Jump to content

Multiple URL dialog hud


SeeAirAhh Josephina
 Share

You are about to reply to a thread that has been inactive for 1300 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I was trying to make a hud that would give the owner a choice of URL's to load using a dialog menu, unfortunately it's not working;

string button1 = "Google";
string button2 = "MSN";
string button3 = "Yahoo";

list MENU = [button1,button2,button3];

string menu_message = "Multi URL Hud";

integer DIALOG_CHAN;
integer listen_handle; 

default
{
    touch_start(integer total_number)
    {
        if (listen_handle != 0)
        {
            llListenRemove(listen_handle);
            listen_handle = 0;
        }
        listen_handle = llListen(DIALOG_CHAN,"","","");
        
        llDialog(llDetectedKey(0),menu_message,MENU,DIALOG_CHAN);
    }
    
    listen(integer channel, string name, key id, string message)
    {
        if( channel == DIALOG_CHAN)
        {
            if(message == button1)
            {  
    key     id              = llDetectedKey(0);
    integer avatarInSameSim = (llGetAgentSize(id) != ZERO_VECTOR);
        if (avatarInSameSim)
        {
            string info = "Google";
            string url = "http://www.google.com/";
            llLoadURL(id, info, url);
        }
        else
        {
            llInstantMessage(id, "I can only open a URL dialog on your screen if you're in my sim!");
        }
            }
            if(message == button2)
            {  
                llSay(0,llKey2Name(id)+" now you clicked button 2"); 
            }
            if(message == button3)
            {  
                llSay(0,llKey2Name(id)+" now you clicked button 3"); 
            }            
            llListenRemove(listen_handle);
            listen_handle = 0;    
        }
    }
}

Should the detect avatar key be at the top?

Link to comment
Share on other sites

You don't need the line that says

key id = llDetectedKey(0);

For one thing, the llDetected * functions won't work unless they are in an event that detects something (like a touch_start event or a sensor event).  For another (better) thing, the variable id is already defined in the listen event, so you don't need to do it again.

You also don't need to create a new variable string info = "Google"; because you have already defined that as button1 anyway.  All you need to do is check whether message == button1. Then you can llLoadURL (id, info, button1);  And of course you still need to do the same thing for button2 and button3.

I suggest being very careful about indenting properly.  That will make it a lot easier to check for matching  { } brackets.  I didn't check them myself, but you should.

Edited by Rolig Loon
Additional information
  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1300 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...