Toggle on/off Low Level

Topics regarding Scripting with Reality Factory
Post Reply
noobscripter
Posts: 1
Joined: Sat Jun 03, 2006 6:02 pm

Toggle on/off Low Level

Post 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
User avatar
AndyCR
Posts: 1449
Joined: Wed Jul 06, 2005 5:08 pm
Location: Colorado, USA
Contact:

Post 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;
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post 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.
Pain is only psychological.
User avatar
jonas
Posts: 779
Joined: Tue Jul 05, 2005 5:43 pm
Location: Texas, USA
Contact:

Post by jonas »

That's what I was thinking but I didn't know for sure so I kept my mouth shut.
Jonas

Focused, hard work is the real key to success. Keep your eyes on the goal, and just keep taking the next step towards completing it. If you aren't sure which way to do something, do it both ways and see which works better. - John Carmack
User avatar
AndyCR
Posts: 1449
Joined: Wed Jul 06, 2005 5:08 pm
Location: Colorado, USA
Contact:

Post by AndyCR »

ah. sorry. i know too little about simkin.
rgdyman
Posts: 84
Joined: Tue Jul 05, 2005 7:05 am

Post 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;

:)
Post Reply