Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

quick question re: if/else condition

Fred Hegel
Registered User
Join date: 15 Jul 2006
Posts: 21
06-22-2009 19:48
noob question here:

I'm basically tying to write a state where:

when the state is entered say something then
if the object is touched
then the object says something
else if something is said in chat
then the object returns to the default state.

so far I've written:

state_entry()
{

llWhisper(0, "";); //verify mode is ON

}
***if (touch_start(integer num_detected))

llWhisper(0, "TRACK 1 ON QUE";) //que track
}
else if (message == "RESTART";)
{
state default; //return to default state
}

but I get an error here (***)

can anyone give me a hand?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-22-2009 22:32
you can't have code outside of events, all code must be inside a custom function or inside an event that is also inside of a state. (exceptions for comments and global variables only)

so your code should look like this
CODE

default
{
//-- other event code here
}

state some_other_state
{
state_entry()
{
llWhisper(0, "";); //verify mode is ON
//-- and you need to set up a llListen call here
}

touch_start(integer num_detected)
{
llWhisper(0, "TRACK 1 ON QUE";); //que track
}

listen( vIntChannel, string vStrName, key vKeySpeaker, string message)
{
if (message == "RESTART";)
{
state default; //return to default state
}
}
}


you may want to browse through https://wiki.secondlife.com/wiki/LSL_Portal there are some tutorials on the left, and there are listings of events and what they do linked from the top bar
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Fred Hegel
Registered User
Join date: 15 Jul 2006
Posts: 21
06-23-2009 12:36
Thanks!