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

LSL Wiki : touch_start

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl411.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;
    }
}
This is a very dirty way of doing it! I highly advise using Time calculations instead by noting the current timestamp at the start of the touch and comparing it with the timestamp at the end. - EthariHallstrom

Events
Comments [Hide comments/form]
I suppose I just rewrote the answer to my own question, huh?:)

I don't get what you would say the semantics of negative indices would be, BW. Please explain.
-- IoneLameth (2006-01-11 13:27:58)
Could anybody write something on the touch* pages on why you can't touch objects attached to somebody else?
-- PierreJosephProudhon (2006-05-29 02:12:02)
Go ahead--and be sure to mention how to code so only the touchable object's owner can touch it--or how the owner can script the touchable object to only allow anyone (or specific people) to touch it at will, at certain times, in certain sims, etc. Oh and don't forget to mention not to wear inappropriate invisible touchable objects (i.e. naughty bits) in PG sims. Wee...
-- EepQuirk (2006-05-30 05:11:30)
Hmm ... I suppose it's not possible to find out WHERE the touch event has teken place? is it?
Like on wich side the touch happened, or even on what x-y coördinate of that side ?
-- TanithNewt (2006-11-29 14:44:31)
Hello to all persons of quality and others. What is a good technique for preventing a double-click from adversely affecting a script that is triggered by a left-click?
-- 72-12-23-254.wan.networktel.net (2007-05-30 21:50:27)
Attach a comment to this page: