Difference between revisions of "Alt.tf"

From AvatarWiki
Jump to navigation Jump to search
(changing trigger to disconnect hook speeds up switching alts)
(Made executing of commands work for lowmorts too...)
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
<P>This script provides <br>
+
<P>This script provides
> quick, easy and safe alt switching<br>
+
* easy alt switching, one command will log out the current char and login the other
> a modified /world (stdlib.tf) which will not connect if tf has an active connection</P>
+
* triggers to log in quickly scrolling by the motd and what not
 
+
* 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 :)</P>
 
<P>
 
<P>
Bug reports, suggestions and/or diffs are appreciated, '''sulfar''' _AT_ ''inbox'' +DOT+ ''com''
+
You'll probably want to change the value of "main_alt" at the beginning of this script.
 
</P>
 
</P>
<P>
+
<B>An older version had 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, plz make sure and update.
You'll probably want to edit line 6 of this script ;)
+
<pre>
</P>
+
;Bug reports, suggestions and/or diffs are appreciated, '''sulfar''' _AT_ ''inbox'' +DOT+ ''com''
<pre>/echo %% /alt               (Logout and) login %main_alt
+
/loaded __SULFAR__/alt.tf
/echo %% /alt <world>       (Logout and) login <world>
+
 
/echo %% /relog             Logout and login current character
+
/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 this variable to your main alt
 
/set main_alt sulfar
 
/set main_alt sulfar
  
/set get_alt 0
+
/def alt_init = \
/set alt=
+
        /set alt_get=0%;\
 +
        /set alt=%;\
 +
        /set alt_post=%;\
 +
        /set alt_execute_post=0
  
 
;;Quick, easy and safe alt switching
 
;;Quick, easy and safe alt switching
 
/def -i alt = \
 
/def -i alt = \
    /set alt %*%;\
+
        /alt_init%;\
    /if (alt =~ "") /set alt %{main_alt}%;/endif%;\
+
        /if (!getopts("x:", "")) /return 0%; /endif%; \
    /if (is_open())\
+
        /if (opt_x !~ "") \
        /set get_alt 1%;\
+
                /set alt_post %{opt_x}%;\
        quit%;\
+
                /set alt_execute_post 1%;\
    /else \
+
        /endif%;\
        /world %{alt}%;\
+
        /set alt %*%;\
        /set get_alt 0%;\
+
        /if (alt =~ "") /set alt %{main_alt}%;/endif%;\
        /set alt=%;\
+
        /if (is_open())\
    /endif
+
                /set alt_get 1%;\
 +
                quit%;\
 +
        /else \
 +
                /world %{alt}%;\
 +
                /set alt=%;\
 +
        /endif
  
 
/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 = \
 +
        /set alt_get 0%;\
 
         /world %{alt}%;\
 
         /world %{alt}%;\
        /set get_alt 0%;\
 
 
         /set alt=
 
         /set alt=
  
;;To avoid multiplay accidents, this modified /world (stdlib.tf) will not
+
/def -i -E(alt_execute_post) -p999 -F -t"Welcome back to the AVATAR System*" alt_welcome_back = \
;; connect if tf has an active connection
+
        /let post %alt_post%;\
 +
        /alt_init%;\
 +
        /echo -aCcyan %%% /%0: Alt switch ready!  Executing command: %post%;\
 +
        /if (post !~ "") /eval -s0 %{post}%; /endif
 +
 
 +
;Some triggers to scroll by the motd and what not
 +
/def -i -mregexp -t"AVATAR (PLAYER|MORTAL) INFORMATION CENTER" login_enter_1 = /eval /send%;/repeat -0:00:0.5 1 /eval /send %;/echo %%% trigger: %0
 +
/def -i -mregexp -t"Please press <enter> to continue" login_enter_2 = /eval /send%;/repeat -0:00:0.5 1 /eval /send %; /echo %%% trigger: %0
 +
/def -i -mregexp -t"Please ensure that you've read and understood the Rules." login_enter_3 = /eval /send%;/repeat -0:00:0.5 1 /eval /send %; /echo %%% trigger: %0
 +
/def -i -mregexp -t"please press *RETURN* to continue" login_enter_4 = /eval /send%;/repeat -0:00:0.5 1 /eval /send %; /echo %%% trigger: %0
 +
/def -i -mregexp -t"Press <ENTER> to continue" login_enter_5 = /eval /send%;/repeat -0:00:0.5 1 /eval /send %; /echo %%% trigger: %0
 +
 
 +
 
 +
;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 = \
 
/def -i world = \
    /if (!getopts("nlqxfb", 0)) /return 0%; \
+
        /if (!getopts("nlqxfb", 0)) /return 0%; \
    /endif%; \
+
        /endif%; \
    /let _args=%*%; \
+
        /let _args=%*%; \
    /if (_args =~ "") \
+
        /if (_args =~ "") \
        /let _args=$(/nth 1 $(/@listworlds -s))%; \
+
                /let _args=$(/nth 1 $(/@listworlds -s))%; \
        /if (_args =/ "default") \
+
                /if (_args =/ "default") \
            /let _args=$(/nth 2 $(/@listworlds -s))%; \
+
                        /let _args=$(/nth 2 $(/@listworlds -s))%; \
 +
                /endif%; \
 
         /endif%; \
 
         /endif%; \
    /endif%; \
+
        /let _opts=%; \
    /let _opts=%; \
+
        /if (is_open(_args)) \
    /if (is_open(_args)) \
+
                /if (opt_n) /let _opts=%_opts -n%; /endif%; \
        /if (opt_n) /let _opts=%_opts -n%; /endif%; \
+
                /if (opt_q) /let _opts=%_opts -q%; /endif%; \
        /if (opt_q) /let _opts=%_opts -q%; /endif%; \
+
                /@fg %_opts %_args%; \
        /@fg %_opts %_args%; \
+
        /elseif (is_open())\
    /elseif (is_open())\  
+
                /echo %% But you *are* connected!%;\
        /echo %% But you *are* connected!%;\
+
        /else \
    /else \  
+
                /if (opt_l) /let _opts=%_opts -l%; /endif%; \
        /if (opt_l) /let _opts=%_opts -l%; /endif%; \
+
                /if (opt_q) /let _opts=%_opts -q%; /endif%; \
        /if (opt_q) /let _opts=%_opts -q%; /endif%; \
+
                /if (opt_x) /let _opts=%_opts -x%; /endif%; \
        /if (opt_x) /let _opts=%_opts -x%; /endif%; \
+
                /if (opt_f) /let _opts=%_opts -f%; /endif%; \
        /if (opt_f) /let _opts=%_opts -f%; /endif%; \
+
                /if (opt_b) /let _opts=%_opts -b%; /endif%; \
        /if (opt_b) /let _opts=%_opts -b%; /endif%; \
+
                /let _secho %{secho}%;\
        /@connect %_opts %_args%; \
+
                /set secho off%;\
    /endif
+
                /@connect %_opts %_args%; \
 
+
                /set secho %{_secho}%;\
 +
        /endif
 
</pre>
 
</pre>
 
  
 
[[Category: TinyFugue Scripting]]
 
[[Category: TinyFugue Scripting]]

Latest revision as of 23:25, 16 November 2008

This script provides

  • easy alt switching, one command will log out the current char and login the other
  • triggers to log in quickly scrolling by the motd and what not
  • 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.

An older version had 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, plz make sure and update.

;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

;Some triggers to scroll by the motd and what not
/def -i -mregexp -t"AVATAR (PLAYER|MORTAL) INFORMATION CENTER" login_enter_1 = /eval /send%;/repeat -0:00:0.5 1 /eval /send %;/echo %%% trigger: %0
/def -i -mregexp -t"Please press <enter> to continue" login_enter_2 = /eval /send%;/repeat -0:00:0.5 1 /eval /send %; /echo %%% trigger: %0
/def -i -mregexp -t"Please ensure that you've read and understood the Rules." login_enter_3 = /eval /send%;/repeat -0:00:0.5 1 /eval /send %; /echo %%% trigger: %0
/def -i -mregexp -t"please press *RETURN* to continue" login_enter_4 = /eval /send%;/repeat -0:00:0.5 1 /eval /send %; /echo %%% trigger: %0
/def -i -mregexp -t"Press <ENTER> to continue" login_enter_5 = /eval /send%;/repeat -0:00:0.5 1 /eval /send %; /echo %%% trigger: %0


;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