Jump to content

I want a script to activate on sit... but I can't find a way to do so.


AkiraShadowblade
 Share

Recommended Posts

To put it simply... I want to use an object that can be remotely activated by a  script, howerver due to my inexperience I am unable to fathom how to properly set it up. An example  was provided  to have said object start on touch... but that isn't what I'm wanting, and pretty much I was hoping if anyone would be generous enoguh to take a moment to help.

Below you'll find the demo script for creating a " on touch" version, and if anyone could modify/ make a new script to allow the script to turn on/ off when sitting/ standing, I'd appreciate it.

( as a note, this is to be used for extending/ retracting tentacles for a place, where the tendrils extend towards the  Avatar that sits down, then cease when they stand up.)

 

// Demo of commanding Tentaculus Infestus from a scripted object, by Xoph Adamczyk.

// In this example, reachpos, endreach, and etrig commands are demonstrated.

// Almost any menu button label or chat command for Infestus can be sent
// from a scripted object by using llSay and the appropriate dialog channel.

// NOTE commands can also be sent from a script in Infestus -- there is a separate demo for that. 

integer dialog_channel = 6;

integer mode;

default
{
    state_entry()
    {
     
    }

    touch_start(integer total_number)
    {  
      if (mode == 0)
      {
          llOwnerSay("Commanding Infestus to point at the position of this object. Touch again to stop.");
          
          llSay(dialog_channel, "reachpos " + (string)llGetPos());
      }
      else if (mode == 1)
      {
          llOwnerSay("Sending endreach command");
          llSay(dialog_channel, "endreach");
      }
      else if (mode == 2)
      {
          llOwnerSay("Triggering Infestus (response and its duration depend on response settings in Infestus).\nNOTES:\n - owner must be within set range and\n - Infestus must have trigger mode set to external.\n\n**** WAIT for Infestus to retract, then click again for point-to-object demo.");

          llSay(dialog_channel, "etrig " + llKey2Name(llGetOwner()));
      }

      mode = (mode+1)%3;
    }
    
    on_rez(integer ignoreme)
    {
        mode = 0;
        
      llOwnerSay("Place this near Tentaculus Infestus and touch a few times to see reach trigger example.\nFull-perm script inside demonstrates how this is done.\nNOTES:\n - dialog channel 6 is assumed, and is the default.\n - Infestus trigger should be set to External.");
    }
}

 

Link to comment
Share on other sites

Your script needs to set up a sit target position and rotation first within the state_entry event by using the llSitTarget function. Then it's possible to use the changed event and let it see if the link set got changed. It does when someone is sitting or standing up as an avatar will count as a prim when sitting on. If the link set changed, your script can then check if someone is sitting on the objects sit target by calling llAvatarOnSitTarget. It returns the key of the avatar when sitting on the object, otherwise it return NULL_KEY.

 

default{    state_entry()    {
// set position and rotation for an avatar to sit on an prim llSitTarget(<0,0.1,0>,ZERO_ROTATION); } changed(integer change) {
// check if link set got changed if(change & CHANGED_LINK) {
// check if an avatar sits on the prim if(llAvatarOnSitTarget() != NULL_KEY) { llOwnerSay("avatar sits on object"); }
// nothing is sitting on the object else { llOwnerSay("avatar stands up"); } } }}
Link to comment
Share on other sites


revochen Mayne wrote:

Your script needs to set up a sit target position and rotation first within the state_entry event by using the llSitTarget function. Then it's possible to use the changed event and let it see if the link set got changed. It does when someone is sitting or standing up as an avatar will count as a prim when sitting on. If the link set changed, your script can then check if someone is sitting on the objects sit target by calling llAvatarOnSitTarget. It returns the key of the avatar when sitting on the object, otherwise it return NULL_KEY.

 
default{    state_entry()    {

// set position and rotation for an avatar to sit on an prim llSitTarget(<0,0.1,0>,ZERO_ROTATION); } changed(integer change) {

// check if link set got changed if(change & CHANGED_LINK) {

// check if an avatar sits on the prim if(llAvatarOnSitTarget() != NULL_KEY) { llOwnerSay("avatar sits on object"); }

// nothing is sitting on the object else { llOwnerSay("avatar stands up"); } } }}

OK... further apologies for bothering you. I'm getting the imporession said script will register of there is someone sitting, correct? After that, what am I to do to get the script itself working ( or, am I to  ad dthat TO the script)

 

Sorry... I'm a complete noob at scripting , as I've said. 90% of what I do is purely experimentation. >.<

Link to comment
Share on other sites

Your question is a little bit awkward for an experienced scripter. I will try to explain this with a language as close to the everyday language as possible. If you don't understand it, then you should read a few beginners tutorials for LSL.

You said that you know how to make a script "do" something on "touch". Then Revochen has showed you how to make a script "do" something on "sit".

So, the script is already doing something. It says "avatar sits on object" to the owner of the object as soon as someone sits down. It says "avatar stands up" when someone stands up.

Now it is up to you. If the script should do something else, then you have to replace the function calls "llOwnerSay" with the function calls you have in mind.

Link to comment
Share on other sites

just take the stuff from the touch event, and put it in the changed event?

 

kinda like so?

 

default
{
    state_entry()
    {
        // set position and rotation for an avatar to sit on an prim
        llSitTarget(<0,0.1,0>,ZERO_ROTATION);
    }
    on_rez(integer ignoreme)
    {        
      llOwnerSay("Place this near Tentaculus Infestus - tentacles will reach towards sitter.\n
      Full-perm script inside demonstrates how this is done.\nNOTES:\n
      - dialog channel 6 is assumed, and is the default.\n - Infestus trigger should be set to External.");
    }
    touch_start(integer total_number)
    {   vector pos = llDetectedPos(0);
        llSay(dialog_channel, "reachpos " + (string)llGetPos());
        // or to have tentacles point towards toucher use ... llSay(dialog_channel, "reachpos " + (string)pos);
    }
    changed(integer change)
    {
        // check if link set got changed
        if(change & CHANGED_LINK)
        {
             key av = llAvatarOnSitTarget();
            if (av) // evaluated as true if key is valid and not NULL_KEY
            {  llSay(dialog_channel, "etrig " + llKey2Name(av) );     // will reach towards ANY avatar sitting, not just owner
            }
          
            else   // nothing is sitting on the object
            {  llSay(dialog_channel, "endreach");
            }
        }
    }
}

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...