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 

Newbie question
Goto page 1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    WiiLi.org Forum Index -> GlovePie
View previous topic :: View next topic  
Author Message
cheng



Joined: 27 Jan 2007
Posts: 33

Digg It
PostPosted: Sun Jan 28, 2007 2:14 am    Post subject: Newbie question

Hello

I am playing with the wiimote and trying to do the following things:

when wiimote.pitch <30 && wiimote.pitch >-30, then press key.c and release it

here is my code:

Code:

if wiimote.Pitch < 30  and wiimote.Pitch > -30
press(key.C)
wait(100ms)
release(key.C)
endif


But the problem with this code is, when the pitch angle is in between 30 to -30, key.C will be repeately pressed and released. Is there any way that I can let the program only presses and releases key.C once?

Thank you very much!!

P.S. whenever I want to declear a variable, I need to write "var.myvar = something" right?
Back to top
View user's profile Send private message
TylerK



Joined: 18 Dec 2006
Posts: 384
Location: Springfield, IL

Digg It
PostPosted: Sun Jan 28, 2007 2:35 am    Post subject:

I'll throw out a couple of options with slight differences.

This will press C when the Wiimote pitch is between -30 and 30 and release it once the pitch is outside that range again.
Code:

C = (wiimote.Pitch < 30  and wiimote.Pitch > -30)

And this one will press and release C once the Wiimote pitch enters the range. You'll need to move it out of the range to enable it again.
Code:
if (wiimote.Pitch < 30  and wiimote.Pitch > -30) then
  if (!var.cDisable) then
    C = true;
    wait 100 ms;
    C = false
    var.cDisable = true
  endif
else
  var.cDisable = false
endif


Last edited by TylerK on Sun Jan 28, 2007 3:38 am; edited 1 time in total
Back to top
View user's profile Send private message
the-white_knight3



Joined: 27 Jan 2007
Posts: 31

Digg It
PostPosted: Sun Jan 28, 2007 3:36 am    Post subject:

Is there no click function that will press a key for the minimum time, or at least fast enough that a keyboard doesn't register it as more than one press?
Back to top
View user's profile Send private message
cheng



Joined: 27 Jan 2007
Posts: 33

Digg It
PostPosted: Sun Jan 28, 2007 4:06 am    Post subject:

Thank you very much TylerK!

I got another problem, I want to press the wiimote.One once, then the Led1 will start to blink. If I press it again, then it will stop blinking and stay on. Here is the code that I wrote:

Code:
if (wiimote.One) then
   wait(200ms);
   if (!var.onhold) then
      var.onhold = true;
      debug = var.onhold;
       while(var.onhold){
           wiimote.Led1 = 1;
           wait(500ms);
           wiimote.Led1 = 0;
           wait(500ms);
       }end
   else
      var.onhold = false;
      debug = var.onhold;
   endif
endif


The problem with this code is the light only blink once, do you know what's the problem??

Thank you!
Back to top
View user's profile Send private message
the-white_knight3



Joined: 27 Jan 2007
Posts: 31

Digg It
PostPosted: Sun Jan 28, 2007 4:23 am    Post subject:

Turn your computer volume up and run that code

You should hear... infinite loop...
Back to top
View user's profile Send private message
cheng



Joined: 27 Jan 2007
Posts: 33

Digg It
PostPosted: Sun Jan 28, 2007 4:31 am    Post subject:

the-white_knight3 wrote:
Turn your computer volume up and run that code

You should hear... infinite loop...


I didn't hear anything and my speaker is on.
Back to top
View user's profile Send private message
the-white_knight3



Joined: 27 Jan 2007
Posts: 31

Digg It
PostPosted: Sun Jan 28, 2007 4:41 am    Post subject:

Code:

if pressed(wiimote.One) && (var.onhold != 1) then
   var.hold = 1;
endif
if pressed(wiimote.One)&& (var.onhold == 1) then
   var.hold = -1;
endif

var.onhold = var.hold

if(var.onhold == 1)then
   wiimote.Led1 = 1;
   wait(500ms);
   wiimote.Led1 = 0;
   wait(500ms);
endif

debug = var.onhold;


I think that should work. I think the actual only problem in your code is the while loop, just try it as an if statement. Yeah I know, its messed up like that.
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 1, 2, 3, 4, 5  Next
Page 1 of 5

 
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