Making a loop - pulling my hair out
andersduus
Member Posts: 12
Hi I'm trying to make a box in an elevator move up and down.
the box has 5 positions (called boxpos 1,2,3,4,5)
i'm trying to make a loop with a timer, so every 1 second it updates the attribute boxpos = boxpos + 1
each box then check if boxpos = 4 set alpha to 100.
thats working fine.
My problem is - i want my loop to change direction when boxpos = 5 then I want it to set boxpos = boxpos - 1 until boxpos = 0 then i should +1 again.
How do I do that? I have an attribute called boxDirection, but its not working?
Thanks for your help.
Anders
the box has 5 positions (called boxpos 1,2,3,4,5)
i'm trying to make a loop with a timer, so every 1 second it updates the attribute boxpos = boxpos + 1
each box then check if boxpos = 4 set alpha to 100.
thats working fine.
My problem is - i want my loop to change direction when boxpos = 5 then I want it to set boxpos = boxpos - 1 until boxpos = 0 then i should +1 again.
How do I do that? I have an attribute called boxDirection, but its not working?
Thanks for your help.
Anders
Comments
do
every 1 sec change boxpos to boxpos+1
else
every 1 sec change boxpos to boxpos-1
if boxpos = 5
do
change game.boxDirection to true
if boxpos = 1
change game.boxdirection to false
this should work
✮ FREE templates at GSinvention ✮
✮ Available for hire! support@gsinvention.com ✮
@andersduus
Hi Anders, hopefully the attached test file will help you.
P.S And welcome to the Forums. :-)
P.P.S typing while @timolapre1998 was replying.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
@gyroscope thanks a lot. A whole lot more nested rules and times than I had - seems like the way forward. I'll let you know if it worked for me :-)
@gyroscope it's so odd. when I recreate you code in my project the counter does not stop at 5, but continues....
https://www.dropbox.com/s/wv1p6285bd3waqa/int updown.gameproj.zip
this is probably a little bit easier and you can just typ is over?
✮ FREE templates at GSinvention ✮
✮ Available for hire! support@gsinvention.com ✮