Difference between revisions of "LlSetClickAction"

From Second Life Wiki
Jump to navigation Jump to search
(hehehehe)
m (some state issues, this script would benifit from being split into two states.)
Line 17: Line 17:
     float Y = XYZ.y;
     float Y = XYZ.y;
     do
     do
    up_up_and_away = up_up_and_away + [PRIM_POSITION, <X,Y,4000.0>];
        up_up_and_away = up_up_and_away + [PRIM_POSITION, <X,Y,4000.0>];
     while((++count) < 400);
     while((++count) < 400);
}
}
Line 32: Line 32:
         if(change & CHANGED_LINK)
         if(change & CHANGED_LINK)
         {
         {
             sitter = llAvatarOnSitTarget();// Someone is upon us.
             sitter = llAvatarOnSitTarget();
            CoughsAndLolz();
            if(sitter)
            llSetClickAction(CLICK_ACTION_TOUCH);// And so we change the click action to allow the touch_start.
            { // Someone is upon us.
            llSay(0, "Click me for a thrill");
                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)
     touch_start(integer detected)
     {
     {
         llSetLinkPrimitiveParams(LINK_SET, up_up_and_away);
         if(sitter)
        llUnSit(sitter);
        {
        llDie();         
            llSetLinkPrimitiveParams(LINK_SET, up_up_and_away);
            llUnSit(sitter);
            llDie();
        }        
     }           
     }           
}</lsl>
}</lsl>

Revision as of 16:37, 8 August 2009

Summary

Function: llSetClickAction( integer action );

Sets the action performed when a prim is clicked upon.

• 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 Toolsit.png
CLICK_ACTION_BUY 2 When the prim is touched, the buy dialog is opened Toolbuy.png
CLICK_ACTION_PAY 3 When the prim is touched, the pay dialog is opened Toolpay.png
CLICK_ACTION_OPEN 4 When the prim is touched, the object inventory dialog is opened Toolopen.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

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>

Notes

With the CLICK_ACTION_* flag set to anything but CLICK_ACTION_NONE or CLICK_ACTION_TOUCH (default), the script won't trigger the touch* events anymore when the prim is clicked.

See Also

Events

•  touch_start
•  touch
•  touch_end

Functions

•  llPassTouches

Articles

•  Detected

Deep Notes

History

Introduced in SL 1.19.1(0)

All Issues

~ Search JIRA for related Issues
   Shift-drag to copy object does not copy all settings

Signature

function void llSetClickAction( integer action );