# ircII's mud client, 1994
# derived from the "nemesis" script
# This script should work for any ircII2.2.9 or better client
# This file is freeware.
#
# Usage:  newmud keyword hostname portnum
#     registers "keyword" in the mud array
#
# Usage:  mud
#     shows you the muds in the array
#
# Usage:  mud keyword
#     logs you into that mud
#
alias mud {
        if ([$0])
        {
                if (mud[$encode($0)][name])
                {
                        if (mud[$encode($0)][mark])
                        {
                                echo *** Already connected to that mud!
                        }
                        {c_mud $0 $mud[$encode($0)][name] $mud[$encode($0)][port]}
                }
                {echo *** No such mud on file}
        }
        {
                foreach mud i
                {
                        echo *** MUD: $decode($i) - $mud[$i][name] $mud[$i][port]
                }
        }
}
alias c_mud {
        @ keyw = [$0]
        @ mudcon = mudcon + 1
        if (mudcon == 5)
        {
                @ mudcon = mudcon - 1
                echo *** Too many muds open (limit of 4)
        }
        {
                window new name $keyw level USERLOG$mudcon
                wait
                window back
                wait
                away mudding... not here at all.
                set auto_unmark_away OFF
                window hide
                wait
                ignore * all
                eval exec -name $keyw telnet $1 $2
                eval query %$keyw
                wait
                eval on ^exec "$keyw *" \{xecho -level USERLOG$mudcon $$1-\}
                eval on ^exec_exit "$keyw*" {
                        window show $0 kill
                        @ mudcon=mudcon-1
                        eval on exec -"$keyw *"
                        eval on exec_exit -"$keyw*"
                        if (!mudcon)
                                {ignore * none}
                }
                wait
        }
}
bind ^W parse_command window next

alias newmud {
        @ mud[$encode($0)][name] = [$1]
        @ mud[$encode($0)][port] = [$2]
}

newmud onyx stimpy.cs.iastate.edu 3456
@ mudcon = 0

#hop'94
