Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sensor avatars, and formatted dialog with Next/Previous Buttons

Evil Fool
"==" != "="
Join date: 30 Jul 2004
Posts: 110
01-20-2005 13:54
this has many more applications than just for a sensor... but this example works pretty well for what it does
(cross-post with /54/26/33489/1.html#post353229 )

CODE

//Formatted Sensor Dialog script by Evil Fool
// You may give this script away for free, but please leave creator information in.
// Next owner MUST have script modify access if any of this code is used in part or whole
//CONFIG
integer gOwnerOnly = FALSE;
integer gChann = -93190;
integer gStride = 9;
//END CONFIG

list names;
integer gPos = 0;
key tReq;

dialog(key id)
{
integer nTop = gPos + gStride - 1;
list buttons = llList2List(names, gPos, nTop);
string msg = llDumpList2String(buttons, "\n");
if (gPos >= gStride)
{
buttons += ["PREVIOUS"];
}else{
buttons += [" "];
}

if (nTop - 1 < llGetListLength(names))
{
buttons += ["NEXT"];
}else{
buttons += [" "];
}

while(llGetListLength(buttons) % 3 != 0)
{
buttons = llListInsertList(buttons, [" "], gStride);
}

llDialog(id, msg, buttons, gChann);
}

default
{
state_entry()
{
llListen(gChann, "", NULL_KEY, "");
}

touch_start(integer num_times)
{
if ( ( gOwnerOnly == TRUE && llDetectedKey(0) == llGetOwner() ) || gOwnerOnly == FALSE)
{
tReq = llDetectedKey(0);
llWhisper(0, "Restarting script for user " + llDetectedName(0) + "!");
llSensor("", NULL_KEY, AGENT, 96.0, PI);
}
}

sensor(integer num_detected)
{
names = [];
gPos = 0;
integer i;
for (i = 0; i < num_detected; i++)
{
names = names + llDetectedName(i);
}
dialog(tReq);
}

listen(integer channel, string name, key id, string msg)
{
if (msg == "NEXT")
{
gPos = gPos + gStride;
dialog(id);
}else if (msg == "PREVIOUS")
{
gPos = gPos - gStride;
dialog(id);
}else if (msg == " ")
{
llSay(0, "Sorry, this is just a filler!");
}else{
llSay(0, msg);
}
}
}


currently only supports 1 user using it at a time... but its pretty cool (you can set it to owner only, using the gOwnerOnly setting at the top, if you realy want)

Give it a shot... you might just like it (and there are probably some better ways to do some things, suggestions welcome)
Evil Fool
"==" != "="
Join date: 30 Jul 2004
Posts: 110
01-27-2005 19:14
fixed it up a bit... seems to work alot better now in formatting

CODE
//Formatted Sensor Dialog script by Evil Fool
// You may give this script away for free, but please leave creator information in.
// Next owner MUST have script modify access if any of this code is used in part or whole
//CONFIG
integer gOwnerOnly = FALSE;
integer gChann = -293190;
integer gStride = 9;
//END CONFIG

list names;
integer gPos = 0;
key tReq;

dialog(key id)
{
integer nTop = gPos + gStride - 1;
list buttons = llList2List(names, gPos, nTop);
string msg = llDumpList2String(buttons, "\n");
while(llGetListLength(buttons) % 3 != 0)
{
buttons = llListInsertList(buttons, [" "], gStride);
}
if (gPos >= gStride)
{
buttons += ["PREVIOUS"];
}else{
buttons += [" "];
}
buttons += [" "];
if (nTop - 1 < llGetListLength(names))
{
buttons += ["NEXT"];
}else{
buttons += [" "];
}

llDialog(id, msg, buttons, gChann);
}

default
{
state_entry()
{
llListen(gChann, "", NULL_KEY, "");
}

touch_start(integer num_times)
{
if ( ( gOwnerOnly == TRUE && llDetectedKey(0) == llGetOwner() ) || gOwnerOnly == FALSE)
{
tReq = llDetectedKey(0);
llWhisper(0, "Restarting script for user " + llDetectedName(0) + "!");
llSensor("", NULL_KEY, PASSIVE, 96.0, PI);
}
}

sensor(integer num_detected)
{
names = [];
gPos = 0;
integer i;
for (i = 0; i < num_detected; i++)
{
names = names + llDetectedName(i);
}
dialog(tReq);
}

listen(integer channel, string name, key id, string msg)
{
if (msg == "NEXT")
{
gPos = gPos + gStride;
dialog(id);
}else if (msg == "PREVIOUS")
{
gPos = gPos - gStride;
dialog(id);
}else if (msg == " ")
{
llSay(0, "Sorry, this is just a filler!");
}else{
llSay(0, msg);
}
}
}