Jump to content

hud only works on the ground


fuiq
 Share

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

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

Recommended Posts

Hello!
I am working on a hud at the moment, the only problem is that when I attach it I can't click on it anymore (even though when i put it on the ground and click the buttons there, it still works...)
So my question is now: What have I possibly done wrong in the scripting?

Link to comment
Share on other sites

If everything functions when the HUD is rezzed in world (not attached) then I'd suggest making sure you don't have another HUD overylaying it blocking you from clicking. You can check by pressing Ctrl + Alt + T to show transparents they'll highlight red.

Also if you've added in any functions to check if attached like llGetAttached make sure it's not checking for attachment point 0 because that's for not attached.

If neither of those help resolve your issue you should post the code below for assistance debugging.

Edited by Scaler Rexen
Link to comment
Share on other sites

so, here is what I did for the root:

integer gchannel;
default
{
     state_entry()
    {
     gchannel = 0x80000000 | (integer) ( "0x" + (string) llGetOwner() );
       
    }
    link_message(integer link, integer num, string msg, key id)
    {
        if(msg == "5")
        {
           key id = llDetectedKey(0);
            llRegionSayTo(id, gchannel, "earringblue"); 
        }
        else if(msg == "4")
        {
           key id = llDetectedKey (0);
           llRegionSayTo (id, gchannel, "earringpurple");
        }
         else if(msg == "3")
        {
           key id = llDetectedKey (0);
           llRegionSayTo (id, gchannel, "earringyellow");
        }
         else if(msg == "2")
        {
           key id = llDetectedKey (0);
           llRegionSayTo (id, gchannel, "earringpink");
        }
    }
}

and this is what i did for the child prims

default
{
    state_entry()
    {
        llSetObjectName((string)llGetLinkNumber());
    }
    touch_start(integer num)
    {
        llMessageLinked(LINK_ROOT,(integer)llGetObjectName(),"Clicked","");
    }
}

I actually folllowed a little tutorial but as I said the clicking only works when the hud is on the ground and not when i attach it..

Link to comment
Share on other sites

The script you have been following will perform different actions depending on which link you click in a link set.

Try

llMessageLinked(LINK_ROOT,0,(string)llDetectedLinkNumber(0),“”);

A linked message is composed like this..

link, num, message, key

You are sending the link number in place of num...but...trying to pick it up in your first script as the message.

Link to comment
Share on other sites

The scripts provided don't appear to be telling the full story... I'm not sure how this would even work with what's shown above alone. Are there other scripts in the object?

Currently as written, this is the sequence I am seeing:

  1. The button script in each child prim will set the host child prim's name to its link number.
  2. When clicked, the button script will send a link message to the root with the integer parameter populated to the child's link number, the message parameter populated to "Clicked" and the key parameter empty.
  3. Then the script in the root will receive the linked message and will then issue a llRegionSayTo based on the value of the message parameter.

However... the message parameter in the linked message sent by the first script is hardcoded to "Clicked" so it will never be anything else. So all the IF tests in the root script will always fail.

Additionally, I don't think it's valid to define a locally scoped variable to have the same name as a variable in the event handler - namely the id variable in the link_message event. Normally if you try to edit the value of an event handler variable, it will silently fail.

And llDetectedKey won't return meaningful results in that event. The detected functions only work in the collision, collision_start, collision_end, sensor, touch, touch_start, touch_end events. For anything else, they will silently fail and return unusable values.

Are you sure there aren't other scripts running here? There must be more going on....

Link to comment
Share on other sites

As another aside, the link_message event will tell you from what child prim the message originated from. So you can use that in your test instead of the message - perhaps that's what you meant to do originally?

Example:

link_message(integer link, integer num, string msg, key id)
	{
        if(link == 5)	//the message came from link number 5
        {
          //stuff
        }
        else if(link == 4)	//the message came form link number 4
        {
          //stuff
        }
   ...
}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1526 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...