Jump to content

Noose script Help with anchor please???


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

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

Recommended Posts

I have this old script and the original creator is no longer around. I just cant figure out how to create an anchor point for this noose to tather on or hook on too for my old-school penal colony sim. Can some help create an anchor script for me??? I would  much appreciated I have zero knowladge on scripting, just got into it a few days ago, picked up a few things here and there so im hoping to learn more from this as well. Im also hoping I picked the right scrip, forgive this Noob if I didnt, the darn thing came with a few scripts Im still trying to figure out so I picked the one that said "string" and "Anchor" hoping it was the right one   =XP 

 

string anchor="smf.gallows anchor";
integer listenhandle;
integer pos_chan;
float rope_length = 15; 
float rope_length_remember = 15; 
float add_length = 0.3;
float dampening = 0.2; 
float bouncing = 0.001; 
float constant = 10.0; 
vector vel;
float velz;
key target;
vector ropecolor = <1,0,0>;
list rope_effect = [];
vector i_pos;
vector u_pos;

integer Key2Chan(key ID) 
{
    return 0x80000000 | (integer)("0x"+(string)ID);
}

default
{
    state_entry()
    {
        llListenRemove(listenhandle); 
        llSleep(2.0); // wait for SCR.reset 
        rope_length = 15; // crazy long, so you don't get pulled up immediately
        rope_length_remember = 15;
        llSetStatus(STATUS_PHYSICS, TRUE); // make gravity active  
        llSensorRepeat(anchor, NULL_KEY , PASSIVE|ACTIVE, 10.0, PI,4); //scan a full sphere with a diameter of 10m every 4 seconds
    }

     no_sensor() 
     {
          llResetScript();
     }
    
    sensor( integer num_detected )
    {
        pos_chan= Key2Chan(llDetectedKey(0)); // determines an unique communication channel
        llListenRemove(listenhandle); 
        listenhandle = llListen(pos_chan, anchor, llDetectedKey(0), ""); //the name of the thing you listen to is 'anchor'
    }

    link_message(integer source, integer num, string msg, key id)
    {
        if (num == 1) rope_length = rope_length_remember; 
        if (msg == "start") // this is the first message SCR.dialog sends
        {   
            rope_length = 4.2; 
            rope_length_remember = rope_length;
        }
            
        if (msg == "start pos") 
        {
            rope_length = 4.2; 
            rope_length_remember = rope_length;
            vector target_pos = u_pos + <0,0,-2.2>; 
            llMoveToTarget(target_pos,0.05); 
            llSleep(4.0);
            llMoveToTarget(target_pos,0.0);
        }
        
        else if (msg == "short drop") 
        {
            rope_length =1.8+ llFrand(0.3);
            rope_length_remember = rope_length; 
        } 
        
        else if (msg == "medium drop") 
        {
            rope_length = 2.1 + llFrand(0.3); 
            rope_length_remember = rope_length; 
        }
        
         else if (msg == "long drop") 
        {
            rope_length =3.7;;
            rope_length_remember = rope_length; 
        } 
        
        else if (msg == "pull up") 
        {
            rope_length = 0.7+ llFrand(0.3);
            rope_length_remember = rope_length; 
        }
    }
    
    listen(integer chan, string name, key id, string msg)
    {
   
    if (chan == pos_chan) //only listen to the right anchor
        {
        i_pos = llGetPos(); //determine your own position
        u_pos = (vector)msg; //determine the position of the anchor
        if (llVecMag(u_pos-i_pos)>rope_length) //determine of the distance between you and the anchor exceeds the rope length
            {
            llSetForce(constant*llGetMass()*llVecNorm(u_pos-i_pos)*(llVecMag(u_pos-i_pos)- rope_length),FALSE);
            llApplyImpulse( llGetMass() * llGetVel() * dampening * -1.0 , FALSE ); 
            vector wrongway = llVecNorm(i_pos - u_pos); 
            float wrongmag = ( llGetVel() - llDetectedVel(0) ) * wrongway; 
            if ( wrongmag > 0.0 ) 
                { 
                llApplyImpulse( llGetMass() * ( ( -1.0 - bouncing ) * ( wrongway * wrongmag ) ) , FALSE );
                } 
            }
        else 
            {  
            llApplyImpulse(-llGetMass()*llGetVel()*0.05,TRUE); 
            llSetForce( ZERO_VECTOR, TRUE );
            llSetAngularVelocity(<0,0,0>,TRUE); 
            } 
        }
    }                
}
 

Link to comment
Share on other sites

If I'm reading it right, it just expects an object named smf.gallows anchor to say something on Key2Chan(llGetKey()) on a timer. particles and some other things seem to be handled by another script in your set that you didn't post, but my best guess from this info alone is just:

// anchor script?
integer Key2Chan(key ID) 
{
    return 0x80000000 | (integer)("0x"+(string)ID);
}
float spam_rate = 0.2;

integer isOn = TRUE;
integer chan;
default
{  state_entry()
   {
      chan = Key2Chan(llGetKey());
      llSetTimerEvent(spam_rate);
   }
   touch_start(integer n)
   {  llSetTimerEvent( (isOn=!isOn)*spam_rate );
      if(isOn) llSay(0,"On");
      else llSay(0,"Off");
   }
   timer()
   {   llSay(chan,"something, doesn't seem to matter what?");
   }
}

Honestly, since your noose already has a sensor_repeat in it, it would be better to rescript it to handle the timing on its own, rather than relying on messages from the anchor to clock its pull. you could have it read the description of the anchor to tell if it's supposed to be on or not.

Edited by Quistess Alpha
Link to comment
Share on other sites

Oh the thing is I dont have the anchor script and, I wish I fully undertood what you said, in concept I did, but in execution I have no idea where tos start or how to do that but if I could evrything you said did sounded awesome =XD

Link to comment
Share on other sites

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