X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=huffware%2Fhuffotronic_tools_n_testers_v6.1%2Fbutton_pusher_v0.5.lsl;fp=huffware%2Fhuffotronic_tools_n_testers_v6.1%2Fbutton_pusher_v0.5.lsl;h=393918b8abb44342b9c6717bb3527f11b7faedcd;hb=f2be7577716da4384c07946069b3b353ca15403a;hp=0000000000000000000000000000000000000000;hpb=620a99face4f2cefadeed9ce69b4fd4f8d6e2b56;p=feisty_meow.git diff --git a/huffware/huffotronic_tools_n_testers_v6.1/button_pusher_v0.5.lsl b/huffware/huffotronic_tools_n_testers_v6.1/button_pusher_v0.5.lsl new file mode 100755 index 00000000..393918b8 --- /dev/null +++ b/huffware/huffotronic_tools_n_testers_v6.1/button_pusher_v0.5.lsl @@ -0,0 +1,57 @@ + +// huffware script: button pusher, by fred huffhines +// +// a simple API for reporting when buttons are pushed. +// +// this script is licensed by the GPL v3 which is documented at: http://www.gnu.org/licenses/gpl.html +// do not use it in objects without fully realizing you are implicitly accepting that license. +// + +// this is a kludgy thing, but this must be hard-coded to have the right button +// name for what the rest of the device is expecting. it should vary depending on +// the actual button prim that this script is placed in. +string BUTTON_NAME = "next"; + +// the button pushing API. +////////////// +integer BUTTON_PUSHER_HUFFWARE_ID = 10035; + // a unique ID within the huffware system for this script. +string HUFFWARE_PARM_SEPARATOR = "{~~~}"; + // this pattern is an uncommon thing to see in text, so we use it to separate + // our commands in link messages. +string HUFFWARE_ITEM_SEPARATOR = "{|||}"; + // used to separate lists of items from each other when stored inside a parameter. + // this allows lists to be passed as single string parameters if needed. +integer REPLY_DISTANCE = 100008; // offset added to service's huffware id in reply IDs. +////////////// +string BUTTON_PUSHED_ALERT = "#btnp"; + // this event is generated when the button is pushed. the number parameter will be + // the huffware id plus the reply distance. the id parameter in the link message will + // contain the name of the button that was pushed. +////////////// + +// generates our button pressed alert, when the user has finished clicking on the button. +send_button_event() +{ +//llOwnerSay("user clicked on button " + BUTTON_NAME); + llMessageLinked(LINK_SET, BUTTON_PUSHER_HUFFWARE_ID + REPLY_DISTANCE, + BUTTON_PUSHED_ALERT, BUTTON_NAME); +} + +default { + state_entry() { if (llSubStringIndex(llGetObjectName(), "huffotronic") < 0) state real_default; } + on_rez(integer parm) { state rerun; } +} +state rerun { state_entry() { state default; } } + +state real_default +{ + state_entry() + { + } + + touch_end(integer count) { + if (llDetectedLinkNumber(0) == llGetLinkNumber()) + send_button_event(); + } +}