Skip to content

Instantly share code, notes, and snippets.

@x1a0
Created September 30, 2018 15:08
Show Gist options
  • Save x1a0/8f03fc230dc3976550653d5b3b3340c6 to your computer and use it in GitHub Desktop.
Save x1a0/8f03fc230dc3976550653d5b3b3340c6 to your computer and use it in GitHub Desktop.
;;;
;;; By Zoid @BatMud
;;;
;;; Set stats
; /x_stats_set <str|dex|con|int|wis|cha|siz> <value>
/def -i x_stats_set=\
/let _name=x_stats_%{1}%;\
/let _prev=$[prgetval(_name)]%;\
/let _diff=$[{2} - {_prev}]%;\
/let _diff_name=x_stats_%{1}_diff%;\
/if (_prev !~ "" & _diff != 0) \
/if (_diff > 0) /let _diff=+%{_diff}%; /endif%;\
/eval /set %{_diff_name}=%{_diff}%;\
/set x_stats_check_has_diff=1%;\
/else \
/eval /set %{_diff_name}= %;\
/endif%;\
/eval /set %{_name}=%{2}%;
;;; Check stats
; -q Quiet mode - will not report with 'say'
/def -i x_stats_check=\
/test getopts("q", "0")%;\
/set x_stats_check_quiet=%{opt_q}%;\
/set x_stats_check_has_diff=0%;\
/def -i -ag -1 -mregexp -t"^You .+ 'Str: [^ ]+ \\((-?\\d+)(-|\\+)*\\), Dex: [^ ]+ \\((-?\\d+)(-|\\+)*\\), Con: [^ ]+ \\((-?\\d+)(-|\\+)*\\), Int: [^ ]+ \\((-?\\d+)(-|\\+)*\\), Wis: [^ ]+ \\((-?\\d+)(-|\\+)*\\), Cha: [^ ]+ \\((-?\\d+)(-|\\+)*\\), Siz: [^ ]+ \\((-?\\d+)(-|\\+)*\\)\\.'$$" _x_stats_check_on_report=\
/x_stats_set str %%{P1}%%;\
/x_stats_set dex %%{P3}%%;\
/x_stats_set con %%{P5}%%;\
/x_stats_set int %%{P7}%%;\
/x_stats_set wis %%{P9}%%;\
/x_stats_set cha %%{P11}%%;\
/x_stats_set siz %%{P13}%%;\
/if ({x_stats_check_quiet} != 1) \
/send @say | str dex con int wis cha siz |%%;\
/send @say | \
$$[pad({x_stats_str}, 3)] \
$$[pad({x_stats_dex}, 3)] \
$$[pad({x_stats_con}, 3)] \
$$[pad({x_stats_int}, 3)] \
$$[pad({x_stats_wis}, 3)] \
$$[pad({x_stats_cha}, 3)] \
$$[pad({x_stats_siz}, 3)] |%%;\
/if (x_stats_check_has_diff > 0) \
/send @say | \
$$[pad({x_stats_str_diff}, 3)] \
$$[pad({x_stats_dex_diff}, 3)] \
$$[pad({x_stats_con_diff}, 3)] \
$$[pad({x_stats_int_diff}, 3)] \
$$[pad({x_stats_wis_diff}, 3)] \
$$[pad({x_stats_cha_diff}, 3)] \
$$[pad({x_stats_siz_diff}, 3)] |%%;\
/endif%%;\
/endif%;\
/send @report stats%;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment