Jump to content

Assistance request for 'pose and listen' script


Argus Foxclaw
 Share

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

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

Recommended Posts

I am not a scripter but worked on pockling this together some time ago. Have been out of SL for some time and would like to 'revive' it.

The script simply aims to allow someone to click on a prim and 'sit' on it using a defined animation name.  After the 'sit' has occurred the script listens and then collects two inputs from the avatar, a height and a building name, which it will use in the next part of the script which is not yet begun.

The problem seems to be with the line:
void handleBuildingSelection(string buildingName)

But I cannot fathom why (however I am not working with many fathoms in in this area).

If there are any other details that would be useful, please ask I am pretty much a stranger to coding generally. I have very limited time here the early part of this week, but I will endeavour to 'nip' in every hour or so and have a quick look and see if any kind soul can give me a 'push'. I would really like to finish this after my SL break. :)

Any help gratefully received.

 

I can't see quickly how to import a text file here, so I am thinking I should probably paste the script below:

string animation = "animation name"; // name of built-in animation or animation in prim inventory
integer sitHeight; // variable to store the sit height
list buildingNames; // list to store the building names

default
{
    state_entry()
    {
        llSitTarget(<0.0, 0.0, 0.01>, ZERO_ROTATION);
        llSetSitText(llToUpper(animation));
        llSetClickAction(CLICK_ACTION_SIT);
        
        // Load building names from notecard
        buildingNames = llGetNotecardLine("building_names");
    }

    changed(integer change)
    {
        if (change & CHANGED_LINK)
        {
            key sitter = llAvatarOnSitTarget();
            if (sitter != NULL_KEY) llRequestPermissions(sitter, PERMISSION_TRIGGER_ANIMATION);
            else
            {
                if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) llStopAnimation(animation);
                llSetAlpha(1.0, ALL_SIDES); // show prim
            }
        }
    }

    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            llSetAlpha(0.0, ALL_SIDES); // hide prim
            llStartAnimation(animation);
            llStopAnimation("sit");

            // Listen on channel 123 for sit height and building selection
            llListen(123, "", llGetOwner(), "");
        }
    }

    listen(integer channel, string name, key id, string message)
    {
        // Check if the message starts with "H:"
        if (llSubStringIndex(message, "H:") == 0)
        {
            // Parse the sit height value from the message
            string sitHeightString = llGetSubString(message, 2, -1);
            sitHeight = (integer)llList2String(llParseStringKeepNulls(sitHeightString, [" "], []), 0);
            
            // Display the sit height in local chat
            llOwnerSay("Sit Height: " + (string)sitHeight);
        }
        // Check if the message starts with "B:"
        else if (llSubStringIndex(message, "B:") == 0)
        {
            // Parse the building name value from the message
            string buildingName = llGetSubString(message, 2, -1);

            // Perform actions based on the selected building name
            handleBuildingSelection(buildingName);
        }
    }
}

void handleBuildingSelection(string buildingName)
{
    // Find the corresponding building name in the list
    integer index = llListFindList(buildingNames, [buildingName]);

    // Check if the building name is found in the list
    if (index != -1)
    {
        // Perform actions based on the selected building
        string selectedBuilding = llList2String(buildingNames, index);
        llOwnerSay("Selected Building: " + selectedBuilding);
    }
}

Link to comment
Share on other sites

in LSL 'void' isn't a valid type. to declare a user defined function with no type, just omit the type. Also in LSL, all user-defined functions must be declared before the 'default' state, so, copy that whole block up to the beginning of the script after variable declarations.

  • Like 1
Link to comment
Share on other sites

13 hours ago, Argus Foxclaw said:

buildingNames = llGetNotecardLine("building_names");

is also probably throwing an error because buildingNames is of type list, and llGetNotecardLine returns type key. You need a dataserver event to read from a notecard.

  • Thanks 1
Link to comment
Share on other sites

9 hours ago, elleevelyn said:

this line here also

llListen(123, "", llGetOwner(), "");

script should be listening for avatar that sat on the object (avatar that gave animation permission when they sat) rather than the owner of the object

llListen(123, "", llGetPermissionsKey(), "");

https://wiki.secondlife.com/wiki/LlGetPermissionsKey

 

Many thanks elleevelyn... my but I have a lot to learn! I will try and get something more functional together and post a better version for you, Quistess and/or anyone else kind enough to look it over... though I think to get to that point I am going to need to up my understanding a tad (or two or so). Still, if it was easy I guess it wouldn't be fun :)

Link to comment
Share on other sites

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