-
Notifications
You must be signed in to change notification settings - Fork 4
XOBJ Control
JasXSL edited this page Nov 29, 2017
·
1 revision
The XOBJ control listener is the standard way to accept control events for the entire linkset, using control. Most often added to a project #ROOT script.
Example setup:
Global scope:
float pressStart; float lastclick;
default:
control(key id, integer level, integer edge){ if(level&edge){ // Pressed pressStart = llGetTime(); raiseEvent(evt$BUTTON_PRESS, (string)(level&edge)); if(llGetTime()-lastclick < .5){ raiseEvent(evt$BUTTON_DOUBLE_PRESS, (string)(level&edge&lcb)); lcb = 0; }else{ lastclick = llGetTime(); lcb = (level&edge); } integer i; for(i=0; i<32; i++){ integer pow = llCeil(llPow(2,i)); if(level&edge&pow)multiTimer(["H_"+(string)pow, 0, 1, TRUE]); } } if(~level&edge){ raiseEvent(evt$BUTTON_RELEASE, llList2Json(JSON_ARRAY, [(~level&edge),(llGetTime()-pressStart)])); integer i; for(i=0; i<32; i++){ integer pow = llCeil(llPow(2,i)); if(~level&edge&pow)multiTimer(["H_"+(string)pow]); } } }
This example will raise the following events:
Event | Arguments | Description |
---|---|---|
evt$BUTTON_PRESS | int buttons | Raised when you press a key. |
evt$BUTTON_DOUBLE_PRESS | int buttons | Raised when you double-tap a key. |
evt$BUTTON_RELEASE | int buttons, float duration | Raised when you release a key. |
Don't forget to add llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
and take controls in the run_time_permissions_event llTakeControls(CONTROL_UP|CONTROL_DOWN|CONTROL_ML_LBUTTON, TRUE, FALSE);