Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Menu Oddity

Lyndzay Meili
Registered User
Join date: 2 Sep 2007
Posts: 28
10-26-2008 18:42
Hi There,

I've made a menu using link messages and every thing works great, but occasionally when I press a button that calls another menu, it will say the button message in chat, the menu will still come up and the new menu will work. It happens on different buttons so I've not been able to figure out which snippet is the culprit.

All menu pages are made the same so I'll just post one of the smaller ones and hope someone sees something that I'm missing.

Thanks Lyndz~

php

//Ammo Menu v.1 for Lyndzmatic Flaming Toast Launcher v2.0
//by Lyndzay Meili
//Sets what's being shot out of the toaster

list FOOD = ["Toast", "Waffles", "Bagels", "Hide", "Show","<==BACK", "CLOSE"]; //Ammo choices
integer channel;
integer listener;


list order_buttons(list buttons)
{
return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4)
+ llList2List(buttons, -9, -7) + llList2List(buttons, -12, -10);
}

send_ammo(string ammo) //sends the ammo choice to the gunscript and sculpty ammo
{
llMessageLinked(LINK_THIS,435,(string)ammo,"";);
llMessageLinked(LINK_SET,0,(string)ammo,"";);
}

send_viz(string viz) // Hide or shows the ammo
{
llMessageLinked(LINK_SET,0,(string)viz,"";);
}

send_menu(string menu) //Calls the main menu
{
llMessageLinked(LINK_THIS,772,(string)menu,"";);
llSetTimerEvent(0.0);
llListenRemove(listener); //stop listening
}

time_out() //kills listeners if person does not press button
{
llSetTimerEvent(0.0);
llListenRemove(listener); //stop listening
llOwnerSay("time ran out";);
}

close() // kills the listener and makes the window go away
{
llSetTimerEvent(0.0);
llListenRemove(listener); //stop listening
}

dialog() //calls the dialog menu
{
channel=(integer)(llFrand(-1000000000.0));
llDialog(llGetOwner(),"Pick your toasted treat", FOOD,channel);
listener=llListen(channel, "", llGetOwner(), "";);
llSetTimerEvent(60); //gives 60 seconds to click
}

default //menu to select ammo choices
{
link_message(integer sender_num, integer num, string str, key id)
{
if (str =="ammo";)
{
dialog();
}
}
listen(integer chan, string name, key id, string msg)
{
if(msg=="Waffles";)
{
send_ammo("Waffles";);
send_menu ("main";);
}
else if(msg=="Toast";)
{
send_ammo("Toast";);
send_menu ("main";);
}
else if(msg=="Bagels";)
{
send_ammo("Bagels";);
send_menu ("main";);
}
else if(msg=="Hide";)
{
send_viz("Hide";);
send_menu ("main";);
}
else if(msg=="Show";)
{
send_viz("Show";);
send_menu ("main";);
}
else if(msg=="<==BACK";)
{
send_menu("main";);
}
else if(msg=="CLOSE";)
{
close();
}
}
timer()
{
time_out();
}
}

/php
_____________________
"Be who you are and say what you feel, because those who matter don't mind, and those that mind, don't matter."
—Dr. Seuss
Gearsawe Stonecutter
Over there
Join date: 14 Sep 2005
Posts: 614
10-26-2008 20:33
you need to set
integer channel = 389520;// some number of your choice. or else channel will be 0

the way llDialog works it makes the Avatar say the button clicked on the channel defined. so when you click "TOAST" your avatar says TOAST. putting it on some other channel other than zero will make it not visible to the world
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
10-26-2008 23:18
You are using a random channel for your listener. That is good.
Only problem is this:
llFrand(-alot) generates a number between -alot and 0. This number gets typecast to an in teger. So let's say the generated number is -0.6. That makes the integer 0.

The sollution is to just substract 1.
channel=(integer)(llFrand(-1000000000.0)-1);
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-27-2008 02:28
or if you are using positive channels (some do, I prefer negatives to reduce tampering) then use +1
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Lyndzay Meili
Registered User
Join date: 2 Sep 2007
Posts: 28
10-28-2008 20:59
Thanks for the help I made the changes (adding the -1) and found what was causing the problem. I had left the channel function off of one script so it wasn't listening and that's why it was saying things in open chat when I pressed the dialog buttons.

Now it works great :)

Thanks again
Lyndz~
_____________________
"Be who you are and say what you feel, because those who matter don't mind, and those that mind, don't matter."
—Dr. Seuss