skip navigation

Welcome, Guest [log in · register]
Cwn Annwn
Search
Page 1 of 1 1
Tejon
Avatar
Okay, this snippet of code is used to parse the list that comes up when you type ‘affects’. (Damn, I hate that institutionalized typo!) It colours spells in that list in various ways, depending on whether they are desireable effects or undesireable effects, and whether they are close to finishing. Additionally, it will report any spells that you would like to keep active that are missing.

The customization variables are as follows:
good_effects All the spells you want to be marked as good in the list.
bad_effects All the spells you want to be marked as bad in the list.
X_type_colour where X is good, bad, or neutral: The colour you want the spell name to be normally.
X_time_colour The colour you want the time to be normally.
X_base_colour The colour you want the text about level and modifies to be normally.
X_short_Y_colour where X is as above, and Y is type, base, or time: The corresponding colours to use when there is less than @short_time left on the spell.
short_time The time remaining at which the parser switches from ‘short’ colours to normal colours. Defaults to 11 game minutes.
wanted_spells A list of spells that you want to have active all the time. If you are missing one, it will note it at the end of the affects list.
Good luck, and let me know if you see any bugs.


#CLASS {effects}
#VAR good_effects {levitation|shield|sanctuary|bless|haste|invisibility|armor|augment aura|stone skin|fireshield|enhanced strength|detect invisibilit}
#VAR bad_effects {poison|plague|faerie fire|curse|web|paralyze|silence|slow|weaken|fatigue}
#VAR wanted_spells {levitation|shield|sanctuary|bless|haste|invisibility|armor|augment aura|stone skin|detect invisibilit|enhanced strength}
#var short_time 11
#VAR good_base_colour {cyan}
#VAR good_type_colour {green}
#VAR good_time_colour {green}
#VAR good_short_type_colour {green}
#VAR good_short_time_colour {yellow}
#VAR good_short_base_colour {yellow}
#VAR bad_base_colour {red}
#VAR bad_type_colour {red}
#VAR bad_time_colour {red}
#VAR bad_short_type_colour {red}
#VAR bad_short_base_colour {magenta}
#VAR bad_short_time_colour {red}
#VAR neutral_time_colour {white}
#VAR neutral_type_colour {white}
#VAR neutral_base_colour {cyan}
#VAR base_colour {cyan}
#VAR type_colour {white}
#VAR time_colour {white}
#VAR misstring {}
#VAR found_spell {1} {0}
#VAR first_spell {1} {0}
#VAR spells {}
#REGEX {^Spell: (.+?) +- Level ([0-9]+) *, modifies (.+) + by ([-0-9]+) + for *([0-9-]+) +minutes.} {
#gag
#class effects
#var base_colour @neutral_base_colour
#var type_colour @neutral_type_colour
#var time_colour @neutral_time_colour
#if (%ismember( %1, @good_effects)) {
#if ((%int( %5) < @short_time) and (%int( %5) > -1)) {
#var base_colour @good_short_base_colour
#var type_colour @good_short_type_colour
#var time_colour @good_short_time_colour
} {
#var base_colour @good_base_colour
#var type_colour @good_type_colour
#var time_colour @good_time_colour
}
} {
#if ( %ismember( %1, @bad_effects)) {
#if ((%int( %5) < @short_time) and (%int( %5) > -1)) {
#var base_colour @bad_short_base_colour
#var type_colour @bad_short_type_colour
#var time_colour @bad_short_time_colour
} {
#var base_colour @bad_base_colour
#var type_colour @bad_type_colour
#var time_colour @bad_time_colour
}
}
}
#say %ansi( high, magenta, black) %ansi( high, @type_colour)%format( "&-19s", %1)%ansi( high, @base_colour)"- Level " %format( "&3.0n", %2)", modifies " %ansi( high, @base_colour)%format( "&-19s", %3)%ansi( high, @base_colour)" by "%ansi( high, @base_colour)%format( "&3.0n", %4)%ansi( high, @time_colour)" for "%format( "&4.0n", %5)%ansi( high, @base_colour)" minutes"
#var espells %additem( %1, @espells)
#var first_spell 0
}
#TRIGGER {Total of (*) magical affects.} {
#class effects
#if (@first_spell = 0) {
#var first_spell 1
#var found_spell 0
#forall @wanted_spells {
#if ( not %ismember( %i, @espells)) {
#if (( %len( %i) > 0) and (@found_spell == 0)) {
#var found_spell 2
#var misstring %cr%ansi( high, red)"Missing:"
}
#var misstring %concat( @misstring, " "%ansi( high, red)%i)
}
}
}
#if ( @found_spell == 2) {
#say @misstring
#var found_spell 1
}
#var misstring ""
#var espells ""
#class 0
}
#CLASS 0


Last edited on November 6, 2006 11:44pm.
Tejon
Avatar
Sample output
Tejon
Avatar
For the new affects output:

[code]
#REGEX {^Spell: (.+?) +- Level +([0-9]+) *, modifies +(.+) by +([0-9]+)(?: +for +([0-9]+) +minute.*)*.} {
#gag
#var timeleft %int( %5)
#class effects
#var base_colour @neutral_base_colour
#var type_colour @neutral_type_colour
#var time_colour @neutral_time_colour
#if (%ismember( %1, @good_effects)) {
#if ((@timeleft < 11) and (@timeleft > 0)) {
#var base_colour @good_short_base_colour
#var type_colour @good_short_type_colour
#var time_colour @good_short_time_colour
} {
#var base_colour @good_base_colour
#var type_colour @good_type_colour
#var time_colour @good_time_colour
}
} {
#if ( %ismember( %1, @bad_effects)) {
#if ((@timeleft < 11) and (@timeleft > 0)) {
#var base_colour @bad_short_base_colour
#var type_colour @bad_short_type_colour
#var time_colour @bad_short_time_colour
} {
#var base_colour @bad_base_colour
#var type_colour @bad_type_colour
#var time_colour @bad_time_colour
}
}
}
#say %ansi( high, magenta, black) %ansi( high, @type_colour)%format( "&-21s", %1)%ansi( high, @base_colour)"- Level " %format( "&3.0n", %2)", » " %ansi( high, @base_colour)%format( "&-19s", %3)%ansi( high, @base_colour)" by "%ansi( high, @base_colour)%format( "&3.0n", %4)%ansi( high, @time_colour)" for "%format( "&3.0n", @timeleft)%ansi( high, @base_colour)" min"
#var espells %additem( %1, @espells)
#var first_spell 0
}
Tejon
Avatar
People wanted the whole new one at once, so here it is:

[code]
#CLASS {effects}
#VAR good_effects {levitation|shield|sanctuary|bless|haste|invisibility|armor|augment aura|stone skin|fireshield|enhanced strength|detect invisibility|augment aura|stone skin}
#VAR bad_effects {poison|plague|faerie fire|curse|web|paralyze|silence|slow|weaken|fatigue}
#VAR base_colour {cyan}
#VAR first_spell {0} {0}
#VAR type_colour {white}
#VAR spells {}
#VAR wanted_spells {levitation|shield|sanctuary|bless|haste|invisibility|armor|augment aura|stone skin|detect invisibility|enhanced strength}
#VAR found_spell {0} {0}
#VAR good_base_colour {cyan} {cyan}
#VAR good_type_colour {green} {green}
#VAR good_time_colour {green} {green}
#VAR good_short_type_colour {green} {green}
#VAR good_short_time_colour {yellow} {yellow}
#VAR good_short_base_colour {yellow} {yellow}
#VAR bad_base_colour {red} {red}
#VAR bad_type_colour {red} {red}
#VAR bad_time_colour {red} {red}
#VAR bad_short_type_colour {yellow} {yellow}
#VAR bad_short_base_colour {magenta} {magenta}
#VAR bad_short_time_colour {red} {red}
#VAR neutral_time_colour {white} {white}
#VAR neutral_type_colour {white} {white}
#VAR neutral_base_colour {cyan} {cyan}
#VAR time_colour {white}
#VAR misstring {}
#VAR espells {}
#REGEX {^Spell: (.+?) +- Level +([0-9]+) *, modifies +(.+) by +([0-9]+)(?: +for +([0-9]+) +minute.*)*.} {
#gag
#var timeleft %int( %5)
#class effects
#var base_colour @neutral_base_colour
#var type_colour @neutral_type_colour
#var time_colour @neutral_time_colour
#if (%ismember( %1, @good_effects)) {
#if ((@timeleft < 11) and (@timeleft > 0)) {
#var base_colour @good_short_base_colour
#var type_colour @good_short_type_colour
#var time_colour @good_short_time_colour
} {
#var base_colour @good_base_colour
#var type_colour @good_type_colour
#var time_colour @good_time_colour
}
} {
#if ( %ismember( %1, @bad_effects)) {
#if ((@timeleft < 11) and (@timeleft > 0)) {
#var base_colour @bad_short_base_colour
#var type_colour @bad_short_type_colour
#var time_colour @bad_short_time_colour
} {
#var base_colour @bad_base_colour
#var type_colour @bad_type_colour
#var time_colour @bad_time_colour
}
}
}
#say %ansi( high, magenta, black) %ansi( high, @type_colour)%format( "&-21s", %1)%ansi( high, @base_colour)"- Level " %format( "&3.0n", %2)", » " %ansi( high, @base_colour)%format( "&-19s", %3)%ansi( high, @base_colour)" by "%ansi( high, @base_colour)%format( "&3.0n", %4)%ansi( high, @time_colour)" for "%format( "&3.0n", @timeleft)%ansi( high, @base_colour)" min"
#var espells %additem( %1, @espells)
#var first_spell 0
}
#TRIGGER {Total of (*) magical affects.} {
#class effects
#if (@first_spell = 0) {
#var first_spell 1
#var found_spell 0
#forall @wanted_spells {
#if ( not %ismember( %i, @espells)) {
#if (( %len( %i) > 0) and (@found_spell == 0)) {
#var found_spell 2
#var misstring %cr%ansi( high, red)"Missing:"
}
#var misstring %concat( @misstring, " "%ansi( high, red)%i)
}
}
}
#if ( @found_spell == 2) {
#say @misstring
#var found_spell 1
}
#var misstring ""
#var espells ""
#class 0
}
#CLASS 0
Cerryl Doesn’t work with affects that result in a negative stat, such as web.
Syll
Doesn’t work with affects that result in a negative stat, such as web.


Can we work around this?
Page 1 of 1 1