Script HELP??
|
|
KINGR Redgrave
Registered User
Join date: 23 Dec 2006
Posts: 37
|
12-25-2006 15:06
hello, i just had a question about a script that will bring up a menu box when you enter text into the chat window. I have scripts that when you touch an object the menu box appears,and i have a script that when you type a command it does the command.I just cant seem to figure out how to type in command and have the menu box appear.If anyone can post a simple script showing me how that would be highly appreciated,thanks Blueprints
|
|
KINGR Redgrave
Registered User
Join date: 23 Dec 2006
Posts: 37
|
12-25-2006 16:09
No one can help me out here?Please.
|
|
Peekay Semyorka
Registered User
Join date: 18 Nov 2006
Posts: 337
|
12-25-2006 16:40
The script below displays a dialog menu when touched, or when it hears "help me" in the chat channel. Uses different channels for the menu & for the chat. It uses the listen handler's "id" variable to show the menu to the correct person. enjoy, -peekay // Example script which responds to touch and to chat commands // // Peekay Semyorka: free to copy & redistribute.
// Channel to listen for chat commands integer LISTEN_CHANNEL = 0;
// Chat command to listen for string LISTEN_COMMAND = "help me";
// Channel to listen for menu commands integer MENU_CHANNEL = 1024;
// Menu prompt and buttons string MENU_PROMPT = "What do you need help with?"; list MENU_BUTTONS = ["Buying", "Selling"];
// Menu expires after this number of seconds integer TIMEOUT_SECS = 60;
// Internal handle to keep track of menu listener integer hMenu = -1;
// Method to show the dialog menu to the user showMenu(key id) { hMenu = llListen(MENU_CHANNEL, "", id, ""); llDialog(id, MENU_PROMPT, MENU_BUTTONS, MENU_CHANNEL);
// setup up menu expireation timer llSetTimerEvent(TIMEOUT_SECS); }
// Method to remove the menu listener stopMenuListen() { llSetTimerEvent(0); if (hMenu != -1) { llListenRemove(hMenu); hMenu = -1; } }
default { state_entry() { // Listen to chat channel for command llListen(LISTEN_CHANNEL, "", NULL_KEY, LISTEN_COMMAND); } touch_start(integer num_detected) { // Show dialog menu integer i; for (i = 0; i < num_detected; i++) { showMenu(llDetectedKey(i)); } }
listen(integer channel, string name, key id, string msg) { if (channel == LISTEN_CHANNEL) { // We heard something in chat, see if it's the command word if (msg == LISTEN_COMMAND) { llSay(0, "I heard you"); showMenu(id); } } else if (channel == MENU_CHANNEL) { // A menu button was invoked, see which button it was stopMenuListen(); if (msg == "Buying") { llSay(0, "To buy anything, you need a lot of money"); } else if (msg == "Selling") { llSay(0, "To sell something, list it in the classifieds"); } else { llSay(0, "No such menu item: " + msg); } } } timer() { // Called when the menu timer expires stopMenuListen(); } on_rez(integer start_param) { // Reset script on rez, for good measure llResetScript(); } }
|
|
Champie Jack
Registered User
Join date: 6 Dec 2003
Posts: 1,156
|
12-25-2006 17:01
From: KINGR Redgrave No one can help me out here?Please. I'll help. Read the WikillListenllDialog
|
|
KINGR Redgrave
Registered User
Join date: 23 Dec 2006
Posts: 37
|
12-25-2006 18:02
alright thanks alot for the help.im going to try out that script and hopefully i can work with sorry.Sorry im just a little new to lsl scripting,well programming in general.ive done a little bit of python but nothing much.thanks again for the help its highly appreciated
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
12-25-2006 19:24
I apologize for part of the reception you recieved here KINGR. Being Christmas day there weren't as many people on to answer your question. If you need any help with what Peekay posted then please ask away. Questions are always welcome. If you click the name of someone that gave a flippant remark here instead of help you will see by the threads they started that they are a troll. Strange how some of the weird and downright mean posts have popped up here in the last couple of days from people that never post in the Scripting Forum. Guess some people are having a less then joyful Christmas. Go back and look at the threads in history and you will find it is normally a warm and inviting place here and we are always happy to help new people learn LSL.
_____________________
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
|
|
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
|
12-25-2006 19:36
Apologies I had this all typed in but didn't want to send before testing, then of course something shiny went by... this is about as simple an example as can be. integer CHANNEL = 4; default { state_entry() { llListen(CHANNEL, "", llGetOwner(), ""); } on_rez(integer param) { llResetScript(); } listen(integer channel, string name, key id, string message) { if (message == "menu") { llDialog(llGetOwner(), "Choose an option:", ["Yes", "No"], CHANNEL); } if (message == "Yes") llOwnerSay("You said yes"); if (message == "No") llOwnerSay("You said no"); } }
|
|
Champie Jack
Registered User
Join date: 6 Dec 2003
Posts: 1,156
|
12-25-2006 20:02
From: Jesse Barnett I apologize for part of the reception you recieved here KINGR. Being Christmas day there weren't as many people on to answer your question. If you need any help with what Peekay posted then please ask away. Questions are always welcome. If you click the name of someone that gave a flippant remark here instead of help you will see by the threads they started that they are a troll. Strange how some of the weird and downright mean posts have popped up here in the last couple of days from people that never post in the Scripting Forum. Guess some people are having a less then joyful Christmas. Go back and look at the threads in history and you will find it is normally a warm and inviting place here and we are always happy to help new people learn LSL. aw, was I mean for giving him links to the relevent pages in the wiki? I offered what I could. It is far more than you offered on the topic, Jesse. I won't go so far as to call you any names, because I think you are doing what you believe to be a good thing. I do admire that you feel the compulsion to defend KINGR even if he hasn't been attacked.
|
|
KINGR Redgrave
Registered User
Join date: 23 Dec 2006
Posts: 37
|
12-25-2006 20:24
i thank everyone for the help and can see how wonderful this comunnity of people are and would love to be a part of it. Thanks Jesse for the explanation i appreciate it.And thank you too Champie even though your reply sounded a little "smart", and thank you too Boss for the script,both of them are working well.Hopefully everyone had a nice christmas,and hopefully i can contribute to people in need also.
|
|
Champie Jack
Registered User
Join date: 6 Dec 2003
Posts: 1,156
|
12-25-2006 21:17
From: KINGR Redgrave i thank everyone for the help and can see how wonderful this comunnity of people are and would love to be a part of it. Thanks Jesse for the explanation i appreciate it.And thank you too Champie even though your reply sounded a little "smart", and thank you too Boss for the script,both of them are working well.Hopefully everyone had a nice christmas,and hopefully i can contribute to people in need also. Yes, I can understand. But I have to ask, Was it useful information? My apologies for coming off terse and/or "smart-ass." I do hope you find the WIKI useful. It is maintained and contributed to by a bunch of intelligent and helpful people. As your experience with LSL grows I bet you will find it an invaluable resource. I would also add the following: If/when you have help requests, post any code you have that is relevent, even if it isnt complete by enclosing the code in "PHP" "/PHP" tags (replace the " with brackets). When you do this others can direct their responses at exactly where the confusion/problem may be. Hope you had a Merry Christmas, and I wish you the Best New Year!
|
|
KINGR Redgrave
Registered User
Join date: 23 Dec 2006
Posts: 37
|
12-26-2006 08:13
thanks Champie,and yes i did.Ive been using all three scripts to experiment with.Im sure its pretty basic but i just figured out how to add another menu when clicking on a tab in the main menu, so these scripts are coming in real handy.i had a great christmas and hope you had the same.Thanks and have a happy new year also
|