This should help you understand how multiple
states work.
// States in LSL example by Jim Bunderfeld
integer x = 0;
default
{
touch_start(integer total_number)
{
if (x == 0)
{
llSay(0,"Chakra System Engaged");
x = 1;
llSleep(0.5);
state k; // change to state k.
}
}
}
state k
{
touch_start(integer total_number)
{
if (x == 1)
{
llSay(0,"Chakra System Disengaged");
x = 0;
state default; // change to default.
}
}
}
Unless you have some other use for variable x in this example, it is redundant and potentially confusing. You're using x to keep track of the "current system state", yet that is the purpose (and actual use here) of the state machine. You could easily get rid of all references to x in this example, making the example much simpler, clearer and a proper use of the state machine.
See
ExampleStatesConcise for a clearer example.
Examples /
States