Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Strings and states

Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
02-28-2008 21:08
Using llMessageLinked in the root to communicate with a child prim, how can I take the sting and use it to change states in the child prim with link_message?
example:
the string in the roots llMessageLinked is "on" or "off"
the state in the child is state on or state off
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
02-28-2008 23:38
You send a link message with either "on" or "off" to the linkset and in the child prims you have a link_message event in each state where you check if the appropriate command was given and then switch states.

easy as pie :)
or cake. if it wasn't a lie.
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
02-28-2008 23:40
Is this what you are looking for:

CODE

default
{
state_entry()
{
state off;
}
}

state off
{
state_entry()
{
//do stuff
llOwnerSay("Off");
}
link_message(integer sender_number, integer number, string message, key id)
{
if("on"==message)
state on;
}
}

state on
{
state_entry()
{
//do stuff
llOwnerSay("On");
}
link_message(integer sender_number, integer number, string message, key id)
{
if("off"==message)
state off;
}
}
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
02-29-2008 04:18
From: Very Keynes
Is this what you are looking for:

CODE

default
{
state_entry()
{
state off;
}
}

state off
{
state_entry()
{
//do stuff
llOwnerSay("Off");
}
link_message(integer sender_number, integer number, string message, key id)
{
if("on"==message)
state on;
}
}

state on
{
state_entry()
{
//do stuff
llOwnerSay("On");
}
link_message(integer sender_number, integer number, string message, key id)
{
if("off"==message)
state off;
}
}

Cool, thanks. Seemed to escape me that it still is just a way to communicate and I was way over thinking it.