2 // huffware script: jaunter button pusher, by fred huffhines
4 // the button pusher script warped into service for jaunters.
6 // this script is licensed by the GPL v3 which is documented at: http://www.gnu.org/licenses/gpl.html
7 // do not use it in objects without fully realizing you are implicitly accepting that license.
10 string JAUNT_NEXT_BUTTON_NAME = "next";
11 string JAUNT_MENU_BUTTON_NAME = "menu";
13 // the button pushing API.
15 integer BUTTON_PUSHER_HUFFWARE_ID = 10029;
16 // a unique ID within the huffware system for this script.
17 string HUFFWARE_PARM_SEPARATOR = "{~~~}";
18 // this pattern is an uncommon thing to see in text, so we use it to separate
19 // our commands in link messages.
20 string HUFFWARE_ITEM_SEPARATOR = "{|||}";
21 // used to separate lists of items from each other when stored inside a parameter.
22 // this allows lists to be passed as single string parameters if needed.
23 integer REPLY_DISTANCE = 100008; // offset added to service's huffware id in reply IDs.
25 string BUTTON_PUSHED_ALERT = "#btnp";
26 // this event is generated when the button is pushed. the number parameter will be
27 // the huffware id plus the reply distance. the id parameter in the link message will
28 // contain the name of the button that was pushed.
31 float MENU_TIMER_FOR_TOUCH = 0.8; // click hold delay before we decide they want the menu.
33 key last_toucher; // the last person who touched the jaunter.
35 integer sent_menu_event = FALSE; // true when we just sent out a menu event.
41 if (last_toucher != NULL_KEY) {
42 //log_it("decided to send menu event!");
43 // this is a timer elapsing for a touch-hold menu event.
44 send_menu_button_event();
45 last_toucher = NULL_KEY;
47 sent_menu_event = TRUE;
52 // generates our next button alert, once the user has finished clicking on the button.
53 send_next_button_event()
55 llMessageLinked(LINK_SET, BUTTON_PUSHER_HUFFWARE_ID + REPLY_DISTANCE,
56 BUTTON_PUSHED_ALERT, JAUNT_NEXT_BUTTON_NAME);
59 // tells the jaunter to show the menu of places.
60 send_menu_button_event()
62 llMessageLinked(LINK_SET, BUTTON_PUSHER_HUFFWARE_ID + REPLY_DISTANCE,
63 BUTTON_PUSHED_ALERT, wrap_parameters([JAUNT_MENU_BUTTON_NAME, last_toucher]));
70 integer debug_num = 0;
72 // a debugging output method. can be disabled entirely in one place.
76 // tell this to the owner.
77 llOwnerSay(llGetScriptName() + "[" + (string)debug_num + "] " + to_say);
78 // say this on open chat, but use an unusual channel.
79 // llSay(108, (string)debug_num + "- " + to_say);
82 string wrap_parameters(list to_flatten)
83 { return llDumpList2String(to_flatten, HUFFWARE_PARM_SEPARATOR); }
88 state_entry() { if (llSubStringIndex(llGetObjectName(), "huffotronic") < 0) state real_default; }
89 on_rez(integer parm) { state rerun; }
91 state rerun { state_entry() { state default; } }
99 touch_start(integer total_number) {
100 if (llDetectedLinkNumber(0) != llGetLinkNumber()) return;
101 //log_it("touch start");
102 llSetTimerEvent(MENU_TIMER_FOR_TOUCH);
103 // how long before "hold touch" kicks in and we show the destination menu.
104 last_toucher = llDetectedKey(0);
107 timer() { handle_timer(); }
109 touch_end(integer total_number)
111 if (llDetectedLinkNumber(0) != llGetLinkNumber()) return;
112 //log_it("touch end");
113 if (sent_menu_event) {
114 // don't send a click event if we popped the menu.
115 sent_menu_event = FALSE;
118 // clear timer since we got to here.
119 llSetTimerEvent(0.0);
120 last_toucher = NULL_KEY;
121 send_next_button_event();