Alt.tf

From AvatarWiki
Revision as of 05:14, 11 October 2008 by Sulfar (talk | contribs)
Jump to navigation Jump to search

This script provides

  • quick, easy and safe alt switching
  • a modified /world (stdlib.tf) which will not connect if tf has an active connection
  • you can use /alt -x<command> <alt> to log in <alt> and have <command> executed 8 seconds after the alt logged in.

You'll probably want to change the value of "main_alt" at the beginning of this script.

;Bug reports, suggestions and/or diffs are appreciated, '''sulfar''' _AT_ ''inbox'' +DOT+ ''com''
/loaded __SULFAR__/alt.tf

/echo -aCyellow %% /alt                  (Logout and) login %{main_alt}
/echo -aCyellow %% /alt <worldname>      (Logout and) login <worldname>
/echo -aCred %%     [-x<command>]            execute <command> 8 sec. after alt switch
/echo -aCyellow %% /relog                (Logout and) login current worldname

;Set this variable to your main alt
/set main_alt sulfar

/def alt_init = \
        /set get_alt 0%;\
        /set alt=%;\
        /set alt_post=%;\
        /set alt_execute_post=

;;Quick, easy and safe alt switching
/def -i alt = \
        /alt_init%;\
        /if (!getopts("x:", "")) /return 0%; /endif%; \
        /if (opt_x !~ "") \
                /set alt_post %{opt_x}%;\
                /set alt_execute_post 1%;\
        /else \
                /set alt_post=%;\
                /set alt_execute_post 0%;\
        /endif%;\
        /set alt %*%;\
        /if (alt =~ "") /set alt %{main_alt}%;/endif%;\
        /if (is_open())\
                /set get_alt 1%;\
                quit%;\
        /else \ 
                /world %{alt}%;\
                /set get_alt 0%;\
                /set alt=%;\
        /endif

/def -i relog = /alt ${world_name}

/def -i -p999 -F -E(get_alt) -h'disconnect' leaving_avatar= \
        /world %{alt}%;\
        /set get_alt 0%;\
        /set alt=

/def -i -E(alt_execute_post) -p999 -F -t"Welcome back to the AVATAR System, *" alt_execute_post = \
        /let post %alt_post%;\
        /alt_init%;\
        /echo -aCcyan %%% /%0: Alt switch ready!  Executing command: %post%;\
        /if (post !~ "") /eval -s0 /repeat -8 1 %{post}%; /endif

;To avoid multiplay accidents, this modified /world (stdlib.tf) will not
;  connect if tf has an active connection
/def -i world = \
        /if (!getopts("nlqxfb", 0)) /return 0%; \
        /endif%; \
        /let _args=%*%; \
        /if (_args =~ "") \
                /let _args=$(/nth 1 $(/@listworlds -s))%; \
                /if (_args =/ "default") \
                        /let _args=$(/nth 2 $(/@listworlds -s))%; \
                /endif%; \
        /endif%; \
        /let _opts=%; \
        /if (is_open(_args)) \
                /if (opt_n) /let _opts=%_opts -n%; /endif%; \
                /if (opt_q) /let _opts=%_opts -q%; /endif%; \
                /@fg %_opts %_args%; \
        /elseif (is_open())\
                /echo %% But you *are* connected!%;\
        /else \
                /if (opt_l) /let _opts=%_opts -l%; /endif%; \
                /if (opt_q) /let _opts=%_opts -q%; /endif%; \
                /if (opt_x) /let _opts=%_opts -x%; /endif%; \
                /if (opt_f) /let _opts=%_opts -f%; /endif%; \
                /if (opt_b) /let _opts=%_opts -b%; /endif%; \
                /@connect %_opts %_args%; \
        /endif