|
KINGR Redgrave
Registered User
Join date: 23 Dec 2006
Posts: 37
|
12-26-2006 18:27
Hello again, im back wit another question for the gurus  . anyway i have just learned how to make a dialog box with touch and verbal commands, and now would like to add some commands to the menu list.How would i implement such a thing such as i have my option box open,and an option is to scan an area.How would i implement that into the script so when i click on that option, it does it for me.any help would be appreciated,thanx How would i add it to a script like this?
// 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(); } }
|
|
KINGR Redgrave
Registered User
Join date: 23 Dec 2006
Posts: 37
|
12-26-2006 18:40
One more question,can someone explain prims and rez meanings please?
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
12-26-2006 19:35
You can set all variables via menu with this. It will assign the 12 nearest targets to buttons on the menu, and will list more detail on 15 targets in the top of the menu such as the full name. If it is worn as an attachment you can also fire a particle at the target. list targets; list rate_menu = ["1 sec", "3 sec", "5 sec", "7 sec", "10 sec"]; list range_menu = ["5 M", "10 M", "20 M", "30 M", "96 M"]; list type_menu = ["Agent", "Scripted", "Active", "Passive"]; list radar_options = ["Set Rate", "Set Range", "Detect Type", "Targets", "Ping"]; integer link_num; integer rate = 5; integer range = 96; integer type = SCRIPTED; integer chan; list keys; list names; string long_names; string target_key;
default { state_entry(){ llParticleSystem([]); llSetText("", <0,0,0>, 0); llListenRemove(chan); }
touch_start(integer num){ chan = -84503; llListen(chan,"",llGetOwner(),""); string id = llGetOwner(); llSetTimerEvent(60); link_num = llDetectedLinkNumber(num); llDialog(id, "Radar Options", radar_options, chan); } listen(integer chan, string name, key id, string message){
if (llListFindList(radar_options + range_menu + rate_menu + type_menu, [message]) != -1) if (message == "Set Rate") llDialog(id, "Rate Options", rate_menu, chan);{ llSensorRemove(); llSetText("", <0,0,0>, 0); if (message == "1 sec"){ rate = 1;} else if (message == "3 sec"){ rate = 3;} else if (message == "5 sec"){ rate = 5;} else if (message == "7 sec"){ rate = 7;} else if (message == "10 sec"){ rate = 10;} } if (message == "Set Range") llDialog(id, "Range Options", range_menu, chan);{ llSensorRemove(); llSetText("", <0,0,0>, 0); if (message == "5 M"){ range = 5;} else if (message == "10 M"){ range = 10;} else if (message == "20 M"){ range = 20;} else if (message == "30 M"){ range = 30;} else if (message == "96 M"){ range = 96;} } if (message == "Detect Type") llDialog(id, "Detect Type", type_menu, chan);{ llSensorRemove(); llSetText("", <0,0,0>, 0); if (message == "Agent"){ type = AGENT;} else if (message == "Scripted"){ type = SCRIPTED;} else if (message == "Active"){ type = ACTIVE;} else if (message == "Passive"){ type = PASSIVE;} } if (message == "Targets"){ if (llGetListLength(targets) == 0){ llOwnerSay("No Targets"); return; } else{ llDialog(id, long_names, targets, chan); } } if (message == "Ping"){ llSensor("", NULL_KEY, type, range, PI); } if (llListFindList(targets,[message]) != -1){ list msg = [message]; integer msg_int = llListFindList(names, msg); target_key = llList2String(keys, msg_int); state particles; } } sensor(integer n) { vector pos = llGetPos(); list result; long_names = ""; string name; vector angle; string angles; integer p; for (p=n; p>=0; p--) { vector pos2 = llDetectedPos(p); integer dist = llRound(llVecDist(pos, pos2)); angle = llVecNorm(pos2 - pos); angles += ((string)angle); angles += "\n"; if(dist <= range && llDetectedKey(p) != NULL_KEY){ name = llDetectedName(p); long_names += ((string)(p) + " " + name + " @ " + (string)dist); long_names += "\n"; result += [(string)p] + [llDetectedName(p)] + [llDetectedKey(p)] + [dist]; } } names = llList2ListStrided(result, 0, -1, 4); keys = llList2ListStrided(llDeleteSubList(result, 0, 1), 0, -1, 4); integer list_length = llGetListLength(names); if (list_length > 12){ integer dif = (list_length - 12); targets = llList2List(names, dif, -1); } else{ targets = llList2List(names, 0, -1); } } no_sensor() { llSetText("", <0,0,0>, 0); } timer() { llSetTimerEvent( 0 ); llListenRemove(chan); return; } }
state particles{ state_entry(){ float part = (5.0); llSetTimerEvent(part); llParticleSystem([PSYS_PART_FLAGS, PSYS_PART_EMISSIVE_MASK | PSYS_PART_TARGET_POS_MASK, PSYS_PART_START_COLOR, <1.0,1.0,1.0>, PSYS_PART_START_SCALE,(vector) <.3 ,.3 , 0 >, PSYS_SRC_BURST_PART_COUNT,(integer)1, PSYS_SRC_BURST_RATE, (float)3.0, PSYS_SRC_MAX_AGE, part, PSYS_SRC_BURST_SPEED_MIN, (float)20.0, PSYS_SRC_BURST_SPEED_MAX, (float)20.0, PSYS_SRC_TARGET_KEY, (key) target_key]); } timer(){ 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
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
12-26-2006 19:36
From: KINGR Redgrave One more question,can someone explain prims and rez meanings please? hmmmm Could you clarify this request some?
_____________________
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
|
|
KINGR Redgrave
Registered User
Join date: 23 Dec 2006
Posts: 37
|
12-26-2006 19:49
Awsome for such a quick response Jesse, im going to get playing with this and will ask for some help if needed.lol wich i probably will be doing shortly. Oh i was just wondering what do people mean when they talk about a "Prim" or when they say "it has to be rezzed or rez it" or something like that.I dont know what those terms means,and if anyone could explain if you could explain that would help.thanks
|
|
KINGR Redgrave
Registered User
Join date: 23 Dec 2006
Posts: 37
|
12-26-2006 20:54
also, i know i sound like im repeating myself, but what is the commands to have the dialog just come up instead up touching it?i have scripts that work offvoice commands but how could i simply add a string of script to have the dialog show off voice command just for the menu only.not to control the menu.
|
|
Zaphod Kotobide
zOMGWTFPME!
Join date: 19 Oct 2006
Posts: 2,087
|
12-27-2006 03:49
string MENU_PROMPT = "What do you need help with?"; list MENU_BUTTONS = ["Buying", "Selling"]; integer MENU_CHANNEL = 1024;
default { state_entry() { llListen(0,"",NULL_KEY,""); } listen(integer channel, string name, key id, string message) { if (llToLower(message) == "help") { llDialog(id, MENU_PROMPT, MENU_BUTTONS, MENU_CHANNEL); } } }
That is the barebones of what you'd need. BUT - you generally should AVOID scripts listening on channel 0, as it can and will be a heavy cost in areas with any significant chatter within range of the script. A "prim" is short for "Primitive Shape".. any of the predefined shapes available in your build tool.. those are "prims".. simple, or "primitive" geometric shape. "Rez" comes from the classic movie "Tron", and I believe is short for "Resolve".. in SL speak, it's simply a way of referring to any of several ways to cause an object to appear in world, whether it's via scripting, or an agent dragging something from inventory out into the world.. that process is called "rezzing". zk
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
Avoiding IF's
12-27-2006 08:30
Jesse, you're over using the IF statement in your listen. Because of the nature of the values being requested you can short cut it using a llListFindList and a simple cast. integer value = (integer)msg; integer index = llListFindList(rate_menu, [ msg ] ); if(index >= 0) { rate = value; } else { index = llListFindList(range_menu, [ msg ] ); if(index >= 0) { range = value; } }
Likewise if you altered the ordering of the target options to match teh constants you could calculate rather than have to use IF's. list type_menu = ["Agent", "Active", "Passive", "Scripted"];
Then in the listen index = llListFindList(type_menu, [ msg ] ); if(index >= 0) { type = 2 ^ index; }
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
12-27-2006 08:56
Cool I will play around with this some later but a question till then. I can not get my mind around 2 ^ index. The wiki doesn't really show XOR being used like this. How or what is ^ evaluating????
_____________________
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
|
12-27-2006 09:15
From: Jesse Barnett Cool I will play around with this some later but a question till then. I can not get my mind around 2 ^ index. The wiki doesn't really show XOR being used like this. How or what is ^ evaluating???? Oops, sorry but wasn't XOR'ing just power of, i.e. 2 ^ 0 = 1, 2^ 1 = 2, 2 ^ 2 = 4 etc... I guess I'm confusing the languages. Try 1 << index instead.
|
|
KINGR Redgrave
Registered User
Join date: 23 Dec 2006
Posts: 37
|
12-27-2006 16:02
thanks again for all the help and information.hopefully i can contribute as well soon.
|