Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

change a float via lldialog

Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
10-11-2007 06:31
Need to change some floats with a dialog. I can't find any examples. Anyone have an example of this or point me in the right direction?
Thanks
Atashi Toshihiko
Frequently Befuddled
Join date: 7 Dec 2006
Posts: 1,423
10-11-2007 06:54
Can't you just put the floats as button options in the dialog box then turn the strings into floats in the listen event?

CODE

default {
state_entry() {
llListen(-9999, "", NULL_KEY, "");
}
touch_start(integer num) {
string text = "Please choose a number.";
list buttons = ["0.1", "2.3", "3.4", "4.5", "5.6"];
llDialog(llDetectedKey(0), text, buttons, -9999);
}
listen(integer chn, string name, key id, string message) {
float variable = (float)message;
}
}


That's a pretty simple example, of setting a float variable with a dialog box.

-Atashi
_____________________
Visit Atashi's Art and Oddities Store and the Waikiti Motor Works at beautiful Waikiti.
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
10-11-2007 07:04
sendDialog(key id,string valuename,float value,integer listenchannel,integer dialogchannel)
{
llDialog(id, "Change the value "+valuename+" from "+(string)value+" by using the buttons below, alternatively, say the value on channel "+(string)listenchannel, ["+1.0", "+0.5", "+0.2", "+0.1", " ", "-0.1", "-0.2", "-0.5", "-1.0"], dialogchannel);
}

where id is the agent's key, valuename is the name of the value you wish to change, value is it's value and listenchannel and dialogchannel are channels.

listen(integer chan, string name, key id, string msg)
{
if (chan==dialogchannel)
{
if ( msg == "+1.0" ) value += 1.0;
else if ( msg == "+0.5" ) value += 0.5;
else if ( msg == "+0.2" ) value += 0.2;
else if ( msg == "+0.1" ) value += 0.1;
else if ( msg == "-0.1" ) value -= 0.1;
else if ( msg == "-0.2" ) value -= 0.2;
else if ( msg == "-0.5" ) value -= 0.5;
else if ( msg == "-1.0" ) value -= 1.0;

if ( value > maxvalue ) value = maxvalue;
else if ( value < minvalue ) value = minvalue;
sendDialog(id, valuename, value, listenchannel, dialogchannel);
}
}
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-11-2007 10:34
if you use dialog, there's a nice trick to shutting down the listener... when the diallog is called, also call llSetTimerEvent( 30 ); and in your timer call llSetTimerEvent( 0 ), and either llListenRemove(x) or change to another state and back to clear all listens...

set timer event will keep putting the listen close off till 30 seconds after it's called, so the listen will expire 30 seconds after the last time it's opened