Jump to content

SLS_Help_Post_5


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

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

Recommended Posts

The simplest approach to this is to list all inventory items with an index number at the start of each line, or list all the notecard lines with an index number at the start of each line, and either have a dialogue with numbered buttons, or more sensibly, use llTextbox to allow the user to input the number of the item they are interested in.

The biggest drawback with this method though is that for any reasonably-sized inventory or well-stuffed notecard they're going to be hit with a wall of text in their local chat window.

Link to comment
Share on other sites

wrong script :

default
{
    state_entry()
    {
        llSay(0, "Hello, Avatar!");
    }

    touch_start(integer total_number)
    {
        list b = [];
        integer n = llGetInventoryNumber(INVENTORY_ALL);
        integer x;
         do
            {
            b += llGetInventoryName(INVENTORY_ALL,x);
            }
          while (++x <++n);
          llDialog(llDetectedKey(0), "Please choose one of the below options:",b,0);
    }
}
 

Link to comment
Share on other sites

Ok, so several things are preventing that script from doing anything:

dialogs are limited in the number of buttons, so creating a list then requires you to split that list up into pages. Can be hard work.

Have a look at The first example in llTextbox here , because it shows most of what I've suggested you try.

My earlier suggestion about llTextbox would work a bit better. Instead of populating the list, each inventory name is chatted  out or IMed to the toucher preceded by the string value of integer x. llWhisper(0, (string) x + " " + llGetInventoryName(..., x) ); They will see several lines of text with a number followed by a name.

Then instead of llDialog, use llTextbox to ask the user to enter a number.

After llTextbox( or indeed llDialog) you must have an llListen(...) call.

After the touch event you must then have a listen event to catch their response.

 

You have used channel 0 in your dialog call which means whatever the dialog outputs will get mixed up in local chat, it is far better to use a negative number for the channel in dialogs, say -142536, and then the listen you set up must also listen on this channel. 

 

Use an integer to store the listen handle returned by the call to llListen, because at the end of the listen event you will probably want to close that listen.

 

 

Edited by Profaitchikenz Haiku
  • Like 1
Link to comment
Share on other sites

And how to include permission in this wrong script:

 

key  teleportee;
default
{
    touch_start(integer num_detected)
    {
        string thisScript = llGetScriptName();
        list inventoryItems;
        integer inventoryNumber = llGetInventoryNumber(INVENTORY_ALL);
 
        integer index;
        for ( ; index < inventoryNumber; ++index )
        {
            string itemName = llGetInventoryName(INVENTORY_ALL, index);
 
            if (itemName != thisScript)
            {
                if (llGetInventoryPermMask(itemName, MASK_OWNER) & PERM_COPY)
                {
                    inventoryItems += itemName;
                }
                else
                {
                    llSay(0, "Unable to copy the item named '" + itemName + "'.");
                }
            }
        }
 
        if (inventoryItems == [] )
        {
            llSay(0, "No copiable items found, sorry.");
        }
        else
        {
            llDialog(llDetectedKey(0), "\nPlease make a choice.",inventoryItems, 0);
        integer listenHandle = llListen(0, "", llDetectedKey(0), "");    // 3.0 seconds delay
        }
    }
     listen(integer channel, string name, key id, string message)
    {
        llTeleportAgent(teleportee, "message", <0.0, 0.0, 0.0>, <0.0, 0.0, 0.0>);
        }
}

Link to comment
Share on other sites

 

In order to make this work reliably you should restrict the inventory search to type INVENTORY_LANDMARK so that there's no chance of trying to teleport somebody to a texture or an animation.

You would need to request teleport permission for the teleportee, but there's no place in the script where teleportee is ever assigned a value to there's no chance of actually getting that permission.

The actual permission is granted by llRequestPermissions(avatar_key, PERMISSION_TELEPORT) and so would then need to have a run_time_permissions event, in which the given permissions are tested, and that event is the correct place to then call llTeleportAgent.

In the listen, when the toucher has chosen a landmark, you would need to request permissions for them. The destination landmark is therefore going to have to be a global variable to which the value of message in the listen event must be assigned. In your script you are instead trying to teleport somebody to a place called "message", a string literal.

Do you really intend to teleport somebody to a null vector? (zero vector in a region is the corner of a sim and is a most uncomfortable place to find oneself). 128,128,26 is safe in that it is dead-centre of the sim and a reasonable assumption of a ground level.

So, putting things all together,

you also want a global variable destination, to which the value of message is assigned

teleportee is assigned the value of id in the listen event.

a call is then made to llRequestPermissions(teleportee, PERMISSION_TELEPORT)

and in a new event run_time_permissions, you first check if PERMISSION_TELEPORT is set,

run_time_permissions(integer perms)

{

    if(perms & PERMISSION_TELEPORT)

and if so, call llTeleportAgent with teleportee, destination ,<128,128,26>, ZERO_VECTOR as the parameters.

 

Edited by Profaitchikenz Haiku
  • Like 1
Link to comment
Share on other sites

I was starting to get the idea, the object purports to be a giver of things, the clicker believes that they are getting a "short sharp thrill" thingy, but the sensation-seeker instead gets TP-ed into said short sharp thrill. It's going to fail on the popup box "da-da-da, an object owned by ... wishes to teleport your avatar into the bowels of hell", to which quite a few are going to say Oh no, not me you don't".

But as a starter script it's quite a good one for finding out how to do things.

Link to comment
Share on other sites

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