Alt.tf

From AvatarWiki
Revision as of 15:03, 15 October 2008 by Sulfar (talk | contribs) (mod to /world prevends a local echo of the password if secho would be on)
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
  • a modification to /world to set secho off during the /@connect, this prevends the password from being displayed if you have secho on.
  • 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=0

;;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%;\
        /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}

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

;Modified /world (stdlib.tf)
; will not connect if tf has an active connection to avoid multiplay accidents
; will turn secho off before connecting to prevend echoing the password to the
;   screen in case it was on.  The value of secho is restored after connecting.
/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%; \
                /let _secho %{secho}%;\
                /set secho off%;\
                /@connect %_opts %_args%; \
                /set secho %{_secho}%;\
        /endif