Affects Sidebar

From Dyrdex.com
Revision as of 04:39, 23 November 2023 by Admin (talk | contribs)
Jump to navigation Jump to search

This code creates a right-hand sidebar containing your affects list.

You can toggle it on/off on the fly. It will not disrupt any existing right-hand sidebars you have set up.

Usage: just type 'affbar' to toggle it on/off.


Installation

1. Edit my MSDP script [Here] per the Auto-Updater section below and #READ msdp.tin 2. Create a new file and copy/paste all the Affbar Code section below into it. Then #READ filename.tin to load that. 3. Run 'affbar' to toggle the sidebar on/off

Troubleshooting

If you have problems, please run the following. Let me know if these vars exist and contain data or not.

1. Run #var msdp_info 2. Run #var screen 2. Run #line debug get_affects 3. Run #var affects

If you run into a problem, check those first and let me know where you are seeing a problem.

Also... (and this has fooled me multiple times...) -- make sure your character as some spells on! duh!


Customization

The formatting of the list is done in the get_affects alias, edit that however you like.

It basically just builds a list at $affects, do #var affects to view it. Get that looking however you want.


CODE:

MSDP AUTO-UPDATER

To get this to auto-update as spells tick down, you can fire a re-draw based on the msdp reception of the affects string.

Edit my MSDP script [Here], just add the line in bold below to this event:


#EVENT {IAC SB MSDP AFFECTS}
{
   #unvariable {msdp_info[AFFECTS]};
       #variable {msdp_affects_raw} {%1};
       #replace {msdp_affects_raw} {\a\a} {;};
       #replace {msdp_affects_raw} {\a} {;};
   #foreach {$msdp_affects_raw} {tmp} 
   {
       #regex {$tmp} {%*,%d} {#var msdp_info[AFFECTS][&1] &2} {#NOP};
   };
   #unvar tmp;
   #unvar msdp_affects_raw;
   #IF {&{affbar}} {draw_affects_sidebar};
};



Affbar Code

#ALIAS get_affects {
        #LIST affects clear;
        #FOREACH {*msdp_info[AFFECTS][]} {affect}
        {
                #IF {$msdp_info[AFFECTS][$affect] < 50} {#var Color {<dbb>}};
                #IF {$msdp_info[AFFECTS][$affect] > 49 && $msdp_info[AFFECTS][$affect] < 99} {#var Color {<ffd>}};
                #IF {$msdp_info[AFFECTS][$affect] > 99} {#var Color {<ddd>}};
                #FORMAT {affect_line} {%c%+15.15s %c%-4s%c}
                        {<bbb>}{$affect}
                        {$Color}{$msdp_info[AFFECTS][$affect]}{<ddd>};
                #CLASS null assign #LIST {affects} {add} {<ddd>$affect_line};
        };
        #UNVAR Color;
        #UNVAR affect_line;
};

#ALIAS {draw_affects_sidebar} {
        #IF {!&{screen}} {screen_refresh};
        #MATH {screen[split_right_total]} {$screen[split_right] + 24};
        #SPLIT $screen[split_top] $screen[split_bot] $screen[split_left] $screen[split_right_total];
        #MATH {affects_Row1} {$screen[split_top] + 1};
        #MATH {affects_Col1} {$screen[split_right_total] - 1};
        #MATH {affects_Row2} {$screen[split_bot] + 2};
        #MATH {affects_Col2} {$screen[original_right_split] + 1};
        #DRAW box $affects_Row1 -$affects_Col1 -$affects_Row2 -$affects_Col2 $affects[1..-1];
        }

#ALIAS screen_refresh {
        #CLASS null open;
        #SCREEN get split_top_bar screen[split_top];
        #SCREEN get split_bot_bar screen[split_bot];
        #SCREEN get split_left_bar screen[split_left];
        #SCREEN get split_right_bar screen[split_right];
        #CLASS null close;
        }

#EVENT {SCREEN RESIZE} {
        #buffer end;
        #IF {&{affbar}} {draw_affects_sidebar};
        };


#ALIAS {affbar} {
        #IF {!&{affbar}} {
                #NOP if not already on, turn on;
                #VAR affbar 1;
                screen_refresh;
                #VAR {screen[original_right_split]} {$screen[split_right]};
                get_affects;
                draw_affects_sidebar;
                };
        #ELSE {
                #NOP if already on, turn off;
                #UNVAR affbar;
                #split $screen[split_top] $screen[split_bot] $screen[split_left] $screen[original_right_split];
                };
        }