tintin++ mud连线列表维护脚本

把这段代码存到tintin++启动文件中,运行tintin++后会增加addworlddeleteworldconnect三个别名,可以用来维护MUD列表,方便连接游戏。

#EVENT {PROGRAM START}
{
    #class worlddata read worlddata.tin;
    #if {&{worldlist} == 0}
    {
        #class worlddata open;
        #list worldlist clear;
        #class worlddata close
    }
}

#ALIAS {addworld}
{
    #if {"%3" == ""}
    {
        #showme Syntax: addworld <name> <host> <port> [character name] [password]
    };
    #else
    {
        #variable worldlist[%1][name] %1;
        #variable worldlist[%1][host] %2;
        #variable worldlist[%1][port] %3;
        #if {"%4" != ""}
        {
            #variable worldlist[%1][char] %4
        };
        #if {"%5" != ""}
        {
            #variable worldlist[%1][pass] %5
        };
        #if {&worldlist[%1][char]}
        {
            #showme The world %1 (%2 %3) and the character %4 (%5) has been added.
        };
        #else
        {
            #showme The world %1 (%2 %3) has been added.
        };
        #class worlddata write worlddata.tin
    }
}

#ALIAS {deleteworld}
{
    #if {&worldlist[%1] != 0}
    {
        #unvariable worldlist[%1];
        #class worlddata write worlddata.tin;
        #showme The world %1 has been deleted.
    };
    #else
    {
        #showme The world %1 could not be found.
    }
}

#ALIAS {connect}
{
    #if {"%1" == ""}
    {
        #echo {%h} {{ WORLD LIST }};
        #foreach {*worldlist[]} {world}
        {
            #echo {%-20s %s %s %s} {$worldlist[$world][name]} {$worldlist[$world][host]} {$worldlist[$world][port]} {$worldlist[$world][char]}
        }
    };
    #elseif {&worldlist[%1] != 0}
    {
        #variable mud {%1};
        #session $worldlist[%1][name] $worldlist[%1][host] $worldlist[%1][port]
    };
    #else
    {
        #showme Could not find world %1.
    }
}

#EVENT {SESSION CONNECTED}
{
    #variable mud @gts{$mud};
    #if {&worldlist[$mud]}
    {
        #if {&worldlist[$mud][char]}
        {
            #send {$worldlist[$mud][char]};
            #if {&worldlist[$mud][pass]}
            {
                #send {$worldlist[$mud][pass]}
            }
        }
    }
}

比如,输入 addworld yhmud mud.ren 6666 会增加一个名称为yhmud的站点,使用 connect yhmud即可连接游戏。

京ICP备13031296号-4