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 

GlovePIE question

 
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Remote and Nunchuck
View previous topic :: View next topic  
Author Message
ImCowman



Joined: 15 Dec 2006
Posts: 2

Digg It
PostPosted: Fri Dec 15, 2006 5:35 am    Post subject: GlovePIE question

okok, I know Im new here, this being my first post, but theres something driving me absolutely INSANE.

I know VERY basic code, but Im trying to code something in GlovePIE for the wiimote, and I need a boolean variable.

How do I create a boolean variable in GlovePIE?
and after a value is set, how do I initiate a 'flip', or a switch between the current value and the opposite one?

sorry if this is the wrong place for this, just point me where if this is the case.
_________________
ImCowman
Back to top
View user's profile Send private message AIM Address
deceased
Site Admin


Joined: 11 Dec 2006
Posts: 287
Location: Aurora, ON

Digg It
PostPosted: Fri Dec 15, 2006 5:44 am    Post subject:

just write

Code:
var.boolean = 0 //for false
var.boolean = 1 //for true


GlovePIE is made so that you don't specify boolean, int, etc just write var.X where X is the name of the variable. You can make them go higher to 1 and it knows that it's a number. However, it uses 0 as false and 1 as true (so var.boolean = 0 is the same as writing var.boolean = false).
_________________
-deceased-

Wiili - a gnu revolution
Back to top
View user's profile Send private message
ImCowman



Joined: 15 Dec 2006
Posts: 2

Digg It
PostPosted: Fri Dec 15, 2006 6:14 am    Post subject:

thats awesome, thanks.

by any chance, do you know how id create a way to flip the value?


like if i wanted to swap true for false or vice versa?
_________________
ImCowman
Back to top
View user's profile Send private message AIM Address
deceased
Site Admin


Joined: 11 Dec 2006
Posts: 287
Location: Aurora, ON

Digg It
PostPosted: Fri Dec 15, 2006 3:58 pm    Post subject:

Well first thing: Don't declare variables. Just use them

In other words don't write
Code:

// declaration (don't do this)
var.boolean = false

// if statement 1
if wiimote.A and var.boolean = false then
   Space = true
   var.boolean = true
endif

// if statement 2
if wiimote.B and var.boolean = true then
   Space = false
   var.boolean = false
endif


GlovePIE will never make Space = false again, because as soon as var.boolean = true from if statement 1, the script will read your declaration and var.boolean will equal false. The scripts must be non linear.

So, instead write code like


Code:
// if statement 1
if wiimote.A and var.boolean = false then
   Space = true
   var.boolean = true
endif

// if statement 2
if wiimote.B and var.boolean = true then
   Space = false
   var.boolean = false
endif


Since the variables are automatically set to 0 (false or the number 0) by default when you press A on the wiimote, space will be pressed down, and then when you hit B on the wiimote, it'll be like you took your finger off the space bar.

So basically to flip a value, just create an two if statements where the conditions are that your boolean is true (in the first) and false (in the second). Then make the reult of calling one of those if statements be that the boolean is changed to true (if it was false) and false (if it was true).

Hope that helps.
_________________
-deceased-

Wiili - a gnu revolution
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Remote and Nunchuck All times are GMT
Page 1 of 1

 
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