|
GaL Soyer
Registered User
Join date: 24 Feb 2006
Posts: 47
|
04-02-2007 02:04
hi  if i define global var like: A=4; default { etc. i cant change its value in the script??? i made that: integer Counter=1; default { state_entry() { } control(key id, integer down, integer new) { if (pressed & CONTROL_UP & LineCounter>1) { state PGUP; } if (pressed & CONTROL_DOWN & LineCounter<7) { state PGDN; } } } state PGUP { state_entry() { LineCounter-=1; state default; } } state PGDN { state_entry() { LineCounter+=1; state default; } } whats wrong with that??? and how can i do that?
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
04-02-2007 02:10
Counter or LineCounter?
|
|
GaL Soyer
Registered User
Join date: 24 Feb 2006
Posts: 47
|
04-02-2007 02:17
oups !! all the linecounter are actually counter... i forgot to change them... i copy paste it from SL....
|
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
04-02-2007 07:28
if (pressed & CONTROL_UP & LineCounter>1) { state PGUP; } if (pressed & CONTROL_DOWN & LineCounter<7) { state PGDN; }
I think these if statements aren't quite right. If you want to say "if (this is true and that is true)" then you should use &&. If you want to test for certain bits being set then you should use &. I think you want: if ((pressed & CONTROL_UP) && LineCounter>1) { state PGUP; } if ((pressed & CONTROL_DOWN) && LineCounter<7) { state PGDN; }
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
04-02-2007 07:45
Meade is correct, & is numeric/bitwise and, && is logical. (I hadn't even looked that far after seeing the mismatched variable names.)
|