Config.tf
Jump to navigation
Jump to search
A script to store mud side configuration and filter options into variables and restore them later. It also allows you to set defaults and restore them with "/config_restore all" For more information, read the comments in the first 100 lines.
This script uses prompt.tf and verbose.tf so you'll want those if you want to use this script. You should also have TINYPREFIX set in your config file, pointing at the directory with tf scripts like
/set TINYPREFIX=~/tinyfugue/
;Bug reports, suggestions and/or diffs are appreciated, '''sulfar''' _AT_ ''inbox'' +DOT+ ''com'' /loaded __SULFAR__/config.tf /require -q lisp.tf /eval /require -q %{TINYPREFIX}prompt.tf /eval /require -q %{TINYPREFIX}verbose.tf ;Scripts can use this script to store configuration and filter options from ; Avatar into variables. Example for a call from myscript ; ; /config_store -smyscript -x/myscript_config_done ; ;/def -i myscript_config_done = \ ; config +notake%;\ ; config +nosummon%;\ ; /myscript_continues ; ;/def -i myscript_exit = \ ; /config_restore -smyscript notake%;\ ; /config_restore -smyscript nosummon%;\ ; /config_rmset myscript /def -i config_usage = \ /echo -aCyellow %%% /config_store Stores mud configuration%;\ /echo -aCyellow %%% [-s<name>] name for this set of options, default: avatar%;\ /echo -aCyellow %%% [-x<command>] execute <command> on exit%;\ /echo -aCyellow %%% /config_restore <option> Restore config <option>%;\ /echo -aCyellow %%% /config_restore all Restore all config options from this set%;\ /echo -aCyellow %%% [-s<name>] name for this set of options, default: avatar%;\ /echo -aCyellow %%% /config_rmset <set> Remove config <set> from memory /def -i filter_usage = \ /echo -aCyellow %%% /filter_store Stores mud filter configuration%;\ /echo -aCyellow %%% [-s<name>] name for this set of options, default: avatar%;\ /echo -aCyellow %%% [-x<command>] execute <command> on exit%;\ /echo -aCyellow %%% /filter_restore <option> Restore filter <option>%;\ /echo -aCyellow %%% /filter_restore all Restore all filter options from this set%;\ /echo -aCyellow %%% [-s<name>] name for this set of options, default: avatar%;\ /echo -aCyellow %%% /filter_rmset <set> Remove filter <set> from memory ;Default config. If you interrupt a script or otherwise mess up your config ; you can just /config_restore all ;To produce this list I used "/config_store" and "/listvar config_avatar*". /set config_avatar_autoexit= +autoexit /set config_avatar_autogold= +autogold /set config_avatar_autogroup= +autogroup /set config_avatar_autoloot= -autoloot /set config_avatar_autopull= +autopull /set config_avatar_autosac= -autosac /set config_avatar_autosplit= +autosplit /set config_avatar_autotitle= +autotitle /set config_avatar_battlenone= -battlenone /set config_avatar_battleother= -battleother /set config_avatar_battleself= -battleself /set config_avatar_blank= +blank /set config_avatar_blind= -blind /set config_avatar_brief= -brief /set config_avatar_cmdcolor= +cmdcolor /set config_avatar_color= +color /set config_avatar_combine= +combine /set config_avatar_condition= -condition /set config_avatar_demonbank= +demonbank /set config_avatar_keepalive= -keepalive /set config_avatar_label= +label /set config_avatar_nobeep= -nobeep /set config_avatar_nodisturb= -nodisturb /set config_avatar_nogenesis= -nogenesis /set config_avatar_nosummon= -nosummon /set config_avatar_notake= -notake /set config_avatar_prompt= +prompt /set config_avatar_prompt2= +prompt2 /set config_avatar_scoreaff= -scoreaff /set config_avatar_telnetga= -telnetga /set config_avatar_list= autoexit autoloot autogold autogroup autopull \ autosplit autosac autotitle battleother battleself battlenone blank blind \ brief color cmdcolor combine condition demonbank keepalive nobeep \ nogenesis nosummon notake nodisturb label prompt prompt2 scoreaff telnetga /eval /set config_set_list $(/unique %{config_set_list} avatar) ;Default filter, for /filter_restore all /set filter_avatar_objectother=0 /set filter_avatar_roomindiv=0 /set filter_avatar_roomtotal=1 /set filter_avatar_spellother=0 /set filter_avatar_walkother=0 /set filter_avatar_list= walkother roomindiv roomtotal spellother objectother /eval /set filter_set_list $(/unique %{filter_set_list} avatar) ;Set to 0-3 to override system verbosity level ;Set to -100 to disable script verbosity level and keep system verbosity level ;see verbose.tf /verbose -s-100 config /config_usage /filter_usage /def -i config_store = \ /set config_set=avatar%;\ /if (!getopts("x:s:")) /return 0%; /endif%;\ /if (opt_s !~ "") /set config_set %{opt_s}%;/endif%;\ /set config_post %{opt_x}%;\ /eval /set config_%{config_set}_list=%;\ /set config_set_list $(/unique %{config_set_list} %{config_set})%;\ /set config_store 1%;\ /verbose -o%{verbosity_config} -l1 - -aCcyan %%% /%0: Grabbing configuration, storing in set %config_set%;\ config /def -i -E(config_store) -t"\[ Keyword \] Option" config_liststart = \ /verbose -o%{verbosity_config} -l2 - -aCyellow %%% /%0: Start of configuration list%;\ /set prompt_exe config /def -i -E(config_store) -mregexp -t"^\[(-|\+)([a-zA-Z0-9]+) *\] .+\.$" config_option = \ /let sign %{P1}%;\ /let option $[tolower({P2})]%;\ /verbose -o%{verbosity_config} -l2 - -aCyellow %%% /%0: Got config option: %{option}%;\ /eval /set config_%{config_set}_list %%{config_%{config_set}_list} %%{option}%;\ /eval /set config_%{config_set}_%{option} %{sign}%{option} /def -i -E(config_store) -p991 -mglob -h'send PROMPT_EXE config' config_prompt_exe = \ /let post %{config_post}%;\ /set prompt_exe=%;\ /unset config_store%;\ /unset config_post%;\ /verbose -o%{verbosity_config} -ls - -aCyellow %%% /%0: Stored configuration in set %{config_set}, executing %{post}%;\ /unset config_set%;\ /if (post !~ "") /eval -s0 %{post}%; /endif /def -i config_restore = \ /set config_set=avatar%;\ /set config_noset 0%;\ /if (!getopts("s:")) /return 0%; /endif%;\ /if (opt_s !~ "") /set config_set %{opt_s}%;/endif%;\ /eval \ /if (!regmatch("autoexit", config_%{config_set}_autoexit)) \ /verbose -o%{verbosity_config} -l1 - -aCred %%%% %%;\ /verbose -o%{verbosity_config} -l1 - -aCred %%%% /%0: No configuration set %{config_set} stored!%%;\ /verbose -o%{verbosity_config} -l1 - -aCred %%%% %%;\ /set config_noset 1%%;\ /endif%;\ /if (config_noset) \ /unset config_set%;\ /unset config_noset%;\ /return 0%;\ /endif%;\ /let option %1%;\ /if (option =~ "all") \ /eval /mapcar /config_restore %%{config_%{config_set}_list}%;\ /elseif (option !~ "") \ /eval config %%{config_%{config_set}_%{option}}%;\ /else \ /config_usage%;\ /return 0%;\ /endif%;\ /verbose -o%{verbosity_config} -l1 - -aCcyan %%% /%0: Config option %{option} restored using set %{config_set}%;\ /unset config_set%;\ /unset config_noset /def -i config_rmset = \ /let rmset_set %*%;\ /if (rmset_set =~ "") /let rmset_set=avatar%;/endif%;\ /eval /set rmset_options %%{config_%{rmset_set}_list}%;\ /let rmset_length $(/length %rmset_options)%;\ /let counter=1%;\ /while (counter <= rmset_length) \ /unset config_%{rmset_set}_$(/nth %{counter} %{rmset_options})%;\ /test ++counter%;\ /done%;\ /set config_set_list $(/remove %{rm_set} %{config_set_list})%;\ /unset config_%{rmset_set}_list%;\ /unset rmset_options%;\ /if (config_set_list =~ "") /unset config_set_list%;/endif%;\ /verbose -o%{verbosity_config} -l1 - -aCcyan %%% /%0: Configuration set %{rmset_set} removed. ; Same for filter /def -i filter_store = \ /set filter_set=avatar%;\ /if (!getopts("x:s:")) /return 0%; /endif%;\ /if (opt_s !~ "") /set filter_set %{opt_s}%;/endif%;\ /set filter_post %{opt_x}%;\ /eval /set filter_%{filter_set}_list=%;\ /set filter_set_list $(/unique %{filter_set_list} %{filter_set})%;\ /set filter_store 1%;\ /verbose -o%{verbosity_config} -l1 - -aCcyan %%% /%0: Grabbing filters, storing in set %filter_set%;\ filter /def -i -E(filter_store) -t"Filter Type Status" filter_liststart = \ /verbose -o%{verbosity_config} -l2 - -aCyellow %%% /%0: Start of filter list%;\ /set prompt_exe filter /def -i -E(filter_store) -mregexp -t"^([A-Z]+).+(ON|off)" filter_option = \ /let option $[tolower({P1})]%;\ /let sign %{P2}%;\ /verbose -o%{verbosity_config} -l2 - -aCyellow %%% /%0: Got filter: %{option}%;\ /eval /set filter_%{filter_set}_list %%{filter_%{filter_set}_list} %%{option}%;\ /if (sign =~ "off") \ /eval /set filter_%{filter_set}_%{option} 0%;\ /else \ /eval /set filter_%{filter_set}_%{option} 1%;\ /endif /def -i -E(filter_store) -p991 -mglob -h'send PROMPT_EXE filter' filter_prompt_exe = \ /let post %{filter_post}%;\ /set prompt_exe=%;\ /unset filter_store%;\ /unset filter_post%;\ /verbose -o%{verbosity_config} -l1 - -aCcyan %%% /%0: Stored filters in set %{filter_set}, executing %{post}%;\ /unset filter_set%;\ /if (post !~ "") /eval -s0 %{post}%; /endif /def -i filter_restore = \ /set filter_set=avatar%;\ /set filter_noset 0%;\ /if (!getopts("s:")) /return 0%; /endif%;\ /if (opt_s !~ "") /set filter_set %{opt_s}%;/endif%;\ /eval \ /if (!regmatch("0|1", filter_%{filter_set}_objectother)) \ /verbose -o%{verbosity_config} -l1 - -aCred %%%% %%;\ /verbose -o%{verbosity_config} -l1 - -aCred %%%% /%0: No filter set %{filter_set} stored!%%;\ /verbose -o%{verbosity_config} -l1 - -aCred %%%% %%;\ /set filter_noset 1%%;\ /endif%;\ /if (filter_noset) \ /unset filter_set%;\ /unset filter_noset%;\ /return 0%;\ /endif%;\ /let option %1%;\ /if (option =~ "all") \ /eval /mapcar /filter_restore %%{filter_%{filter_set}_list}%;\ /elseif (option !~ "") \ /eval \ /if (filter_%{filter_set}_%{option}) \ filter +%%{option}%%;\ /else \ filter -%%{option}%%;\ /endif%;\ /else \ /filter_usage%;\ /return 0%;\ /endif%;\ /verbose -o%{verbosity_config} -l3 - -aCyellow %%% /%0: Filter %{option} restored using set %{filter_set}%;\ /unset filter_set%;\ /unset filter_noset /def -i filter_rmset = \ /let rmset_set %*%;\ /if (rmset_set =~ "") /let rmset_set=avatar%;/endif%;\ /eval /set rmset_options %%{filter_%{rmset_set}_list}%;\ /let rmset_length $(/length %rmset_options)%;\ /let counter=1%;\ /while (counter <= rmset_length) \ /unset filter_%{rmset_set}_$(/nth %{counter} %{rmset_options})%;\ /test ++counter%;\ /done%;\ /set filter_set_list $(/remove %{rm_set} %{filter_set_list})%;\ /unset filter_%{rmset_set}_list%;\ /unset rmset_options%;\ /if (filter_set_list =~ "") /unset filter_set_list%;/endif%;\ /verbose -o%{verbosity_config} -l1 - -aCcyan %%% /%0: Filter set %{rmset_set} removed.