Difference between revisions of "Alt.tf"

From AvatarWiki
Jump to navigation Jump to search
(mod to /world prevends a local echo of the password if secho would be on)
(Bug!Fix!)
Line 3: Line 3:
 
* a modified /world (stdlib.tf) which will not connect if tf has an active connection
 
* 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.
 
* 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.</P>
+
* you can use /alt -x<command> <alt>  to log in <alt> and have <command> executed when the alt logged in, so you could easily make a spellup macro that'd use 2 alts :)</P>
 
<P>
 
<P>
 
You'll probably want to change the value of "main_alt" at the beginning of this script.
 
You'll probably want to change the value of "main_alt" at the beginning of this script.
 
</P>
 
</P>
 +
<B>This version fixes a bug</B> that creeped in when I changed the trigger to a disconnect hook.  It didn't turn it off after an alt switch.  If you'd use it to log in (create) a denied character, <B>the script would loop trying to log in that character.</B>  I suspect it'd do the same if you'd have a wrong password in your config file.  Big oops!  If you're using this script, plz2update.
 
<pre>
 
<pre>
 
;Bug reports, suggestions and/or diffs are appreciated, '''sulfar''' _AT_ ''inbox'' +DOT+ ''com''
 
;Bug reports, suggestions and/or diffs are appreciated, '''sulfar''' _AT_ ''inbox'' +DOT+ ''com''
Line 12: Line 13:
  
 
/echo -aCyellow %% /alt                  (Logout and) login %{main_alt}
 
/echo -aCyellow %% /alt                  (Logout and) login %{main_alt}
/echo -aCyellow %% /alt <worldname>     (Logout and) login <worldname>
+
/echo -aCyellow %% /alt <world>         (Logout and) login <world>
/echo -aCred %%    [-x<command>]           execute <command> 8 sec. after alt switch
+
/echo -aCyellow %%    [-x<command>]         execute <command> after alt switch
/echo -aCyellow %% /relog                (Logout and) login current worldname
+
/echo -aCyellow %% /relog                (Logout and) login current world
  
 
;Set this variable to your main alt
 
;Set this variable to your main alt
Line 20: Line 21:
  
 
/def alt_init = \
 
/def alt_init = \
         /set get_alt 0%;\
+
         /set alt_get=0%;\
 
         /set alt=%;\
 
         /set alt=%;\
 
         /set alt_post=%;\
 
         /set alt_post=%;\
Line 36: Line 37:
 
         /if (alt =~ "") /set alt %{main_alt}%;/endif%;\
 
         /if (alt =~ "") /set alt %{main_alt}%;/endif%;\
 
         /if (is_open())\
 
         /if (is_open())\
                 /set get_alt 1%;\
+
                 /set alt_get 1%;\
 
                 quit%;\
 
                 quit%;\
 
         /else \  
 
         /else \  
 
                 /world %{alt}%;\
 
                 /world %{alt}%;\
                /set get_alt 0%;\
 
 
                 /set alt=%;\
 
                 /set alt=%;\
 
         /endif
 
         /endif
Line 46: Line 46:
 
/def -i relog = /alt ${world_name}
 
/def -i relog = /alt ${world_name}
  
/def -i -p999 -F -E(get_alt) -h'disconnect' leaving_avatar= \
+
/def -i -E(alt_get) -p999 -F -h'disconnect' alt_disconnect = \
         /world %{alt}
+
        /set alt_get 0%;\
 +
         /world %{alt}%;\
 +
        /set alt=
  
/def -i -p999 -F -t"Welcome back to the AVATAR System, *" alt_welcome_back = \
+
/def -i -E(alt_execute_post) -p999 -F -t"Welcome back to the AVATAR System, *" alt_welcome_back = \
 
         /let post %alt_post%;\
 
         /let post %alt_post%;\
 
         /alt_init%;\
 
         /alt_init%;\
         /echo -aCcyan %%% /%0: Alt switch ready!  Executing command in 8 s: %post%;\
+
         /echo -aCcyan %%% /%0: Alt switch ready!  Executing command: %post%;\
         /if (post !~ "") /eval -s0 /repeat -8 1 %{post}%; /endif
+
         /if (post !~ "") /eval -s0 %{post}%; /endif
  
 
;Modified /world (stdlib.tf)
 
;Modified /world (stdlib.tf)
Line 87: Line 89:
 
                 /set secho %{_secho}%;\
 
                 /set secho %{_secho}%;\
 
         /endif
 
         /endif
 
 
</pre>
 
</pre>
  
 
[[Category: TinyFugue Scripting]]
 
[[Category: TinyFugue Scripting]]

Revision as of 03:25, 19 October 2008

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 when the alt logged in, so you could easily make a spellup macro that'd use 2 alts :)

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

This version fixes a bug that creeped in when I changed the trigger to a disconnect hook. It didn't turn it off after an alt switch. If you'd use it to log in (create) a denied character, the script would loop trying to log in that character. I suspect it'd do the same if you'd have a wrong password in your config file. Big oops! If you're using this script, plz2update.

;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 <world>          (Logout and) login <world>
/echo -aCyellow %%     [-x<command>]         execute <command> after alt switch
/echo -aCyellow %% /relog                (Logout and) login current world

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

/def alt_init = \
        /set alt_get=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 alt_get 1%;\
                quit%;\
        /else \ 
                /world %{alt}%;\
                /set alt=%;\
        /endif

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

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

/def -i -E(alt_execute_post) -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: %post%;\
        /if (post !~ "") /eval -s0 %{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