These forums are CLOSED. Please visit the new forums HERE
Making a llDialog for chosing a person's name |
|
|
Hanumi Takakura
Registered User
Join date: 24 May 2006
Posts: 57
|
09-12-2007 01:25
Hello. Just wondering how do I make use of llDialog to chose a person's name and do an action based on it. I can do up to the dialog and show names on it using a sensor. But, since all you say in the dialog is the chosen person's name, how do I add a function like, say, move toward that person, or whatever? Do I need to shoot yet another sensor in a different script to also sense the person with that name? Or, should I use things like detectedname(number given to person here)?
|
|
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
|
09-12-2007 02:14
Two Ideas:
After you've chosen the name with llDialog, store the requested AV in a Variable and make another Dialog pop up, where you choose the action that should be taken. Depending on how fast you wanna make the operations, it could be a little slow though, since llDialog has a built in delay (afaik ![]() Or... You could build a HUD with the possible actions as buttons. Once one clicks on a button, the llDialog pops up where you can choose the AV you want to apply the action to. |
|
Hanumi Takakura
Registered User
Join date: 24 May 2006
Posts: 57
|
09-12-2007 03:12
It's only one action, so it should trigger upon saying the name. Now, how do I actually store the said name as a variable upon saying it?
<edit> I have to go work, so I'll check this later. Thanks for any replies. |
|
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
|
09-12-2007 03:57
|
|
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
|
09-12-2007 04:19
well if you store the locations from the sensor along with the name, you can simply llMoveToTarget() toward their coords. You could also send yourself a linked message, either to the same script, or to another in the same attachment.
You can find a script to do a dialog based on the sensor data here: /54/d9/205801/1.html |
|
Hanumi Takakura
Registered User
Join date: 24 May 2006
Posts: 57
|
09-12-2007 16:22
Thanks. Reading now. Though this morning, before going to work, I could manage a rather interesting way of doing it, and since the detected av and the user must both have the same script on, (its a health bar and spell casting stuff) it is safe for everyone not using it. Basically I just made both scripts to communicate to each other and upon saying the av name on the script's channel, the script does the rest. I will lean this way too, as I know I will need it in the future.
|
|
Jen Creeley
Registered User
Join date: 21 Oct 2006
Posts: 5
|
Example
09-13-2007 07:54
Im not on SL right now so this may need a little debugging im not sure, but this might help get you started:
integer listener_handle = -1; integer dialog_channel = 100; list av_names = []; list av_positions = []; list av_keys = []; integer dialog_start = 0; //id is the avatar to send the dialog box to show_avatars(key id) { list buttons = []; if(llGetListLength(av_names) > 10) { integer i; for(i=10 * dialog_start;i<10 * dialog_start;i++) { if(i != 2) buttons += llList2String(av_names,i); else { buttons += "Next 10"; buttons += llList2String(av_names,i); } } } else buttons = av_names; //Dont listen to other commands sent over dialog_channel llListenRemove(listener_handle); listener_handle = llListen(dialog_channel, "", id, ""); llDialog(dialog_channel, "Chose an avatar", buttons, id); } scan_area(float range) { dialog_start = 0; llSensor("", NULL_KEY, AGENT, range, PI); } default { on_rez(integer i) { //Update owner key llResetScript(); } listen(integer channel, string name, key id, string data) { if(data == "Next 10") { dialog_start++; show_avatars(llGetOwner()); } else { integer index = llListFindList(av_names,[data]); if(index != -1) { //This will give you the availablity to use the position and name vector av_pos = llList2Vector(av_positions,index); string av_name = llList2String(av_names,index); key av_key = llList2Key(av_keys,index); llOwnerSay(av_name + " is located at " + (string)av_pos + " and has the key " + av_key + "."); } llListenRemove(listener_handle); } } sensor(integer total_detected) { key owner_key = llGetOwner(); av_names = []; av_positions = []; av_keys = []; integer i; for(i=0;i<total_detected;i++) { //Dont wana put yourself in the list if(llDetectedKey(i) != owner_key) { av_names += llDetectedName(i); av_positions += llDetectedPos(i); av_keys += llDetectedKey(i); } } //Send a dialog to yourself (llGetOwner) or someone else (replace with key) show_avatars(llGetOwner()); } no_sensor() { av_names = []; av_positions = []; av_keys = []; llOwnerSay("No avatars within range."); } } Like i said it might have script errors but it should not be too hard to fix any. Hope this helps ^^ |