Jump to content

How do i make this follow script able to be turned on and off?


LouiseDeBlois
 Share

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

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

Recommended Posts

Hi there, simple question, I am using this script:

http://wiki.secondlife.com/wiki/Follower_script

 

The second low lag script, and i am wondering if it is possible to add a toggle feature? When clicked, the object follows the person whom clicked it, then, when its clicked by the same person later on (or the person logs / tp's) it returns to its original rez/placement for others to use.

 

Thank you!

Link to comment
Share on other sites

You will have to add two global variables,  a vector startPos and an integer following, and in the state_entry, set startPos by a call to llGetPos(), and set following to 0. then set the TimerEvent to 0.0, and set the styatus_physics to False.

 

You then need to add a touch_event. Inside the touch event, check the variable following, and if it is 0, set the physics status to TRUE, set following to 1, and set the timer event to 1.0.

 

If following on the other hand is 1, you need to set the timer event to 0.0, call llStopMoveToTarget, set status Physics to false, and finally set following to 0.

Link to comment
Share on other sites

ETA it is far easier for you to modify the first script on that page you linked to for what you want to do. It is already using llSensorRepeat, so you move that line out of the state_entry into the new touch_start event you will be creating.

 

Create the global variables as already mentioned, set status physics to false in state_entry, set startPos by calling llGetPos, and set following to 0.

create a touch_start event as already suggested above, and move the llSensorRepeat line down from state entry into the touch event where you have tested the value of following and found it to be 0.

Instead of llGetOwner() in the sensorRepeat, use llDetectedKey(0), so that the key of the person who touches the object becomes the target.

In the touch event, when following is 1, call llSensorRemove() to stop the sensor, set status physics to false, call llStopMoveToTarget(), set following to 0, anmd finally call llRegionSetPos(startPos) to move the object back to the beginning ready to start all over again.

 

Important: Add a no_sensor even()t, and within it, issue an llSensorRemove() call, followed by llStopMoveToTarget(),set Status_Physics to false, following to 0,  then llSetRegionPos(startPos) to go back to the beginning and wait for the next toucher.

 

As you come to each of the stages above, look through the LSL wiki for no_sensor, etc, to see the layour and syntax of what you are supposed to be doing. You will find snippets of code you can copy and paste into the script you are modifying, which will give you less syntax errors that just typing them in straight from the keyboard.

 

I'm TP-ing out for sleep, post what you've managed and hopefully a night-owl will come to your aid :)

  • Like 1
Link to comment
Share on other sites

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