Rules help
pryceczech
Member, PRO Posts: 15
I have an actor, that I want to add pieces to. There are 4 of the same pieces to add (4 sides of the actor). If he runs into one, he should change image to (actor+1) (where he has 1 of 4 sides). Runs into the second piece, should change image to (actor+2), etc.
I have a global attribute set up, to start as 0.
Under each piece on screen, I have this:
{if Piece collides with Actor}
Destroy Piece
Then under actor, I have this:
{if Actor collides with Piece}
{&& attribute==0}
change image to (actor+1)
change attribute to 1
{&& attribute==1}
change image to (actor+2)
change attribute to 2
{&& attribute==2}
change image to (actor+3)
change attribute to 1
{&& attribute==3}
change image to (actor+4)
change attribute to 4
However, when the Actor collides with the first piece, it automatically changes image to (actor+4).
Any ideas as to why?
I have a global attribute set up, to start as 0.
Under each piece on screen, I have this:
{if Piece collides with Actor}
Destroy Piece
Then under actor, I have this:
{if Actor collides with Piece}
{&& attribute==0}
change image to (actor+1)
change attribute to 1
{&& attribute==1}
change image to (actor+2)
change attribute to 2
{&& attribute==2}
change image to (actor+3)
change attribute to 1
{&& attribute==3}
change image to (actor+4)
change attribute to 4
However, when the Actor collides with the first piece, it automatically changes image to (actor+4).
Any ideas as to why?
Comments
Hi @pryceczech Because basically you've asked it to... ;-)
You asked when the attribute is 0 to make it 1, immediately followed by when it's 1, make it 2, etc..... all the way up to 4, without anything "stopping" it, as it were...
So a couple of ways to solve this; (you could have nested using Otherwise) but here's another way to try:
Rule: When Actor collides with Piece and YourAtt <4
Change Attribute YourAtt to YourAtt+1
Rule: When YourAtt =1
change image to (actor+1)
Rule: When YourAtt =2
change image to (actor+2)
Rule: When YourAtt =3
change image to (actor+3)
Rule: When YourAtt =4
change image to (actor+4)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Any way around that? Or to "expedite" getting rid of each Piece, so that attribute only updates once / piece collided with?
Not sure what you mean now, and why you need to destroy the piece that's being "updated" every time...
If you use the Rules I suggested above, when your actor repeatedly collides with "Piece" it'll update the image every time, but only on each collision, i.e not all at once, which is surely what you're after.... so still no need for any destroy behaviours..or have I misunderstood something?
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Edit: hang on, I think I told you wrong... you are best to use the Otherwise, as I first suggested, I'm thinking, so try this:
Rule: When Actor collides with Piece and YourAtt <4
Change Attribute YourAtt to YourAtt+1
Rule: ---nested in above rule--When YourAtt =1
change image to (actor+1)
Otherwise
Rule: When YourAtt =2
change image to (actor+2)
Otherwise
Rule: When YourAtt =3
change image to (actor+3)
Otherwise
Rule: When YourAtt =4
change image to (actor+4)
That's better; it'll work OK now... second time lucky and all that... ;-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps