Don't click here unless you want to be banned.

LSL Wiki : touch_start

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawling22.us.archive.org
touch_start(integer num_detected)

This event is raised when an agent first touches the object the script is attached to. The number of touching agents is passed to the script in the num_detected parameter. Information on those objects may be gathered via the llDetected* functions.

Event: Triggered: Triggered multiple times:
touch() while a user is clicking on the object. YES
touch_start() when a user starts clicking on the object. NO
touch_end() when a user stops clicking on the object. NO

Notes:

See also the llSetTouchText and llPassTouches functions.

Q: I see a lot of llDetected*(0), which seems like hacky laziness since even though this is a singular event and so unlikely to coincide, it seems possible for two touch starts to be described in a single event. Does it work that way?
A: Yes, multiple touches can be combined into a single event, but since this is rare you can get away with just checking index 0. When you suspect things get clicked a lot and close together, such as perhaps in competitive games, you should use a for or while loop to step though all the avatar references.
Q: Why you can't touch objects attached to somebody else?
A: As of 1.12 you can
Q: how to code so only the touchable object's owner can touch it?
A: Use a For loop and compare llDetectedKey to llGetOwner
Q: How the owner can script the touchable object to only allow specific people to touch it?
A: Use a For loop and use llDetectedName to compare to a list of names using llListFindList
Q: How to prevent inappropriate invisible touchable objects in PG sims?
A: Use llRequestSimulatorData.

You can also time how long the touch went for with this quick hack:
//By Charlie Rezillo
float time = 0.1;
default
{
    touch_start(integer num_detected)
    {
        llSetTimerEvent(0.1);
    }
    timer()
    {
        time = time + 0.1;
    }
    touch_end(integer num_detected)
    {
        llSetTimerEvent(0.0);
        llInstantMessage(llDetectedKey(0),llDetectedName(0) + " you held down your mouse button for " + (string)time + " seconds.");
        time  = 0.0;
    }
}


Events
There are 147 comments on this page. [Display comments/form]