Page 1 of 1

Toggle on/off Low Level

Posted: Sat Jun 03, 2006 6:07 pm
by noobscripter
Can someone explain to me why this snppet wont turn on then off ?
Running Low Level.

Switch [false]

Idle[()
{
if( self.key_pressed = 52)
{
if(Switch=false)
{
Switch=true;
}
if(Switch=true)
{
Switch=false;
}
}
}]

It will only tunr True 1 time. It wont do a simplr toggle to true / false.

PLs help. :P

The NOOB

Posted: Sat Jun 03, 2006 6:35 pm
by AndyCR
been awhile since i used simkin, but are you looping the idle function? ie

Switch [false]

Idle[()
{
if( self.key_pressed = 52)
{
if(Switch=false)
{
Switch=true;
}
if(Switch=true)
{
Switch=false;
}
}
RestartOrder();
}]

also, try this: instead of if switch is true make it false blah blah try:

Switch = !Switch;

Posted: Sat Jun 03, 2006 6:54 pm
by Juutis
That RestartOrder() isn't needed there... it is actually a highlevel command.

I think the problem is this:
if(Switch=false)
{
Switch=true;
}
if(Switch=true)
{
Switch=false;
}
Since the switch is false in the beginning it will first turn to true but immediately after that in the second if-thingie (now the switch is "true") it will turn back to false. Also it's good to have the self.ThinkTime there. What you need is something like:
Idle[()
{
self.ThinkTime = 0.1;

if( self.key_pressed = 52)
{
if(Switch=false)
{
Switch=true;
}
else
{
Switch=false;
}
}
}]
The "Switch = !Switch" thing should work too, i guess.

Posted: Sat Jun 03, 2006 7:00 pm
by jonas
That's what I was thinking but I didn't know for sure so I kept my mouth shut.

Posted: Sat Jun 03, 2006 8:31 pm
by AndyCR
ah. sorry. i know too little about simkin.

Posted: Fri Jun 23, 2006 5:28 pm
by rgdyman
if(self.key_pressed=K_STRAFE)
{
self.ThinkTime=0.1;
if(STRAFE=false)
{
STRAFE=true;
return;
}
if(STRAFE=true)
{
STRAFE=false;
return;
}
}


Need the

return;

:)