Affects Sidebar: Difference between revisions
Jump to navigation
Jump to search
(→CODE:) |
|||
Line 35: | Line 35: | ||
---- | ---- | ||
<pre> | <pre> | ||
#ALIAS get_affects { | #ALIAS get_affects { | ||
#LIST affects clear; | #LIST affects clear; | ||
Line 75: | Line 61: | ||
#DRAW box $affects_Row1 -$affects_Col1 -$affects_Row2 -$affects_Col2 $affects[1..-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_bar}; | |||
}; | |||
#ALIAS {affbar} { | #ALIAS {affbar} { |
Revision as of 18:53, 7 November 2022
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.
Auto-Update
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.
In my MSDP script, 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_bar}; };
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:
#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_bar}; }; #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]; }; }