Difference between revisions of "Config.tf"
Jump to navigation
Jump to search
(bugfix bah) |
(bugfix) |
||
Line 109: | Line 109: | ||
/let option %1%;\ | /let option %1%;\ | ||
/if (option =~ "all") \ | /if (option =~ "all") \ | ||
− | /eval /mapcar /config_restore | + | /eval /mapcar /config_restore %%{config_%{config_set}_list}%;\ |
/elseif (option !~ "") \ | /elseif (option !~ "") \ | ||
/eval \ | /eval \ | ||
Line 198: | Line 198: | ||
/let option %1%;\ | /let option %1%;\ | ||
/if (option =~ "all") \ | /if (option =~ "all") \ | ||
− | /eval /mapcar /filter_restore | + | /eval /mapcar /filter_restore %%{filter_%{filter_set}_list}%;\ |
/elseif (option !~ "") \ | /elseif (option !~ "") \ | ||
/eval \ | /eval \ |
Revision as of 09:50, 2 November 2008
A script to store mud side configuration and filter options into variables and restore them later. See comments.
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 -xmyscript_config_done ; ;/def -i myscript_config_done = \ ; config +notake%;\ ; config +nosummon%;\ ; /my_script_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 /config_usage /filter_usage ;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 -o-100 config /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}%;\ /if (sign =~ "-") \ /eval /set config_%{config_set}_%{option} 0%;\ /else \ /eval /set config_%{config_set}_%{option} 1%;\ /endif /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} -l1 - -aCcyan %%% /%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("0|1", 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 \ /if (config_%{config_set}_%{option}) \ config +%%{option}%%;\ /else \ config -%%{option}%%;\ /endif%;\ /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} -l1 - -aCcyan %%% /%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.