Changeset 17
- Timestamp:
- 04/07/07 19:36:43 (2 years ago)
- Files:
-
- HUD/hud_compensator.lsl (modified) (10 diffs)
- misc/class_secondlife.php (deleted)
- misc/http (added)
- misc/http/class_secondlife.php (added)
- misc/http/httpreq.lsl (added)
- misc/httpreq.lsl (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
HUD/hud_compensator.lsl
r6 r17 1 1 ///////////////// 2 2 // 3 // HUD_compensator.lsl . 13 // HUD_compensator.lsl .3 4 4 // by Max Case 5 5 // … … 9 9 // I've left comments in the script on how to use this, so if you're not script-experienced, you can probably still use this, though, 10 10 // if you don't know scripting, this probably isn't of much interest to you, since you're probably not making HUDs. 11 // 11 // 12 // ***functionality 13 // - 14 // 12 15 // @todo if rezzed from inv, into world, or onto body even? asks to attach to a HUD point. Can even give user a choice via llDialog 13 16 // @todo make flag for wether Requires HUD Attach point, or is any point allowed? 14 // Use this in products you make, but don't just re-sell this script as-is - thanks.17 // Use this in products you make, but don't just re-sell this script as-is - thanks. 15 18 ////////////// 16 19 17 20 //Global Vars 18 rotation GR_HUD_ROTATION = <-0.27060, -0.65328, -0.27060, 0.65328>; 21 22 //The rotation it should be set to. 23 rotation GR_HUD_ROTATION = <0.49999, -0.50001, -0.50001, 0.49999> ; 24 25 //This is the rotation to show the side with preferences. 26 //For basic usage of this script, you won't need it 27 rotation GR_HUD_PREFS = <-0.000000, -0.000000, 1.000000, 0.000000>; 19 28 20 29 //OFFSET - Offset is relative to BOTTOM RIGHT - towards inside of the screen - away from edge 21 vector GV_OFFSET = < 0.0, 0.2, 0.2 >; 22 23 integer GI_KILL_SWITCH = TRUE; //Set to true if you want kill switch functionality on; 24 integer GI_KILL_COUNTER = 0; 25 integer GI_KILL_MAX = 7; //How many chances before i auto delete 30 vector GV_OFFSET = <0.221400, 0.092427, 0.099400>; 31 32 //If the user has set an offset pref, so we don't override it in show hide. 33 vector GV_USER_OFFSET = <0,0,0>; 34 35 //Only necessary if using show/hide functions 36 vector GV_HIDE_OFFSET = <-0.087600, -0.319792, 0.142695>; 37 38 //OFFSET - Offset is relative to BOTTOM RIGHT - towards inside of the screen - away from edge 39 integer GI_HUD_FLIPPED = FALSE; //Panel View default, TRUE = prefs 40 integer GI_VISIBLE = TRUE; //SHow hide flag 41 42 //BUTTONS 43 //Set to -1 to turn off. TO activate this functionality, set to the link number you want associted with the function 44 integer GI_BUTTON_FLIP = -1; //for PREFS on back 45 integer GI_BUTTON_FLIP_B = -1; 46 integer GI_BUTTON_HIDE = -1; 47 integer GI_BUTTON_SHOW = -1; 48 49 //LINK CODE 50 integer SHOW_NUM =-239482; 51 52 integer GI_KILL_SWITCH = TRUE; //Set to true if you want kill switch functionality o - probably want this to be false on no copy objects :) 53 integer GI_KILL_MAX = 10; //How many chances before i auto delete 54 55 integer GI_KILL_COUNTER = 0; //Just a global to track it. 56 26 57 float TICKS = 60.0; //For the Kill Switch timer. 27 58 list GL_HUD_NAMES = ["Center 2","Top Right","Top","Top Left","Center","Bottom Left","Bottom","Bottom Right"]; 28 59 list GL_HUD_NUMBERS = ["31","32","33","34","35","36","37","38"]; 29 60 61 integer LAST_ATTACH_POINT = -1; //This will be used to store users pref 62 30 63 integer CH_ATTACH_POINT = -29394; 31 64 integer GI_ATTACH_HANDLE; 32 65 33 66 integer debug_flag = TRUE; //set to false to turn off debug messages 34 DEBUG(list vars) { llSay(DEBUG_CHANNEL, llList2CSV(vars)); } //We use SAY/DEBUG_CHANNEL because that shows up while we have busy flag on :) 67 DEBUG(list vars) { llOwnerSay( llList2CSV(vars)); } //We use SAY/DEBUG_CHANNEL because that shows up while we have busy flag on :) 68 //This is for public speech mainly. -1 will give owner say, any other will be channel, but allows for general override 69 SAY(string msg, integer channel) { if(channel == -1) llOwnerSay(msg); else llSay(channel, msg); } 35 70 36 71 integer fn_easyDialog( key id, string message, list buttons, integer channel ) { … … 38 73 return llListen(channel, "", id, ""); //now we can just switch it off when done. 39 74 } 75 76 //Flip the hud to either prefs or main panel 77 integer fn_flip_hud( integer current ){ 78 if(current == FALSE) { 79 llSetLocalRot(GR_HUD_PREFS); 80 } else { 81 llSetLocalRot(GR_HUD_ROTATION); 82 } 83 return !current; 84 } 85 86 //Show/Hid the hud 87 integer fn_show_hide_hud( integer current ){ 88 if(current == TRUE) { //so hide it 89 //Using LINK_ALL_OTHERS instead of BUTTON_SHOW for safety while dev'ing. @TODO change later. 90 GV_USER_OFFSET = llGetLocalPos();//get the users last position, to restore later. 91 llSetPos(fn_make_hidePos(llGetAttached(), GV_HIDE_OFFSET)); 92 llMessageLinked( LINK_ALL_OTHERS , SHOW_NUM, "hide", NULL_KEY ); 93 } else { 94 llSetPos(GV_USER_OFFSET); 95 llMessageLinked( LINK_ALL_OTHERS , SHOW_NUM, "show", NULL_KEY ); 96 } 97 return !current; 98 } 99 40 100 41 101 integer fn_getIndex(list foo, string name) { … … 88 148 } 89 149 150 //Center requires different results for hide. 151 //Takes in the offsets, and the attach point 152 vector fn_make_hidePos(integer attach_point, vector offset) { 153 if ((attach_point == 31) || (attach_point == 35)) { //center 2 & center 154 return <0,-1.19,0>; 155 } else { 156 return fn_makePos(attach_point, offset); 157 } 158 } 159 160 90 161 //Once you have your HUD positions (BOTTOM RIGHT) and Rotated just right, put this script into the root prim. 91 162 //In the state entry, you will get the position (which is the offset) and rotation. Plug those into the top of your script, and remove the garbage from state_entry 92 default 93 { 163 default { 94 164 state_entry() { 95 165 //////DELETE ME BEGIN 96 llOwnerSay("Offset Info: "+(string)llGetLocalPos());97 llOwnerSay("Rotation Info: "+(string)llGetLocalRot());98 //DEBUG([llGetLocalPos(), llGetLocalRot()]);166 //llOwnerSay("Offset Info: "+(string)llGetLocalPos()); 167 //llOwnerSay("Rotation Info: "+(string)llGetLocalRot()); 168 DEBUG([llGetLocalPos(), llGetLocalRot()]); 99 169 //////DELETE ME END 100 170 } … … 105 175 llSetTimerEvent(0.0); 106 176 GI_KILL_COUNTER = 0; 107 fn_setHudPos(fn_makePos(llGetAttached(),GV_OFFSET ), GR_HUD_ROTATION );108 177 109 // DEBUG(["-attach---"]); 110 // DEBUG([llGetAttached()]); 111 // DEBUG([llGetLocalPos(), llGetLocalRot()]); 178 if(LAST_ATTACH_POINT != llGetAttached()){ 179 fn_setHudPos(fn_makePos(llGetAttached(),GV_OFFSET ), GR_HUD_ROTATION ); 180 LAST_ATTACH_POINT = llGetAttached(); 181 DEBUG(["setting last attach point"]); 182 } 183 184 //Flip it to front 185 if(GI_HUD_FLIPPED == TRUE) { 186 GI_HUD_FLIPPED=fn_flip_hud(GI_HUD_FLIPPED); 187 } 112 188 } else { 113 189 llSetTimerEvent(TICKS); //This will pester owner seconds to come pick up their item, and do kill switch. Clean up your litter kids! … … 115 191 } 116 192 117 listen( integer chan, string name, key id, string msg ) 118 { 193 listen( integer chan, string name, key id, string msg ) { 119 194 if(chan == CH_ATTACH_POINT) { 120 195 llListenRemove(GI_ATTACH_HANDLE); //Done with the listen, so let's clean up, shall we? … … 124 199 } 125 200 126 127 201 on_rez(integer start_param) { 128 if (!fn_isHudPoint(llGetAttached())){202 if (!fn_isHudPoint(llGetAttached())){ 129 203 llOwnerSay("Please! Let me attach to your HUD, won't you?"); 130 204 llRequestPermissions(llGetOwner(), PERMISSION_ATTACH); … … 137 211 GI_ATTACH_HANDLE = fn_easyDialog( llGetOwner(), "Pick a HUD Attach Point.", GL_HUD_NAMES, CH_ATTACH_POINT); 138 212 } else { 139 llOwnerSay(" You must let me attach.");213 llOwnerSay("Please let me attach! Attachment is my purpose! My Life!"); 140 214 } 141 215 } 142 216 143 217 timer() { 144 DEBUG([GI_KILL_COUNTER]);218 //DEBUG([GI_KILL_COUNTER]); 145 219 GI_KILL_COUNTER++; 146 220 if(GI_KILL_SWITCH == TRUE) { … … 150 224 } 151 225 } 152 226 153 227 string message = "Come Get me! I am here. "+ llGetRegionName()+" - "+ (string)llGetPos(); 154 228 if(GI_KILL_SWITCH == TRUE) { 155 message += " I will clean myself up if you don't pick me up after a few reminders.";156 } 157 229 message += " I will clean myself up if you don't pick me up after a while."; 230 } 231 158 232 llInstantMessage(llGetOwner(), message); 159 233 llSetTimerEvent(TICKS * (float)GI_KILL_COUNTER); … … 161 235 162 236 touch_start(integer num_detected) { 163 DEBUG([llGetAttached(),llGetLocalPos(), llGetLocalRot()]); 164 } 165 } 166 237 //DEBUG([llDetectedLinkNumber(0)]); 238 if((llDetectedLinkNumber(0) == GI_BUTTON_FLIP) || (llDetectedLinkNumber(0) == GI_BUTTON_FLIP_B)) { 239 GI_HUD_FLIPPED=fn_flip_hud(GI_HUD_FLIPPED); 240 } else if((llDetectedLinkNumber(0) == GI_BUTTON_SHOW) || (llDetectedLinkNumber(0) == GI_BUTTON_HIDE)) { 241 GI_VISIBLE= fn_show_hide_hud(GI_VISIBLE); 242 } 243 } 244 245 246 } 247
