Im new to SL and need help with an ON/OFF switch
|
Darth Amarula
Registered User
Join date: 28 Mar 2005
Posts: 4
|
03-30-2005 18:13
1)Ok, how do you make an object only turn on when "Touched" with a right click.
2)How do you make an object turn off, or stop what its doing (for ex. to make an object stop doing everything its doing and return to the you have to touch to start state)?
|
Talila Liu
Micro Builder
Join date: 29 Jan 2004
Posts: 132
|
03-30-2005 19:07
Basically here... state default { touch(integer count) { state foo; } }
state foo { ... //Do stuff here touch(integer count) // touch again to turn off. { state default; } } more info can be found about every aspect of LSL at the Wiki And about States
|
Brian Mifflin
Scripting Addict
Join date: 15 Dec 2004
Posts: 182
|
03-30-2005 19:21
Gotta put that stuff in an event!  state default { touch(integer count) { state foo; } }
state foo { state_entry() { ... //Do stuff here }
touch(integer count) // touch again to turn off. { state default; } }
|
Talila Liu
Micro Builder
Join date: 29 Jan 2004
Posts: 132
|
03-30-2005 20:41
err.. right.. I was generalizeing that they would put the events there... Because not everything is run in state_entry()
|
Punklord Drago
Registered User
Join date: 8 Sep 2004
Posts: 22
|
03-31-2005 07:54
Here is A much better way:
integer ON;
state default { state_entry() { ON = FALSE: }
touch_start(integer dex) { if (ON==FALSE) { /// do what ever!!! // this is on!!! ON = TRUE; }
else { //// do what ever!!!! // this is off!!!! ON = FALSE; } } }
hope that helps, thts my tried an true method!!!!!
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
03-31-2005 08:35
From: Punklord Drago Here is A much better way:
hope that helps, thts my tried an true method!!!!! Actually, it's recently been mentioned that using globals like that is *less efficient* than using states. And if you look carefully, you'll see that's true.
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
03-31-2005 08:42
...and proof that 8 space tabs make scripts (or any code) more difficult to digest...
...I'll refrain from commenting on the the C vs K&R/Java brace cuddle issue (but I guess you'll not find it hard to figure where I stand on that).
/esc
|
Zalandria Zaius
Registered User
Join date: 17 Jan 2004
Posts: 277
|
right click event
03-31-2005 08:44
There is no right click event by the way..
|
Brian Mifflin
Scripting Addict
Join date: 15 Dec 2004
Posts: 182
|
03-31-2005 19:51
From: Talila Liu err.. right.. I was generalizeing that they would put the events there... Because not everything is run in state_entry() I assumed so.....no worries, eh?
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
03-31-2005 20:10
From: Zalandria Zaius There is no right click event by the way.. There is for lefties. 
|
Darth Amarula
Registered User
Join date: 28 Mar 2005
Posts: 4
|
reset on rez?
04-01-2005 04:50
lol, whats the script for an object to reset script on rez?
|
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
|
04-01-2005 05:57
From: Darth Amarula lol, whats the script for an object to reset script on rez? on_rez(integer start_param) { llResetScript(); }
|