Difference between revisions of "LlSetClickAction"

From Second Life Wiki
Jump to navigation Jump to search
(removed note about script not handling touch events and add pay/money caveat)
m
Line 76: Line 76:
{{!}}{{#var:value}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}{{#var:comment}}
{{!}}[[Image:Toolsit.png‎]]
{{!}}[[File:SitActionCursor.png‎]]
{{!}}-
{{!}}-
{{!}}{{LSL Const|CLICK_ACTION_BUY|integer|2|c=When the prim is touched, the buy dialog is opened}}
{{!}}{{LSL Const|CLICK_ACTION_BUY|integer|2|c=When the prim is touched, the buy dialog is opened}}
{{!}}{{#var:value}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}{{#var:comment}}
{{!}}[[Image:Toolbuy.png]]
{{!}}[[File:SaleOneclickCursor.png]]
{{!}}-
{{!}}-
{{!}}{{LSL Const|CLICK_ACTION_PAY|integer|3|c=When the prim is touched, the pay dialog is opened}}
{{!}}{{LSL Const|CLICK_ACTION_PAY|integer|3|c=When the prim is touched, the pay dialog is opened}}
{{!}}{{#var:value}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}{{#var:comment}}
{{!}}[[Image:Toolpay.png]]
{{!}}[[File:SaleOneclickCursor.png]]
{{!}}-
{{!}}-
{{!}}{{LSL Const|CLICK_ACTION_OPEN|integer|4|c=When the prim is touched, the object inventory dialog is opened}}
{{!}}{{LSL Const|CLICK_ACTION_OPEN|integer|4|c=When the prim is touched, the object inventory dialog is opened}}
{{!}}{{#var:value}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}{{#var:comment}}
{{!}}[[Image:Toolopen.png]]
{{!}}[[File:OpenOneclickCursor.png]]
{{!}}-
{{!}}-
{{!}}{{LSL Const|CLICK_ACTION_PLAY|integer|5|c=Play or pause parcel media on touch}}
{{!}}{{LSL Const|CLICK_ACTION_PLAY|integer|5|c=Play or pause parcel media on touch}}

Revision as of 15:21, 10 August 2011

Summary

Function: llSetClickAction( integer action );
0.0 Forced Delay
10.0 Energy

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

• integer action CLICK_ACTION_* flag

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

Constants

Flag Description Cursor
CLICK_ACTION_NONE 0 Performs the default action: when the prim is touched, touch events are triggered
CLICK_ACTION_TOUCH 0 When the prim is touched, touch events are triggered
CLICK_ACTION_SIT 1 When the prim is touched, the avatar sits upon it SitActionCursor.png
CLICK_ACTION_BUY 2 When the prim is touched, the buy dialog is opened SaleOneclickCursor.png
CLICK_ACTION_PAY 3 When the prim is touched, the pay dialog is opened SaleOneclickCursor.png
CLICK_ACTION_OPEN 4 When the prim is touched, the object inventory dialog is opened OpenOneclickCursor.png
CLICK_ACTION_PLAY 5 Play or pause parcel media on touch Toolplay.png
CLICK_ACTION_OPEN_MEDIA 6 Play parcel media on touch, no pause Toolmediaopen.png
CLICK_ACTION_ZOOM 7 Zoom (Viewer 2) Toolzoom.png

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.

Examples

This is a great way to create a user interface that evolves with the process the script is taking the user through.<lsl>key sitter;

list up_up_and_away;

CoughsAndLolz() {

   integer count = 0;
   vector XYZ = llGetPos();
   float X = XYZ.x;
   float Y = XYZ.y;
   do
       up_up_and_away = up_up_and_away + [PRIM_POSITION, <X,Y,4000.0>];
   while((++count) < 400);

}

default {

   state_entry()
   {
       llSetClickAction(CLICK_ACTION_SIT); // Set in state entry to be sit on click.
       llSitTarget(<0.0,0.0,0.01>, ZERO_ROTATION);
   }
   changed(integer change)
   {
       if(change & CHANGED_LINK)
       {
           sitter = llAvatarOnSitTarget();
           if(sitter)
           { // Someone is upon us.
               CoughsAndLolz();
               llSetClickAction(CLICK_ACTION_TOUCH);// And so we change the click action to allow the touch_start.
               llSay(0, "Click me for a thrill");
           }
       }
   }
   touch_start(integer detected)
   {
       if(sitter)
       {
           llSetLinkPrimitiveParams(LINK_SET, up_up_and_away);
           llUnSit(sitter);
           llDie();
       }        
   }           
}</lsl>

See Also

Events

•  touch_start
•  touch
•  touch_end

Functions

•  llPassTouches

Articles

•  Detected

Deep Notes

History

Signature

function void llSetClickAction( integer action );