|
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
|
12-16-2007 09:25
I am trying to use listen events (chat commands) to turn on and off a scripts ability to respond to touch events which change its states. I am beginning to think this cannot be done. The script is below, it keeps giving me a syntax error at the place I marked. This is a simplified version I made just to test the concept and see if I could make it work. I'm trying to create an object that will respond to touch only if the owner turns it on or unlocks it. If this won't work is there another way of doing it? default { state_entry() { llListen(1,"","",""); //anyone can change it. } on_rez(integer rez_num) { llResetScript(); } listen(integer chan, string name, key id, string msg) { if(msg=="chaton") { llWhisper(0, "Chat On"); state H; }
if(msg=="chatoff") { llWhisper(69, "chat off"); state default; } }
///////////ERROR : Syntax error/////////////
state H { touch_start(integer total_number) { llWhisper(0, "State H"); //do stuff state H1; } }
state H1 { touch_start(integer total_number) { llWhisper(0, "State H1"); //do stuff state H2; } }
state H2 { touch_start(integer total_number) { llWhisper(0, "State H2"); //do stuff state_entry; } }
_____________________
 VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30 http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240 http://shop.onrez.com/Archtx_Edo
|
|
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
|
12-16-2007 09:33
Your syntax error is being caused by missing brackets. here is a version that compiles: default { state_entry() {
llListen(1,"","",""); //anyone can change it. } on_rez(integer rez_num) { llResetScript(); }
listen(integer chan, string name, key id, string msg) { if(msg=="chaton") { llWhisper(0, "Chat On"); state H; }
if(msg=="chatoff") { llWhisper(69, "chat off"); state default; } } }
///////////ERROR : Syntax error/////////////
state H { touch_start(integer total_number) {
llWhisper(0, "State H"); //do stuff state H1; } }
state H1 { touch_start(integer total_number) { llWhisper(0, "State H1"); //do stuff
state H2; } }
state H2 { touch_start(integer total_number) { llWhisper(0, "State H2"); //do stuff // state_entry; dont know what you want here.. .maybe state default? } }
|
|
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
|
12-16-2007 10:29
From: RJ Source Your syntax error is being caused by missing brackets. ... .... // state_entry; dont know what you want here.. .maybe state default?
Thanks RJ, you were right about the missing bracket. Dang I swear I checked for that 6 or 7 times before posting. Right also on "state_entry" i would not compile until I changed it to "state default". Now the script works so that "/1 chaton" turns the touch activated states on, but "/1 chatoff" does not work to return to the default state. EDIT: I verified in the wiki that on state change all listens are released. I assume I probably need a new "listen" in each state, if that is possible. ?? EDIT: I tried putting a "listen" inside of state H and it would not compile, I guess I will go read up on it at the wiki. default { state_entry() { llListen(1,"","",""); //anyone can change it. } on_rez(integer rez_num) { llResetScript(); } listen(integer chan, string name, key id, string msg) { if(msg=="chaton") { llWhisper(0, "Chat On"); state H; }
if(msg=="chatoff") { llWhisper(0, "Chat Off"); state default; } } }
state H { touch_start(integer total_number) { llWhisper(0, "State H"); //do stuff state H1; } }
state H1 { touch_start(integer total_number) { llWhisper(0, "State H1"); //do stuff state H2; } }
state H2 { touch_start(integer total_number) { llWhisper(0, "State H2"); //do stuff state default; } }
_____________________
 VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30 http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240 http://shop.onrez.com/Archtx_Edo
|
|
Xhawkx Holden
Registered User
Join date: 1 Nov 2006
Posts: 86
|
12-16-2007 11:00
This is untested... but should work for ya...... default { state_entry() { llListen(1,"","",""  ; //anyone can change it. } on_rez(integer rez_num) { llResetScript(); } listen(integer chan, string name, key id, string msg) { if(msg=="chaton"  { llWhisper(0, "Chat On"  ; state H; } } } state h { state_entry() { llListen(1,"","",""  ; //anyone can change it. } //put touch event here on_rez(integer rez_num) { llResetScript(); } listen(integer chan, string name, key id, string msg) { if(msg=="chatoff"  { llWhisper(0, "Chat off"  ; state default; } } }
|
|
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
|
12-16-2007 12:17
Fantastic, that worked, here is the final working script. /////////////// default { state_entry() { llListen(1,"","",""); //anyone can change it. //llListen(1,"",llGetOwner(),""); //only owner can change it. llWhisper(0, "State Default"); } on_rez(integer rez_num) { llResetScript(); } listen(integer chan, string name, key id, string msg) { if(msg=="chaton") { llWhisper(0, "Chat On, Change to State H"); state H; } } }
state H { state_entry() { llListen(1,"","",""); //anyone can change it. } ////////////put touch event here touch_start(integer total_number) { llWhisper(0, "Change to State H2"); //do stuff state H2; } /////////// on_rez(integer rez_num) { llResetScript(); }
listen(integer chan, string name, key id, string msg) { if(msg=="chatoff") { llWhisper(0, "Chat Off"); state default; } } }
state H2 { state_entry() { llListen(1,"","",""); //anyone can change it. } ////////////put touch event here touch_start(integer total_number) { llWhisper(0, "Change to State H3"); //do stuff state H3; } /////////// on_rez(integer rez_num) { llResetScript(); }
listen(integer chan, string name, key id, string msg) { if(msg=="chatoff") { llWhisper(0, "Chat Off"); state default; } } }
state H3 { state_entry() { llListen(1,"","",""); //anyone can change it. } ////////////put touch event here touch_start(integer total_number) { llWhisper(0, "Change to State Default"); //do stuff state default; } /////////// on_rez(integer rez_num) { llResetScript(); }
listen(integer chan, string name, key id, string msg) { if(msg=="chatoff") { llWhisper(0, "Chat Off"); state default; } } }
_____________________
 VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30 http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240 http://shop.onrez.com/Archtx_Edo
|