;;;;;;; Alias and xalias definition. Original alias.tf + lots local changes. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /def -i alias = \ /let opt_w=0%; \ /test getopts("sxw:")%; \ /if (opt_w !~ 0) \ /if (opt_w =~ "") /let alias_name_mod=_${world_name}%; \ /else /let alias_name_mod=_%opt_w%; \ /endif%; \ /else \ /let alias_name_mod=%; \ /endif%; \ /if ({#} < 2) \ /quote -S /~listalias \ `/list -s -i -mglob alias_body_%{1-*}%alias_name_mod*%; \ /else \ /if (opt_s = 1) \ /if (opt_x = 1) /let alias_pre=%; \ /else /let alias_pre=/send -%; \ /endif%; \ /else \ /if (opt_x = 1) /let alias_pre=/dot -x -%; \ /else /let alias_pre=/dot -%; \ /endif%; \ /endif%; \ /if (regmatch("%{", {*})) /let alias_tail=%; \ /else /let alias_tail=%%{*}%; \ /endif%; \ /def -i alias_body_%1%alias_name_mod = %alias_pre %-1 %alias_tail%; \ /def -i -ag -mglob -h'SEND {%1}*' alias_call_%1 = \ /if /ismacro alias_body_%1_$${world_name}%%; /then \ /shift%%; \ /alias_body_%1_$${world_name} %%*%%; \ /elseif /ismacro alias_body_%1%%; /then \ /shift%%; \ /alias_body_%1 %%*%%; \ /else \ /send - %%*%%; \ /endif%; \ /endif /def -i ~listalias = /echo /alias $[substr({L}, 11)] ${%L} /def -i unalias = \ /let opt_w=0%; \ /test getopts("w:")%; \ /if (opt_w !~ 0) \ /if (opt_w =~ "") /let alias_name_mod=_${world_name}%; \ /else /let alias_name_mod=_%opt_w%; \ /endif%; \ /else \ /let alias_name_mod=%; \ /endif%; \ /undef alias_body_%1%alias_name_mod ; leave alias_call_%1 in case other worlds were using it... /def -i xalias = \ /let opt_w=0%; \ /test getopts("sxw:")%; \ /if (opt_w !~ 0) \ /if (opt_w =~ "") /let xalias_name_mod=_${world_name}%; \ /else /let xalias_name_mod=_%opt_w%; \ /endif%; \ /else \ /let xalias_name_mod=%; \ /endif%; \ /if ({1} =~ "\\") \ /result "% '\\' is a reserved xalias."%; \ /endif%; \ ; convert the char to an ascii value so we can legally use it in the macro name /let xalias_char=$[ascii({1})]%; \ /if ({#} < 2) \ /quote -S /~listxalias \ `/list -s -i -mglob xalias_body_%xalias_char%xalias_name_mod*%; \ /else \ /if (opt_s = 1) \ /if (opt_x = 1) /let xalias_pre=%; \ /else /let xalias_pre=/send -%; \ /endif%; \ /else \ /if (opt_x = 1) /let xalias_pre=/dot -x -%; \ /else /let xalias_pre=/dot -%; \ /endif%; \ /endif%; \ /if (regmatch("%{", {*})) /let xalias_tail=%; \ /else /let xalias_tail=%%{*}%; \ /endif%; \ /def -i xalias_body_%xalias_char%xalias_name_mod = \ %xalias_pre %-1 %xalias_tail%; \ /def -i -ag -mglob -h'SEND \\%1*' xalias_call_%xalias_char = \ /if /ismacro xalias_body_%{xalias_char}_$${world_name}%%; /then \ /test regmatch(".", "%%{*}")%%; \ /xalias_body_%xalias_char%xalias_name_mod %%PR%%; \ /elseif /ismacro xalias_body_%{xalias_char}%%; /then \ /test regmatch(".", "%%{*}")%%; \ /xalias_body_%xalias_char %%PR%%; \ /else \ /send - %%*%%; \ /endif%; \ /endif /def -i ~listxalias = /echo /xalias $[char(substr({L}, 12))] ${%L} /def -i unxalias = \ /let opt_w=0%; \ /test getopts("w:")%; \ /if (opt_w !~ 0) \ /if (opt_w =~ "") /let xalias_name_mod=_${world_name}%; \ /else /let xalias_name_mod=_%opt_w%; \ /endif%; \ /else \ /let xalias_name_mod=%; \ /endif%; \ /let xalias_char=$[ascii(%1)]%; \ /undef xalias_body_%xalias_char%xalias_name_mod ; leave xalias_call_%1 in case other worlds were using it... ;;;;;;; Allow '\' to always send directly to the mud. Not done as an xalias ;;;;;;; because of problems using '\' that way. /def -i -mglob -h'SEND \\\*' escape_alias = /send $[substr({*}, 1, \ strlen({*}))] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;; Define macros that are only active in the world they were defined in. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; /def -i wdef = \ /split %*%; \ /if (strlen({P2})) \ /def %{P1} = /%{P1}_$${world_name}%; \ /def %{P1}_${world_name} = %{P2}%; \ /endif /def -i unwdef = /undef %1_${world_name} ; leave /%1 in case other worlds were using it...