 |
WiiLi.org a new revolution
|
| View previous topic :: View next topic |
| Author |
Message |
TiagoTiago
Joined: 20 Jan 2007 Posts: 710 Location: Brasil
Digg It |
Posted: Fri Feb 16, 2007 4:19 am Post subject: |
|
|
aren't commands inside an if block executed linearlly? _________________ please put the scripts on the wiki so they dont get lost as new stuff is posted!
phpBB doesnt like me,somtimes it will forget to warn me about new replies to threads I asked it to,if you see a thread I should have responded, could please email me? |
|
| Back to top |
|
 |
SwedishFrog Site Admin

Joined: 25 Jan 2007 Posts: 273 Location: New York
Digg It |
Posted: Fri Feb 16, 2007 5:00 am Post subject: |
|
|
Yeah, each line inside executes linearly with respect to each other. However, if the condition for the IF statement continues to be true, then that linear code will be executed again and again.
My understanding is that each code block, such as an if statement, starts its own thread which executes that block of code on a loop, until the IF condition becomes false. (if i'm wrong about this then please correct me)
If you want that code to execute only once for every time the condition turns from true to false, use the pressed function. Pressed will only be true at the moment that condition becomes true. The next time glovepie loops through and reads that if statement, pressed() will be false, effectively preventing that IF code block from executing again.
For example, instead of the regular if:
if wiimote.a then
//code executes on a loop as long as wiimote.a = true
you wrap the pressed function around it
if pressed(wiimote.a)
//code executes once |
|
| Back to top |
|
 |
thagerty
Joined: 01 Feb 2007 Posts: 35
Digg It |
Posted: Fri Feb 16, 2007 5:09 am Post subject: |
|
|
| Yes i just learned this the hard way and it works great!!! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|