WiiLi Wiki frontpage Include your post in the News Get links Hoteles Quito
WiiLi.org Forum Index WiiLi.org
a new revolution
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Feature request
Goto page Previous  1, 2, 3, 4
 
Post new topic   Reply to topic    WiiLi.org Forum Index -> GlovePie
View previous topic :: View next topic  
Author Message
TiagoTiago



Joined: 20 Jan 2007
Posts: 710
Location: Brasil

Digg It
PostPosted: 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
View user's profile Send private message Send e-mail
SwedishFrog
Site Admin


Joined: 25 Jan 2007
Posts: 273
Location: New York

Digg It
PostPosted: 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
View user's profile Send private message Visit poster's website AIM Address
thagerty



Joined: 01 Feb 2007
Posts: 35

Digg It
PostPosted: Fri Feb 16, 2007 5:09 am    Post subject:

Yes i just learned this the hard way and it works great!!!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    WiiLi.org Forum Index -> GlovePie All times are GMT
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
Jump to:  
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