Skip to content
lsl.devlsl.devLSL Dev

LlSetClickAction

Looking for the current API? Open the llSetClickAction reference →

Wiki description

Sets the action performed when a prim is clicked upon (aka click action).

Function notes

When the cursor hovers over the prim, its image changes to reflect the action.

Specification

Constants

Flag Description Cursor
CLICK_ACTION_NONE0Performs the default action: when the prim is touched, touch events are triggered
CLICK_ACTION_TOUCH0When the prim is touched, touch events are triggered
CLICK_ACTION_SIT1When the prim is touched, the avatar sits upon itFile:SitActionCursor.png‎
CLICK_ACTION_BUY2When the prim is touched, the buy dialog is openedFile:SaleOneclickCursor.png
CLICK_ACTION_PAY3When the prim is touched, the pay dialog is openedFile:SaleOneclickCursor.png
CLICK_ACTION_OPEN4When the prim is touched, the object inventory dialog is openedFile:OpenOneclickCursor.png
CLICK_ACTION_PLAY5Play or pause parcel media on touchImage:Toolplay.png
CLICK_ACTION_OPEN_MEDIA6Play parcel media on touch, no pauseImage:Toolmediaopen.png
CLICK_ACTION_ZOOM7Zoom the avatar camera on this object (Viewer 2)Image:Toolzoom.png
CLICK_ACTION_DISABLED8No click action. No touches detected or passed.
CLICK_ACTION_IGNORE9Clicks go through the object to whatever is behind it. No touches detected.

Caveats

  • When set in the root of an object the chosen CLICK_ACTION_* will be that for the children also even if they have their own llSetClickAction set (it will be over-ridden). However (in the case of touch for example) if the CLICK_ACTION_* is set in the root but not at all in the children (including not having touch event scripts in them (this creates a default CLICK_ACTION_TOUCH)) the effect of the roots CLICK_ACTION_* is not seen but the CLICK_ACTION_* is used on clicking. To both use and see the correct cursor the CLICK_ACTION_* flags must match in the children and root.
  • If llSetClickAction is CLICK_ACTION_PAY then you must have a money event, or it will revert to CLICK_ACTION_NONE.
  • While this function works or attached objects (click action can be changed), the configured click action of an attachment is ignored by the viewer (with exceptions). The viewer always* behaves as though an attached object has CLICK_ACTION_TOUCH set.
    • The only exception to the above rule is when the chosen click action is CLICK_ACTION_DISABLED, which will disable the cursor changing from the standard pointer arrow to the touch pointer.
  • llSetClickAction has to be called before an avatar clicks on an object. Calling it while an avatar is clicking (click & holding) will cause this function to silently fail. You can set the click action after an avatar touches an object, but bear in mind that there may be some delay before the given avatar's viewer will update due to ping times, etc.

Examples

make sitting easier make unpacking for next owner easier make buying for customers easier
default
{
    state_entry()
    {
        llSetClickAction(CLICK_ACTION_SIT);
        llRemoveInventory(llGetScriptName());
    }
}
default
{
    state_entry()
    {
        llSetClickAction(CLICK_ACTION_OPEN);
        llRemoveInventory(llGetScriptName());
    }
}
//  remember you'll have to set a price
//  in the general tab of the edit window
//  for your object before using this script

default
{
    state_entry()
    {
        llSetClickAction(CLICK_ACTION_BUY);
        llRemoveInventory(llGetScriptName());
    }
}
//  simple tipjar

default
{
    state_entry()
    {
        llSetClickAction(CLICK_ACTION_PAY);

    //  enabled edit field to put own amount, all quick-pay-buttons hidden
        llSetPayPrice(PAY_DEFAULT, [PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
    }

    money(key id, integer amount)
    {
        string name = llKey2Name(id);

        llInstantMessage(id, "Thank you for the tip, " + name + "!");
    }
}
//Sit Only with Permission

list gAvWhitelist = ["953d10f1-44ce-462a-8bc1-f634333ee031", "599dce91-a2b8-48c5-b96d-54965433022b"];

default
{
    state_entry()
    {
        llSitTarget(<0.0, 0.0, 0.5>, ZERO_ROTATION);
    }
    
    changed(integer change)
    {
        if (change & CHANGED_LINK)
        {
            list Properties = llGetObjectDetails(llGetKey(), [OBJECT_CLICK_ACTION]);
            integer Click = llList2Integer(Properties, 0);
            key Av = llAvatarOnSitTarget();
            if ((Av != NULL_KEY) && (!Click))
            {
                llSay(0, "Please click first for permission to sit.");
                llUnSit(Av);
            }
        }
    }
    touch_start(integer total_number)
    {
        list Properties = llGetObjectDetails(llGetKey(), [OBJECT_CLICK_ACTION]);
        integer Click = llList2Integer(Properties, 0);
        if (!Click && (~llListFindList(gAvWhitelist, [(string)llDetectedKey(0)])))
        {
            llSetClickAction(CLICK_ACTION_SIT);
            llSetTimerEvent(10.0);
            llSay(0, "Please take a seat.");
        }
        else
        {
            llSetClickAction(CLICK_ACTION_TOUCH);
            if (llAvatarOnSitTarget() != NULL_KEY)
            {
                llSay(0, "Good bye!");
            }
            else
            {
                llSay(0, "Sorry.  You are not allowed to sit here.");
            }
            llUnSit(llDetectedKey(0));
        }            
    }
    
    timer()
    {
        llSetTimerEvent(0.0);
        llSetClickAction(CLICK_ACTION_TOUCH);
    }
}

See also: functions

See also: events

See also: articles

History

Shared wiki helpers

The original page also injects shared parameter notes, caveats or issue information through these helpers. Their conditional MediaWiki logic is not reproduced here; inspect the preserved helper source for additional material.

Template:Issues/VWR-640

Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|VWR-640|Shift-drag to copy object does not copy all settings|type=bug|resolution=fixed}}

Template:Issues/VWR-10829

Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|VWR-10829|Linux Viewer: [[CLICK_ACTION_PAY]] shows [[CLICK_ACTION_PLAY]] icon|type=bug|resolution=fixed}}
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.