393918b8abb44342b9c6717bb3527f11b7faedcd
[feisty_meow.git] / huffware / huffotronic_scripts / button_pusher_v0.5.txt
1 
2 // huffware script: button pusher, by fred huffhines
3 //
4 // a simple API for reporting when buttons are pushed.
5 //
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.
8 //
9
10 // this is a kludgy thing, but this must be hard-coded to have the right button
11 // name for what the rest of the device is expecting.  it should vary depending on
12 // the actual button prim that this script is placed in.
13 string BUTTON_NAME = "next";
14
15 // the button pushing API.
16 //////////////
17 integer BUTTON_PUSHER_HUFFWARE_ID = 10035;
18     // a unique ID within the huffware system for this script.
19 string HUFFWARE_PARM_SEPARATOR = "{~~~}";
20     // this pattern is an uncommon thing to see in text, so we use it to separate
21     // our commands in link messages.
22 string HUFFWARE_ITEM_SEPARATOR = "{|||}";
23     // used to separate lists of items from each other when stored inside a parameter.
24     // this allows lists to be passed as single string parameters if needed.
25 integer REPLY_DISTANCE = 100008;  // offset added to service's huffware id in reply IDs.
26 //////////////
27 string BUTTON_PUSHED_ALERT = "#btnp";
28     // this event is generated when the button is pushed.  the number parameter will be
29     // the huffware id plus the reply distance.  the id parameter in the link message will
30     // contain the name of the button that was pushed.
31 //////////////
32
33 // generates our button pressed alert, when the user has finished clicking on the button.
34 send_button_event()
35 {
36 //llOwnerSay("user clicked on button " + BUTTON_NAME);
37     llMessageLinked(LINK_SET, BUTTON_PUSHER_HUFFWARE_ID + REPLY_DISTANCE,
38         BUTTON_PUSHED_ALERT, BUTTON_NAME);
39 }
40
41 default {
42     state_entry() { if (llSubStringIndex(llGetObjectName(), "huffotronic") < 0) state real_default; }
43     on_rez(integer parm) { state rerun; }
44 }
45 state rerun { state_entry() { state default; } }
46
47 state real_default
48 {
49     state_entry()
50     {
51     }
52     
53     touch_end(integer count) {
54         if (llDetectedLinkNumber(0) == llGetLinkNumber())
55             send_button_event();
56     }
57 }