Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Breaking out of a loop in a linked prim

Galdor Fackler
Registered User
Join date: 19 Mar 2006
Posts: 20
07-24-2006 23:37
I just started writing my 1st LSL script and I'm baffled. For those of you who haven't snickered and run away yet......

I have this script that sets up a menu to control a linked prim.

integer CHANNEL=140;
list MAIN_MENU = ["On","Off"];

default
{
state_entry()
{
llListen(CHANNEL,"", NULL_KEY,"";);
llMessageLinked(LINK_SET,0,"Off", NULL_KEY);
}

touch_start (integer total_number)
{
llDialog(llDetectedKey(0),"Main Menu", MAIN_MENU, CHANNEL);
}
listen(integer channel, string name, key id,string message)
{
if (message == "On";)
{
llMessageLinked(LINK_SET,0,"On", NULL_KEY);

}
else if(message == "Off";)
{
llMessageLinked(LINK_SET,0,"Off", NULL_KEY);
}
}

}

-------------------------------------------------
In my linked prim is this script:
-------------------------------------------------
// This is the function I want to repeat
move_my_prim()
{

llSetPos(<0.0, 0.0, 0.02>;);
llSetPos(<0.0, 0.0, 0.06>;);
llSetPos(<0.0, 0.0, 0.1>;);
llSetPos(<0.0, 0.0, 0.06>;);
llSetPos(<0.0, 0.0, 0.02>;);
}

default
{
link_message(integer sender, integer num, string message, key id)
{

if (message == "Off";)
{
llSetPos(<0.0, 0.0, 0.06>;);
}

if (message == "On";)
// loop the function untill "Off" is pressed on the menu
//tried WHILE and DO-WHILE loops here
{
move_my_prim();
}

}
}
------------------------------------------------
I want my function move_my_prim to loop until the menu button "Off" is pressed
The message "Off" is sent to the linked prim but I am unable to get my function to break out of a while loop or a do-while loop.

Any guidence would be appreciated

Galdor
Thraxis Epsilon
Registered User
Join date: 31 Aug 2005
Posts: 211
07-25-2006 00:55
Use a timer to call the movement. Then for the off mode turn the timer off
Galdor Fackler
Registered User
Join date: 19 Mar 2006
Posts: 20
07-25-2006 13:59
Thraxis thanks so much for your guidance.
I used a timed event like you suggested and everything works like it should.

Galdor