Changeset 17

Show
Ignore:
Timestamp:
04/07/07 19:36:43 (2 years ago)
Author:
max.ca..@gmail.com
Message:

Organizing things

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • HUD/hud_compensator.lsl

    r6 r17  
    11///////////////// 
    22// 
    3 //  HUD_compensator.lsl .1 
     3//  HUD_compensator.lsl .3 
    44//  by Max Case 
    55// 
     
    99//    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,  
    1010//  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// 
    1215//  @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 
    1316//  @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. 
    1518////////////// 
    1619 
    1720//Global Vars 
    18 rotation GR_HUD_ROTATION = <-0.27060, -0.65328, -0.27060, 0.65328>; 
     21 
     22//The rotation it should be set to.  
     23rotation 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 
     27rotation GR_HUD_PREFS =  <-0.000000, -0.000000, 1.000000, 0.000000>;  
    1928 
    2029//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 
     30vector 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.  
     33vector GV_USER_OFFSET = <0,0,0>;  
     34 
     35//Only necessary if using show/hide functions 
     36vector 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 
     39integer GI_HUD_FLIPPED = FALSE; //Panel View default, TRUE  = prefs 
     40integer 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 
     44integer GI_BUTTON_FLIP = -1; //for PREFS on back 
     45integer GI_BUTTON_FLIP_B = -1; 
     46integer GI_BUTTON_HIDE = -1; 
     47integer GI_BUTTON_SHOW = -1; 
     48 
     49//LINK CODE 
     50integer SHOW_NUM =-239482; 
     51  
     52integer GI_KILL_SWITCH = TRUE; //Set to true if you want kill switch functionality o - probably want this to be false on no copy objects :)  
     53integer GI_KILL_MAX = 10; //How many chances before i auto delete 
     54 
     55integer GI_KILL_COUNTER = 0; //Just a global to track it. 
     56 
    2657float TICKS = 60.0; //For the Kill Switch timer. 
    2758list GL_HUD_NAMES = ["Center 2","Top Right","Top","Top Left","Center","Bottom Left","Bottom","Bottom Right"]; 
    2859list GL_HUD_NUMBERS = ["31","32","33","34","35","36","37","38"]; 
    2960 
     61integer LAST_ATTACH_POINT = -1; //This will be used to store users pref 
     62 
    3063integer CH_ATTACH_POINT = -29394; 
    3164integer GI_ATTACH_HANDLE; 
    3265 
    3366integer 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 :) 
     67DEBUG(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 
     69SAY(string msg, integer channel) { if(channel == -1) llOwnerSay(msg); else llSay(channel, msg); }  
    3570 
    3671integer fn_easyDialog( key id, string message, list buttons, integer channel ) { 
     
    3873    return llListen(channel, "", id, "");    //now we can just switch it off when done. 
    3974} 
     75 
     76//Flip the hud to either prefs or main panel 
     77integer 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 
     87integer 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 
    40100 
    41101integer fn_getIndex(list foo, string name) { 
     
    88148} 
    89149 
     150//Center requires different results for hide. 
     151//Takes in the offsets, and the attach point  
     152vector 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 
    90161//Once you have your HUD positions (BOTTOM RIGHT) and Rotated just right, put this script into the root prim. 
    91162//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 
     163default { 
    94164    state_entry() { 
    95165        //////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()]); 
    99169        //////DELETE ME END 
    100170    } 
     
    105175            llSetTimerEvent(0.0); 
    106176            GI_KILL_COUNTER = 0; 
    107             fn_setHudPos(fn_makePos(llGetAttached(),GV_OFFSET ), GR_HUD_ROTATION ); 
    108177             
    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                        } 
    112188        } else { 
    113189            llSetTimerEvent(TICKS); //This will pester owner  seconds to come pick up their item, and do kill switch. Clean up your litter kids! 
     
    115191    } 
    116192 
    117     listen( integer chan, string name, key id, string msg ) 
    118     { 
     193    listen( integer chan, string name, key id, string msg ) { 
    119194        if(chan == CH_ATTACH_POINT) { 
    120195            llListenRemove(GI_ATTACH_HANDLE); //Done with the listen, so let's clean up, shall we? 
     
    124199    } 
    125200 
    126  
    127201    on_rez(integer start_param) { 
    128         if (!fn_isHudPoint(llGetAttached())){ 
     202               if (!fn_isHudPoint(llGetAttached())){ 
    129203            llOwnerSay("Please! Let me attach to your HUD, won't you?"); 
    130204            llRequestPermissions(llGetOwner(), PERMISSION_ATTACH); 
     
    137211            GI_ATTACH_HANDLE = fn_easyDialog( llGetOwner(), "Pick a HUD Attach Point.", GL_HUD_NAMES, CH_ATTACH_POINT); 
    138212        } else { 
    139             llOwnerSay("You must let me attach."); 
     213            llOwnerSay("Please let me attach! Attachment is my purpose! My Life!"); 
    140214        } 
    141215    } 
    142216 
    143217    timer() { 
    144         DEBUG([GI_KILL_COUNTER]); 
     218        //DEBUG([GI_KILL_COUNTER]); 
    145219        GI_KILL_COUNTER++; 
    146220        if(GI_KILL_SWITCH == TRUE) { 
     
    150224            } 
    151225        } 
    152          
     226 
    153227        string message = "Come Get me! I am here. "+ llGetRegionName()+" - "+ (string)llGetPos(); 
    154228        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 
    158232        llInstantMessage(llGetOwner(), message); 
    159233        llSetTimerEvent(TICKS * (float)GI_KILL_COUNTER); 
     
    161235 
    162236    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