Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

probably a dumb question but... dialog box question

Akamu Hula
Registered User
Join date: 26 Sep 2006
Posts: 8
11-28-2006 11:31
I need to display a dialog box that says something like "Enter number here:" and then an input box where they can enter the number. But I'm not quite sure how to do this... help!! :)

Thanks in advance!
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
11-28-2006 11:36
LSLWiki on llDialog

This can't accomplish that, exactly.. You have to have something to put in the buttons ahead of time.

You may want to consider asking the user to input via chat, then collect the data input through the listen event.
_____________________
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
11-28-2006 11:36
Can't be done with dialog boxes. They only allow essentially "multiple choice" answers.

The best way I know to do direct data input is to use a listen and type the data into the chat bar.
Akamu Hula
Registered User
Join date: 26 Sep 2006
Posts: 8
so ...
11-28-2006 11:37
so there's no way to do something that looks like the Pay dialog box (when you pay someone)?
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
11-28-2006 11:39
From: Akamu Hula
so there's no way to do something that looks like the Pay dialog box (when you pay someone)?

Precisely!
_____________________
Akamu Hula
Registered User
Join date: 26 Sep 2006
Posts: 8
...since i'm new to scripting
11-28-2006 11:40
I'm new to scripting ... is there an example of a simple one question/one answer listener?

Thanks!
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-28-2006 12:19
llDialog allows you to specify a line of text, well actually about 6 I think, and 12 possible choices. This is displayed to the user and when they press a button the text on the button is sent back via the specified chat channel.


The following code is a very simple menu
CODE

list MenuChoices = ["Small","Medium","Large","Huge"];
integer Listening = 0;
integer listenchannel = 0;



UpdateListen(key id)
{
CancelListen();
Listening = llListen(listenchannel,"",id,"");
// Start 30 second timer
llSetTimerEvent(30);
}

CancelListen()
{
if(Listening > 0) llListenRemove(Listening);
Listening = 0;
llSetTimerEvent(0);
}

// Owner Conversation Dialog
ShowMainMenu(key id)
{

string text = "Menu\nPlease Select an Option";
llDialog(id,text,MenuChoices,listenchannel);
UpdateListen(id);
}


// States
default
{
state_entry()
{
llSetTimerEvent(0);
}

on_rez(integer num) { llResetScript(); }

changed(integer change)
{
// something changed
if (change & CHANGED_INVENTORY)
{
llResetScript();
}
}

touch_start(integer total_number)
{
// Owner
key id = llDetectedKey(0);
if( (id == llGetOwner()))
{
// Random Channel
listenchannel = (integer)llFrand(1000) + 10;
ShowMainMenu(id);
}
}

timer()
{
CancelListen();
}

listen( integer channel, string name, key id, string message )
{
CancelListen();

if("Small" == message) llOwnerSay("small");
else if("Medium" == message) llOwnerSay("medium");
else if("Large" == message) llOwnerSay("large");
else if("Huge" == message) llOwnerSay("huge");
}
}

Dai Vega
Registered User
Join date: 22 Jan 2006
Posts: 9
....
11-28-2006 14:44
If I wanted to just have the script say "Please enter number into chat box", what should the script look llike to listen for the answer?
Akamu Hula
Registered User
Join date: 26 Sep 2006
Posts: 8
... simpler question
11-28-2006 14:51
So, if I just wanted to display (in chat) "Please enter a number into chat", what does the script need to look like to display that text and then listen for the answer?

Thanks - sorry. Very new at this. :)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-28-2006 15:03
From: Akamu Hula
So, if I just wanted to display (in chat) "Please enter a number into chat", what does the script need to look like to display that text and then listen for the answer?

Thanks - sorry. Very new at this. :)



If you just want to do it in chat then its really very simple
I'm making it touch activated purely because I can and its the 'right' thing to do.
You will see I'm using all the same structure as I did for the previous Dialog version.

CODE

integer Listening = 0;
integer listenchannel = 0;

UpdateListen(key id)
{
CancelListen();
Listening = llListen(listenchannel,"",id,"");
// Start 30 second timer
llSetTimerEvent(30);
}

CancelListen()
{
if(Listening > 0) llListenRemove(Listening);
Listening = 0;
llSetTimerEvent(0);
}

// States
default
{
state_entry()
{
llSetTimerEvent(0);
}

touch_start(integer total_number)
{
// Owner
key id = llDetectedKey(0);
llSay(0,"Hi " + llKey2Name(id) + ", Please type a number in to chat");
UpdateListen(id);
}

timer()
{
CancelListen();
}

listen( integer channel, string name, key id, string message )
{
CancelListen();
llSay(0,"Thank You, You typed " + message);
}
}

Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-28-2006 15:40
Hee is a bare bones basic one. It will repeat whatever you say after you touch it and then the listen will be removed.


CODE

integer chan;
default
{
touch_start(integer n) {
chan = llListen(0, "", llGetOwner(), "" );
llOwnerSay("Type something and I will say it");
}
listen(integer channel, string name, key id, string message){
llOwnerSay(message);
llListenRemove(chan);
}
}


EDIT: corrected channel
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Squeebee Wakawaka
Newbie Savant
Join date: 22 Feb 2006
Posts: 28
11-29-2006 07:25
Ok, I am fairly new to LSL but I have to ask why use a flag called listening when you can use states? My first instinct with this scenario is:

CODE

default
{
touch_start(integer n)
{
state listen;
}
}

listen
{
state_entry()
{
llListen(0, "", llGetOwner(), "" );
llOwnerSay("Type something and I will say it");
}

listen(integer channel, string name, key id, string message)
{
llOwnerSay(message);
state default;
}
}


Is there anything wrong with such an approach?
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-29-2006 07:50
From: Squeebee Wakawaka
Ok, I am fairly new to LSL but I have to ask why use a flag called listening when you can use states? My first instinct with this scenario is:

CODE

default
{
touch_start(integer n)
{
state listen;
}
}

listen
{
state_entry()
{
llListen(0, "", llGetOwner(), "" );
llOwnerSay("Type something and I will say it");
}

listen(integer channel, string name, key id, string message)
{
llOwnerSay(message);
state default;
}
}


Is there anything wrong with such an approach?


The reason for the listening variable is to get a 'handle' to the listen we have set up.
It allows us to kill of the listen when we no longer need it using llListenRemove.

EDIT I was wrong, Listens are removed on state change....
Changing state wont kill the listen, it will still be active when you next return to that state.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-29-2006 10:39
From: Squeebee Wakawaka
Ok, I am fairly new to LSL but I have to ask why use a flag called listening when you can use states? My first instinct with this scenario is:

CODE

default
{
touch_start(integer n)
{
state listen;
}
}

listen
{
state_entry()
{
llListen(0, "", llGetOwner(), "" );
llOwnerSay("Type something and I will say it");
}

listen(integer channel, string name, key id, string message)
{
llOwnerSay(message);
state default;
}
}


Is there anything wrong with such an approach?

Some people think of it as a hack, using a state change like that. But I abuse state changes like that all of the time including doing exactly what you did. But I was also trying to show him the most basic listen I could come up with.

BTW there are a couple of problems with your script. You can not use a function name like that for a state name, it will not compile. You could use something like "state listen1" for example. Also default is the only state that can be addressed without using state first. "listen" even if changed to "listen1" or something else will not work. "state listen1" does work.

Other then that you script works fine and the listen is not active in state default:

CODE

default
{
touch_start(integer n)
{
state anynameexceptfunction;
}
}

state anynameexceptfunction
{
state_entry()
{
llListen(0, "", llGetOwner(), "" );
llOwnerSay("Type something and I will say it");
}

listen(integer channel, string name, key id, string message)
{
llOwnerSay(message);
state default;
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-29-2006 13:08
You missed the point though Jesse.
The listens would be building up each time it was actioned, you would end up with more than 64 listens and crash the script.

From: WIKI
"If a script goes over its limit of around 64, it crashes with a run-time "Too Many Listens" error."