Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - amylase

Pages: [1] 2
1
Other / Evennia
« on: August 18, 2012, 05:25:49 am »
Hey guys check out this python geared lib
http://code.google.com/p/evennia/

Seems pretty well documented and high level.  What do people think?

It also uses twisted words to conveniently talk with IRC and intermud channels.
http://code.google.com/p/evennia/wiki/IRC
This bit particularly appeal to me since I am more towards social mud development.

Functional beta release has come out.

2
Code Vault / Chat Timestamp
« on: August 17, 2012, 11:48:57 am »
Version: Mudlib: Dead Souls 3.6,  Driver: FluffOS v2.23-ds01w               
Aim: Add date and time stamp to chats
File: /lib/secure/daemon/chat.c

Just an updated mod to add timestamp to the end of chat.

What this code does is for example in dschat whenever someone says something, at the end of their sentence there will be date and time in square brackets. Useful when you haven't been in front of the computer for hours or days and come back to scroll back to check on who said what when.

For example normally you get:
Quote
User@Game <channel> chat content.

After modification, you will get this:
Quote
User@Game <channel> chat content. [Aug 18 00:49:49]

Tricky back in 2006 showed us how to do the modification to ds 2.1.1.
See middle of this thread: http://lpmuds.net/smf/index.php?topic=184.msg1072#msg1072
Since then, there's been some changes to /lib/secure/daemon/chat.c
For simplicity sake I include the entire modified chat.c here

Code: [Select]
/*    /daemon/chat.c
 *    from the Dead Souls Mudlib
 *    daemon to handle all mud chat channels
 *    created by Descartes of Borg 931220
 *
 *    IMC2 support added by Shadyman 2007-Sep-24
 *    Feelings support added by Shadyman 2007-Sep-24
 *    "mapping tags" added by Shadyman 2007-Sep-24
 */

#ifndef LOG_REMOTE_CHANS
#define LOG_REMOTE_CHANS 0
#endif

#ifndef LOG_LOCAL_CHANS
#define LOG_LOCAL_CHANS 1
#endif

#ifndef CHANNEL_PIPES
#define  CHANNEL_PIPES 0
#endif

#include <lib.h>
#include <pov.h>
#include <daemons.h>
#include <origin.h>
#include <message_class.h>
#include "include/chat.h"

inherit LIB_DAEMON;

string suspect,site,chan;
static private mapping Channels;
static private mapping chanlast;

static private string *local_chans = ({});
static private string *remote_chans = ({});
static string *syschans = ({});

static private mapping localchans = ([
        //I3 Channels
        "imud_code": "intercre",
        "imud_gossip": "intergossip",
        "ie_flibcode": "foundation",
        "dead_test4": "ds_test",
        "dead_souls": "ds",

        //IMC2 Channels
        "Server02:igame": "i2game2",
        "Server02:inews": "i2news2",
        "Server01:ibuild": "ibuild2",
        "Server01:ichat": "ichat2",
        "Server01:pchat": "pchat2",
        "Server01:i2game": "i2game2",
        "Server01:i2chat": "i2chat2",
        "Server01:i3chat": "i3chat2",
        "Server01:i2code": "i2code2",
        "Server01:i2news": "i2news2",
        "Server01:imudnews": "imudnews2",
        "Server01:irc": "irc2",
        "Server01:ifree": "ifree2",

        ]);

        static private mapping remotechans = ([
                //I3 Channels
                "intercre": "imud_code",
                "intergossip": "imud_gossip",
                "foundation": "ie_flibcode",
                "dutch": "dutch",
                "ds_test": "dead_test4",
                "ds": "dead_souls",

                //IMC2 Channels
                "i2game2": "Server02:igame",
                "i2news2": "Server02:inews",
                "ibuild2": "Server01:ibuild",
                "ichat2": "Server01:ichat",
                "pchat2": "Server01:pchat",
                "i2game2": "Server01:i2game",
                "i2chat2": "Server01:i2chat",
                "i3chat2": "Server01:i3chat",
                "i2code2": "Server01:i2code",
                "i2news2": "Server01:i2news",
                "imudnews2": "Server01:imudnews",
                "irc2": "Server01:irc",
                "ifree2": "Server01:ifree",
                ]);

static private mapping tags = ([
        "intermud"    : "%^B_BLACK%^WHITE%^",
        "muds"        : "%^B_BLACK%^WHITE%^",
        "connections" : "%^B_BLACK%^BOLD%^WHITE%^",
        "death"       : "%^BOLD%^RED%^",
        "cre"         : "%^BOLD%^GREEN%^",
        "admin"       : "%^BOLD%^MAGENTA%^",
        "newbie"      : "%^BOLD%^B_YELLOW%^",
        "gossip"      : "%^BOLD%^B_BLUE%^",

        "ds"          : "%^YELLOW%^",
        "dchat" :"%^CYAN%^",
        "intergossip" : "%^GREEN%^",
        "intercre"    : "%^ORANGE%^",

        "ibuild2"      : "%^B_RED%^%^YELLOW%^",
        "ichat2"       : "%^B_RED%^%^GREEN%^",
        "pchat2"       : "%^B_RED%^%^BOLD%^GREEN%^",
        "i2game2"      : "%^B_BLUE%^",
        "i2chat2"      : "%^B_GREEN%^",
        "i3chat2"      : "%^B_RED%^",
        "i2code2"      : "%^B_YELLOW%^%^RED%^",
        "i2news2"      : "%^B_YELLOW%^%^BLUE%^",
        "imudnews2"    : "%^B_YELLOW%^%^CYAN%^",
        "irc2"         : "%^B_BLUE%^%^GREEN%^",
        "ifree2"         : "%^B_BLUE%^%^GREEN%^",

        "default"     : "%^BOLD%^BLUE%^",
        "default-IMC2" : "%^BOLD%^WHITE%^%^B_BLUE%^",
        ]);

static void Setup(){
    mixed rchan2 = ({});
    mixed rchan3 = ({});
    remote_chans = ({});
    local_chans = ({"newbie","cre","gossip","admin","error", "intermud",
            "death", "connections", "muds" });
    syschans = ({ "intermud", "death", "connections", "muds" });

    local_chans += CLASSES_D->GetClasses();

    if(find_object(INTERMUD_D)){
        if(arrayp(INTERMUD_D->GetChannels()))
            rchan3 += distinct_array(INTERMUD_D->GetChannels());
    }
    if(find_object(IMC2_D)){
        if(arrayp(IMC2_D->GetChanList()))
            rchan2 += distinct_array(IMC2_D->GetChanList());
    }

    foreach(mixed foo in local_chans){
        if(!stringp(foo)){
            local_chans -= ({ foo });
        }
    }

    rchan3 = sort_array(filter(rchan3, (: stringp($1) :)), 1);
    rchan2 = sort_array(filter(rchan2, (: stringp($1) :)), 1);

    foreach(mixed bar in ({ rchan3, rchan2 })){
        foreach(mixed foo in bar){
            string svr, cnl;
            if(!stringp(foo) || member_array(foo, local_chans) != -1){
                bar -= ({ foo });
                continue;
            }
            if(sscanf(foo, "%s:%s", svr, cnl) == 2){
                if(member_array(cnl, local_chans) == -1 && !localchans[cnl] &&
                  member_array(cnl, rchan3) == -1){
                    localchans[foo] = cnl;
                    remotechans[cnl] = foo;
                }
            }
        }
    }
    remote_chans = distinct_array((rchan3 + rchan2));
    local_chans = distinct_array(local_chans);
}

static void create() {
    object pl;
    string *tmp_arr = ({});
    daemon::create();
    SetNoClean(1);
    Channels = ([]);

    call_out("Setup", 10);

    foreach(string kanal in local_chans + syschans){
        if( !Channels[kanal] ) Channels[kanal] = ({});
    }
    foreach(pl in users()) {
        string *chans;
        string channel;

        if( pl && !(chans = pl->GetChannels()) ) continue;
        foreach(channel in chans) {
            if( !Channels[channel] ) Channels[channel] = ({});
            Channels[channel] = distinct_array(Channels[channel] + ({ pl }));
        }
    }
    foreach( string channel in local_chans ){
        tmp_arr += ({ channel + "emote" });
        tmp_arr += ({ channel + ":" });
    }

    local_chans += tmp_arr;
}

string *AddRemoteChannel(mixed chan){
    string *ret = copy(remote_chans);
    if(base_name(previous_object()) != INTERMUD_D) return ret;
    if(stringp(chan)) chan = ({ chan });
    if(!arrayp(chan)) return ret;
    foreach(string element in chan){
        if(member_array(element, local_chans) != -1){
            chan -= ({ element });
        }
    }
    return copy(remote_chans = distinct_array(remote_chans += chan));
}

string *AddLocalChannel(mixed chan){
    string *ret = copy(local_chans);
    if(base_name(previous_object()) != PARTY_D) return ret;
    if(stringp(chan)) chan = ({ chan });
    if(!arrayp(chan)) return ret;
    foreach(string element in chan){
        if(member_array(element, local_chans) != -1){
            chan -= ({ element });
        }
    }
    return copy(local_chans = distinct_array(local_chans += chan));
}

string *RemoveRemoteChannel(mixed chan){
    string *ret = copy(remote_chans);
    if(base_name(previous_object()) != INTERMUD_D) return ret;
    if(stringp(chan)) chan = ({ chan });
    if(!arrayp(chan)) return ret;
    foreach(string element in chan){
        if(member_array(element, local_chans) != -1){
            chan -= ({ element });
        }
    }
    return copy(remote_chans = distinct_array(remote_chans -= chan));
}

string *RemoveLocalChannel(mixed chan){
    string *ret = copy(local_chans);
    if(base_name(previous_object()) != PARTY_D) return ret;
    if(stringp(chan)) chan = ({ chan });
    if(!arrayp(chan)) return ret;
    foreach(string element in chan){
        if(member_array(element, local_chans) != -1){
            chan -= ({ element });         }
    }     
    return copy(local_chans = distinct_array(local_chans -= chan));
}

varargs string *GetRemoteChannels(int localized){
    mixed *ret = ({});
    if(!localized) return copy(remote_chans);
    foreach(string chan in remote_chans){
        ret += ({ GetLocalChannel(chan) });
    }
    return ret;
}

string decolor(string str){
    string s1 = "", s2, s3, test;
    int tmp = 2;
    if(sscanf(str,"%s<%s>%s",s1,s2,s3) != 3)
        tmp = sscanf(str,"<%s>%s",s2,s3);
    if(tmp != 2) return str;
    else {
        test = s1+"<"+s2+">%^RESET%^"+strip_colours(s3);
        return test;
    }
}

varargs int CanListen(object who, string canal){
    if(!RESTRICTED_INTERMUD) return 1;
    if(canal && member_array(canal, local_chans) != -1) return 1;
    else return imud_privp(who);
}

varargs int CanTalk(object who, string canal){
    if(!RESTRICTED_INTERMUD) return 1;
    if(canal && member_array(canal, local_chans) != -1) return 1;
    else return imud_privp(who);
}

string *eventRegisterMember(string *chans) {
    string *tmp;
    object ob;
    string channel;

    if( !living(ob = previous_object()) ) return ({});
    tmp = ({});
    foreach(channel in chans) {
        /* just check out for secure channels */
        switch(channel) {
            case "admin":
                if( !archp(ob) ) break;
            case "cre": case "intercre": case "intergossip":
                if( !creatorp(ob) ) break;
            default:
            if( !Channels[channel]) Channels[channel] = ({});
            Channels[channel] = distinct_array(Channels[channel] + ({ ob }));
            tmp += ({ channel });
        }
    }
    return tmp;
}

string *eventRemoveMember(string *chans) {
    object ob;
    string channel;

    if( !living(ob = previous_object()) ) return({});
    foreach(channel in chans) {
        if( !Channels[channel] ) continue;
        else Channels[channel] -= ({ ob });
        if( !sizeof(Channels[channel]) ) map_delete(Channels, channel);
    }
    return chans;
}

int cmdLast(string feep){

    if(!chanlast||!Channels[feep]||member_array(this_player(), Channels[feep])==-1){

        this_player()->eventPrint("You are not subscribed to that channel.", MSG_ERROR);
        return 1;
    }
    if(!sizeof(chanlast[feep]))
    {
        this_player()->eventPrint("That channel has no backlog.", MSG_ERROR);
        return 1;
    }
    if(!CanListen(this_player(),feep)){
        write("You lack privileges to that channel.");
        return 1;
    }
    this_player()->eventPrint(implode(chanlast[feep], "\n"));
    return 1;
}

static int LogIt(string what, string where, string canale){
    if( (member_array(canale,local_chans) != -1 && LOG_LOCAL_CHANS) ||
            ( member_array(GetRemoteChannel(canale),remote_chans) != -1 && LOG_REMOTE_CHANS) ){
        unguarded( (: write_file($(where), $(what)) :) );
        return 1;
    }
    else return 0;
}

varargs int eventAddLast(string feep, string str, string pchan, string pmsg, string pwho)
{
    string plainmsg;
    string Chan=feep;
    if(!chanlast)
        chanlast=([]);
    if(!sizeof(chanlast[Chan]))
        chanlast[Chan] = ({});
    if(sizeof(chanlast[Chan]) == 50)
        chanlast[Chan] = chanlast[Chan][1..sizeof(chanlast[Chan])];
    chanlast[Chan] += ({ str });
    Chan = GetLocalChannel(Chan);

    if (Chan == "death") return 1;

    //Log in either SQL or file
#ifdef MYSQL
    if (MYSQL_D->sql_request("INSERT INTO LOG_CHAT (Channel,Who,What) VALUES (\'"+ escape(pchan) +"\',\'" + escape(pwho) + "\',\'" + escape(pmsg) + "\')") == 0) {
        true();
    }
#endif
    Chan = GetLocalChannel(Chan);
    if(!pchan || pchan == "") pchan = "foo";
    plainmsg = "bar";
    if(pchan) plainmsg = "<" + pchan + "> ";
    if(pmsg) plainmsg += pmsg;
    if(pwho && pwho !="") plainmsg = pwho+" "+plainmsg;
    if(pchan && pchan != "admin"){
        LogIt("["+timestamp()+"] "+plainmsg+"\n", "/log/chan/"+Chan, Chan);
    }
    else {
        LogIt("["+timestamp()+"] "+plainmsg+"\n", "/secure/log/"+Chan, Chan);
    }
    return 1;
}

int cmdChannel(string verb, string str){
    string msg, name, rc, target, targetkey, target_msg, emote_cmd, remains;
    string *exploded;
    mixed array msg_data;
    object ob = 0;
    int i, emote, forcedemote;

    if(grepp(verb,"|")){
        string foo, bar;

        if(CHANNEL_PIPES){
            if(grepp(verb,"|morse")){
                str = morse(str);
                verb = replace_string(verb,"|morse","");
            }

            if(grepp(verb,"|colorize")){
                str = dbz_colors(str);
                verb = replace_string(verb,"|colorize","");
            }

            if(grepp(verb,"|annoy")){
                str = dbz_colors(str,2);
                verb = replace_string(verb,"|annoy","");
            }
            if(grepp(verb,"|file")){
                if(!file_exists(str) || !(str = read_file(str))){
                    write("Can't read that file.");
                    return 0;
                }
                verb = replace_string(verb,"|file","");
            }
        }

        if(sscanf(verb, "%s|%s", foo, bar) == 2) verb = foo;
    }

    if(grepp(verb, ":")){
        string *tmpv = explode(verb, ":");
        if(!sizeof(tmpv)) tmpv = ({"newbie"});
        verb = tmpv[0]+"emote";
        if(sizeof(tmpv) > 1) str = implode(tmpv[1..], ":") + str;
    }

    if(grepp(verb, ";")){
        string *tmpv = explode(verb, ";");
        if(!sizeof(tmpv)) tmpv = ({"newbie"});
        verb = tmpv[0]+"forcedemote";
        if(sizeof(tmpv) > 1) str = implode(tmpv[1..], ";") + str;
    }

    if(sizeof(str) > 2){
        if((str[0..0] == ":" || str[0..0] == ";") &&
                alphap(str[1..1]) && str[2..2] != " "){
            if(str[0..0] == ";" && !grepp(verb,"forcedemote"))
                verb = replace_string(verb,"emote","") + "forcedemote";
            else if(str[0..0] == ":" && !grepp(verb,"emote")) verb += "emote";
            str = str[1..];
        }
    }

    //******LIST******
    //allow "list <chan>" to list users listening
    if( verb == "list" ) {
        string *who;
        string ch, mud;

        if( !str ) return 0;

        //Find the remote listing for a channel on a specific mud
        if( sscanf(str, "%s@%s", ch, mud) == 2 ) {
            mud = trim(mud);
            if(!alphap(last(mud,1))) mud = truncate(mud,1);

            if( !Channels[ch] ) return 0;

            if( member_array(this_player(), Channels[ch]) == -1 ) return 0;

            if( ch == (ch = GetRemoteChannel(ch)) ) {
                if(!creatorp(this_player())){
                    write("Remote channel information is not available to players.");
                    return 1;
                }
            }

            if( !(mud = INTERMUD_D->GetMudName(mud)) ) {
                this_player()->eventPrint(mud_name() + " is not aware of "+
                        "such a place.", MSG_ERROR);
                return 1;
            }

            if(!CanTalk(this_player(),verb)) {
                write("You lack privileges to that channel.");
                return 1;
            }
            SERVICES_D->eventSendChannelWhoRequest(ch, mud);
            this_player()->eventPrint("Remote listing request sent.",
                    MSG_SYSTEM);
            return 1;
        }
        else ch = str;

        //If no such channel, or not a part of that channel, then no list.
        if( !Channels[ch] ) return 0;
        if( member_array(this_player(), Channels[str]) == -1 ) return 0;

        //Build and print the list of listeners
        who = GetChannelList(str);
        msg = "Online: " + implode(who, "   ");
        this_player()->eventPrint(msg, MSG_SYSTEM);
        return 1;
    }
    //******END LIST******


    //All emotes will fall into this IF structure and get tagged
    //as emote = 1 or forcedemote = 1

    //If it's a verb+emote, de-emote the verb, and mark as an emote
    if(grepp(verb, "emote")) {
        //Get the real channel
        if(grepp(verb, "forcedemote")){
            verb = replace_string(verb,"forcedemote","");   
            forcedemote = 1;
        }
        else verb = replace_string(verb,"emote","");
        emote = 1;
    }

    if(!strsrch(str,"^encode")) str = morse("(encoded):  "+str[7..]);

    if(find_object(INTERMUD_D) && !sizeof(remote_chans))
        remote_chans = distinct_array(INTERMUD_D->GetChannels());

    if(member_array(GetRemoteChannel(verb), remote_chans) == -1 &&
            member_array(verb, local_chans) == -1) local_chans += ({ verb });

    //******Access Checks
    //No talking if you're not allowed.
    if ( !CanTalk(this_player(),verb) ) {
        write("You lack privileges to that channel.");
        return 1;
    }
    //Toggle channel blocking
    if ( emote == 1 && ( !str || str == "" ) ) {
        this_player()->SetBlocked(verb + "emote");
        return 1;
    } else if ( !str || str == "" ) {
        this_player()->SetBlocked(verb);
        return 1;
    }
    //Syschans aren't for chatting on, only listening
    if ( member_array(verb, syschans) != -1 ) {
        write("This is not a channel for chatting.");
        return 1;
    }
    //If gagged, you can't talk on channels
    if ( this_player()->GetGagged(verb) ) {
        write("You have gag mode enabled. Type: 'gag off' to talk on channels.");
        return 1;
    }
    //Channel doesn't exist, probably an emote typo
    if(!Channels[verb]) return 0;
    //If not part of the channel, no chatting
    if( member_array(this_player(), Channels[verb]) == -1 ) return 0;
    //If blocked, allow no chatting
    if( this_player()->GetBlocked(verb) ) {
        if( this_player()->GetBlocked("all") ) {
            this_player()->eventPrint("You cannot chat while totally blocked.",
                    MSG_ERROR);
            return 1;
        }
        this_player()->eventPrint("Turn this channel on to talk on it.", MSG_ERROR);
        return 1;
    }
    //******End Access Checks

    //If there's no channel matching now, then it's a typo or wasn't meant for this file to pick up.
    if( !Channels[verb] ) return 0;
    //Find the remote channel's name, based on the local, pretty name
    rc = GetRemoteChannel(verb);
    //Check emotes
    if (emote == 1) {
        exploded = explode(str, " "); //BOOM!!! We have an array of words.
        if (sizeof(exploded) <= 1) {
            emote_cmd = str;
            remains = 0;
        } else {
            emote_cmd = exploded[0];
            remains = implode(exploded[1..]," ");
        }

        //***********************************
        //Find a target for targetted emotes.
        //***********************************
        if( !remains ) { //If no arguments and just one word
            msg_data = SOUL_D->GetChannelEmote(emote_cmd, ""); //Search for a feeling that matches
        } else { //If there is an argument to the emote,
            if( ob = find_living(target = convert_name(remains)) ) {  //If there is a living target
                msg_data = SOUL_D->GetChannelEmote(emote_cmd, "LIV");
                //If it's not there, get the emote's LVS text.
                //if (!msg_data)
                // msg_data = SOUL_D->GetChannelEmote(emote_cmd, "LVS", remains);
            } else if( strsrch(target, "@") == -1 ) { //If no living target
                string array words = explode(remains, " ");
                target = "";
                for(i=0; i<sizeof(words); i++) {
                    target += lower_case(words[i]);
                    if( ob = find_living(target) ) {
                        if( i < sizeof(words)-1 ) {
                            remains = implode(words[(i+1)..], " ");
                        } else {
                            remains = 0;
                        }
                        //If it's not there, get the emote's LVS STR text.
                        if (!msg_data)
                            msg_data = SOUL_D->GetChannelEmote(emote_cmd, "LVS STR", remains);
                        break;
                    }
                }
                if( !ob ) {
                    msg_data = SOUL_D->GetChannelEmote(emote_cmd, "STR", remains);
                    target = 0;
                }

            } else {
                string array words;

                //Find any @'s in the remains.. Should be User@Mud
                i = strsrch(remains, "@", -1);

                //If there's not enough room for a proper name@mud, just do it as a string
                if ( i >= strlen(remains)-1 ) {
                    msg_data = SOUL_D->GetChannelEmote(emote_cmd, "STR", remains);
                    target = 0;
                } else { //Otherwise, call mud and find user
                    string mud,temp;
                    words = explode(remains[(i+1)..], " ");
                    target = remains[0..i];
                    remains = "";
                    while(sizeof(words)) {
                        temp = implode(words, " ");
                        temp = trim(temp);
                        if(!alphap(last(temp,1))) temp = truncate(temp,1);
                        mud = INTERMUD_D->GetMudName(lower_case(temp));
                        if (!mud) mud = IMC2_D->find_mud(lower_case(temp));
                        if( mud ) {
                            target += mud;
                            break;
                        }
                        if( remains == "" ) remains = words[<1];
                        else remains = words[<1] + " " + remains;
                        words = words[0..<2];
                    }

                    //If we couldn't find the mud,
                    if ( !mud ) {
                        msg_data = SOUL_D->GetChannelEmote(emote_cmd, "STR", remains);
                        target = 0;
                    } else {
                        if ( trim(remains) == "" ) {
                            msg_data = SOUL_D->GetChannelEmote(emote_cmd, "LIV");
                        } else {
                            msg_data = SOUL_D->GetChannelEmote(emote_cmd, "LIV STR", remains);
                        }
                    }
                }
            }
        } //Done finding target

        //***********************************
        //Find the target's proper name and target the message at him/her.
        //***********************************

        if ( msg_data ) { //There's a target
            string sgen = this_player()->GetGender();
            string tgen = 0;

            if ( ob ) { //If a local user
                target = ob->GetName();
                tgen = ob->GetGender();
            } else if ( target ) { //If a mud user
                string user, mud;

                sscanf(target, "%s@%s", user, mud);
                targetkey = target;
                tgen = SERVICES_D->GetRemoteGender(user, mud);
                target = SERVICES_D->GetRemoteDisplayName(user, mud);
                if( !target ) target = capitalize(targetkey);
            }

            //Calculate the viewpoint for 3rd parties
            str = create_message(POV_OBSERVER, msg_data[0][0],
                    msg_data[0][1], "$N", sgen, "$O", tgen,
                    msg_data[1]);

            //If it's targetted, calculate the message for the target
            if ( target ) {
                target_msg = create_message(POV_TARGET, msg_data[0][0],
                        msg_data[0][1], "$N", sgen,
                        "$O", tgen, msg_data[1]);
                target_msg = replace_string(target_msg, "$O's", "your");   
            }
        } else { //There's no target. Spurt it out like the user put it in.
            //Forced emotes only allow real emotes, not custom ones.
            if (forcedemote == 1) {
                if ( member_array( emote_cmd,SOUL_D->GetEmotes() ) > -1 ) {
                    write("Invalid syntax. See %^CYAN%^help "+emote_cmd+"%^RESET%^ for a list of usages.");
                    return 1;
                } else {
                    write("No such feeling. See %^CYAN%^help feelings%^RESET%^ for a list of feelings.");
                    return 1;
                }
            } else {
                str = "$N " + str;
                target = 0;
            }
        }
    }

    //If admin or cre channels, Capitalize a person's real name, because admins can be physically hidden
    if( verb == "admin" || verb == "cre" ) {
        if( !(name = this_player()->GetCapName()) )
            name = capitalize(this_player()->GetKeyName());
    }
    else name = this_player()->GetName();
    //Add the "Name" $N to the string
    if(!grepp(str,"$N") && emote) str = "$N "+str;
    //Send locally
    eventSendChannel(name, verb, str, emote, target, target_msg);
    //If it's a remote channel, send it remotely.
    if(member_array(GetRemoteChannel(verb), remote_chans) != -1
            && member_array(verb, local_chans) == -1){
        if (grepp(GetRemoteChannel(verb),":")) { //It's an IMC2 channel
            if(IMC2_D->getonline() != 1){
                return 1;
            }
            name = replace_string(name, " ", "");
            if( ob ) {
                IMC2_D->channel_out(name, rc, replace_string(replace_string(str,"$N ",""),"$O",target), emote);
            } else if ( targetkey ) {
                IMC2_D->channel_out(name, rc, replace_string(replace_string(str,"$N ",""),"$O",targetkey), emote);
            } else {
                IMC2_D->channel_out(name, rc, replace_string(str,"$N ",""), emote);
            }
        } else { //It's an I3 channel
            if( ob ) {
                SERVICES_D->eventSendChannel(name, rc, str, emote, convert_name(target), target_msg);
            } else {
                SERVICES_D->eventSendChannel(name, rc, str, emote, convert_name(targetkey), target_msg);;
            }
        }
    }
    return 1;
}

varargs void eventSendChannel(string who, string ch, string msg, int emote,
        string target, string targmsg) {
    object channeler = find_player(lower_case(who));
    int terminal;
    string prev = base_name(previous_object());
    string pchan,pmsg;
    string chatlayout = "%s %s<%s>%s %s";
    string emotelayout = "%s<%s>%s %s";
    //string chatlayout = "%s says, %s(%s)%s '%s'";
    //string emotelayout = "%s(%s)%s %s";

    if(prev == INSTANCES_D){
        terminal = 1;
    }
    if(prev == SERVICES_D) terminal = 1;
    if(prev == IMC2_D) terminal = 1;
    if(!terminal){
        string rch = GetRemoteChannel(ch);
        if(member_array(rch, remote_chans) == -1){
            INSTANCES_D->eventSendChannel(who,ch,msg,emote,target,targmsg);
        }
    }

    pchan=ch;
    if(!channeler) channeler = this_player();
    if(!strsrch(msg,"-.--. . -. -.-. --- -.. . -.. -.--.- ---...")) msg = unmorse(msg);
    if(targmsg && !strsrch(targmsg,"-.--. . -. -.-. --- -.. . -.. -.--.- ---..."))
        targmsg = unmorse(targmsg);

    if(this_player() && this_player() != channeler) channeler = this_player();

    if(!strsrch(base_name(previous_object()), "/realms/") ||
            !strsrch(base_name(previous_object()), "/open/")) {
        return 0;
    }

    if(member_array(ch, syschans) != -1) {
        emote = 0;
    }
    if(channeler){
        if(!CanTalk(channeler, ch) && member_array(ch, syschans) == -1){
            return;
        }
    }
    if( file_name(previous_object()) == SERVICES_D ||
            file_name(previous_object()) == IMC2_D) {
        ch = GetLocalChannel(ch);
        if( emote && sizeof(who)) msg = replace_string(msg, "$N", who);
    }
    else if( origin() != ORIGIN_LOCAL && previous_object() != master() &&
            file_name(previous_object()) != PARTY_D &&
            file_name(previous_object()) != UPDATE_D &&
            file_name(previous_object()) != INSTANCES_D &&
            member_array(ch, syschans) == -1){
        return;
    }
    prev = file_name(previous_object());
    if(!Channels[ch] && prev != SERVICES_D && prev != INSTANCES_D){
        return;
    }
    if( emote ) {
        object *obs;
        object ob;
        string this_msg, tmp;

        if( target && (ob = find_player(convert_name(target))) ) {
            target = ob->GetName();
        }

        //Colorize emote channels
        if (member_array(lower_case(ch),keys(tags)) >= 0){
            this_msg = tags[lower_case(ch)];
        } else {
            if(member_array(ch, local_chans) < 0 && (prev == IMC2_D ||
                        member_array(ch, (keys(INTERMUD_D->GetChannelList())
                                || ({}))) < 0)){
                this_msg = tags["default-IMC2"]; //Use the default IMC2 entry
            }
            else {
                this_msg = tags["default"]; //Use the default entry
            }
        }

        msg = replace_string(msg, "$N", who);
        if( target ) {
            msg = replace_string(msg, "$O", target);
            targmsg = replace_string(targmsg, "$N", who);
            targmsg = capitalize(replace_string(targmsg, "$O", "you"));
        }

        //Put together the channel emote message
        tmp = sprintf(emotelayout, this_msg, ch, "%^RESET%^", msg, time());

        //Store message in the history list
        eventAddLast(ch, tmp, pchan, msg);

        if(Channels[ch]){
            obs = filter(Channels[ch], (: $1 && !($1->GetBlocked($(ch))) :));
            foreach(object listener in obs) {
                int ignore;
                if(sscanf(who,"%s@%s",suspect,site) < 2) {
                    suspect = who;
                    site = "@"+mud_name();
                }
                else site = "@"+site;
                if( listener == ob ) continue;
                if(sizeof(listener->GetMuffed()))
                    foreach(string jerk in listener->GetMuffed()){
                        if(jerk && lower_case(suspect) == lower_case(jerk)){
                            ignore = 1;
                        }
                        if(jerk && lower_case(site[1..]) == lower_case(jerk)){
                            ignore = 1;
                        }
                    }
                if(listener->GetNoChanColors()) tmp = decolor(tmp);
                if(!ignore && CanListen(listener,ch) &&
                        !(listener->GetMuted(ch))){
                    listener->eventPrint(tmp, MSG_CHAN);
                }
                ignore = 0;
            }
            if( member_array(ob, obs) != -1 ) {
                if( ob && !(ob->GetBlocked(ch)) ) {
                    int ignore;
                    tmp = sprintf(emotelayout, this_msg, ch, "%^RESET%^", targmsg, time());
                    if(sizeof(ob->GetMuffed()))
                        foreach(string jerk in ob->GetMuffed()){
                            if(jerk && lower_case(suspect) == lower_case(jerk)) ignore = 1;
                            if(jerk && lower_case(site[1..]) == lower_case(jerk)) ignore = 1;
                        }
                    if(ob->GetNoChanColors()) tmp = decolor(tmp);
                    if(!ignore && CanListen(ob,ch)&& !(ob->GetMuted(ch)))
                        ob->eventPrint(tmp, MSG_CHAN, time());
                    ignore = 0;
                }
            }
        }
        suspect = "";
        site = "";
    }
    else {
        object *obs;
        string chancolor;

        //Colorize flag
        if (member_array(lower_case(ch),keys(tags)) >= 0) { //If there's an entry for the channel
            chancolor = tags[lower_case(ch)]; //Use it
        } else { //Otherwise
            if(member_array(ch, local_chans) < 0 && (prev == IMC2_D ||
                        member_array(ch, (keys(INTERMUD_D->GetChannelList())
                                || ({}))) < 0)){
                chancolor = tags["default-IMC2"]; //Use the default IMC2 entry
            }
            else {
                chancolor = tags["default"]; //Use the default entry
            }
        }
msg += " [" + ctime(time())[4..18] + "]";
        pmsg = msg;

        //Put together the channel emote message
        msg = sprintf(chatlayout, who, chancolor, ch, "%^RESET%^", pmsg, time());
        eventAddLast(ch, msg, pchan, pmsg, who, time());
     
        if(Channels[ch]) {
            obs = filter(Channels[ch], (: $1 && !($1->GetBlocked($(ch))) :));
            foreach(object ob in obs){
                int ignore;
                if(sscanf(who,"%s@%s",suspect,site) < 2) {
                    suspect = who;
                    site = "@"+mud_name();
                }
                else site = "@"+site;

                if(sizeof(ob->GetMuffed()))
                    foreach(string jerk in ob->GetMuffed()){
                        if(jerk && lower_case(suspect) == lower_case(jerk)) ignore = 1;
                        if(jerk && lower_case(site[1..]) == lower_case(jerk)) ignore = 1;
                    }
                if(ob->GetNoChanColors()) msg = decolor(msg);
                if(!ignore && CanListen(ob,ch)&& !(ob->GetMuted(ch)))
                    ob->eventPrint(msg, MSG_CHAN);

                ignore = 0;
                suspect ="";
                site = "";
            }
        }
    }
}

string *GetChannelList(string ch) {
    string *ret;
    object who;

    if( file_name(previous_object()) == SERVICES_D ) ch = GetLocalChannel(ch);
    else if( origin() != ORIGIN_LOCAL ) return ({});
    if( !Channels[ch] ) return ({});
    ret = ({});
    foreach(who in Channels[ch]) {
        if( !who || who->GetInvis() || who->GetBlocked(ch) )
            continue;
        ret += ({ who->GetName() });
    }
    return ret;
}

string *GetLocalChannels(){
    return copy(local_chans);
}

string GetLocalChannel(string ch) {
    if(ch && !strsrch(ch,"server0")){
        ch = replace_string(ch, "server01", "Server01");
        ch = replace_string(ch, "server02", "Server02");
    }
    if (sizeof(localchans[ch])) return localchans[ch];
    else return ch;
}

string GetRemoteChannel(string ch) {
    if (sizeof(remotechans[ch])) return remotechans[ch];
    else return ch;
}

int GetListening(object player, string ch){
    if(!Channels[ch] ||
            member_array(player, Channels[ch]) == -1) return 0;
    return 1;
}

string *GetChannels() { return sort_array(copy(keys(Channels)),1); }
string *GetSystemChannels() { return sort_array(copy(syschans),1); }
mapping GetTags() { return copy(tags); }
string GetTag(string ch) { return tags[ch]; }

Now all you need to do is replace /lib/secure/daemon/chat.c with this code above.
(Note, I may have also added a few more ctime() else where here and there that might be redundant, just erase them if you find them).

Or if you wish to DIY, then just do this:

Find (at around line 899)
Code: [Select]
pmsg = msg;
For date + time stamp, insert before it, this
Code: [Select]
msg += " [" + ctime(time())[4..18] + "]";
For time only stamp (no date), insert this instead:
Code: [Select]
msg += " [" + ctime(time())[11..18] + "]";

3
Open Chat / Merry X'mas and Happy New Year 2012 everyone!
« on: December 03, 2011, 08:35:02 pm »
Time really flies and it's good to see this forum is still active and the lib continued to update thanks for Cratylus and everybody.

Merry X'mas and Happy New Year!  ;)

4
Other / What's a good open source 2D MMORPG pack?
« on: October 30, 2011, 08:38:24 am »
Hey guys, I am in the middle of integrating DS3.6 to my SMF2 forum via Anyterm.

While I personally enjoy plain text MUD, most of my visitors will prefer at least some 2D graphical interaction. So I am going to also install a 2D MMORPG as an option for users.

What's a good open source 2D MMORPG package I can easily deploy (easily like DS) and use its already built-in default world?
I don't have time to develop anything but just want to install it, get it running, and provide a very basic social gaming platform for people.

Something like Ultima Online sort of staging would be perfect.
Eclipse has semi decent graphics http://www.touchofdeathforums.com/eclipse/media.php

A few other ones I came across include:
Mana World
Elsium
Kizare
OpenTibia
ExtremeWorlds

Other than Eclipse, all of them seem pretty sh1t actually. Any suggestions?

2D MMORPG, easy to install, open source, built-in default world. Preferably active community. Server needs to run on Linux. Client best to offer Windows, Linux and Mac systems, but if only Windows that's fine too. Preferably if the user can just use Explorer or Firefox to log on, otherwise requirement to install a small client software is acceptable too.

Thanks!

5
Open Chat / Happy new year 2011 everyone
« on: December 28, 2010, 02:26:03 am »
Hi everyone and happy new year!

For the past 3 or 4 years I notice it's usually around this time of the year I have the luxury of a couple of weeks off to play around with MUD. Here I am again except this year I'm busier. So just want to say a big hi and wish everyone a good year to come.

Keep up the good work and please keep this lib going!!

6
General / Advise RE strange clipping phenomenon
« on: February 17, 2009, 10:17:37 am »
I added replace_string and sscanf to wget in effect turning it into kind of text web browser. Nothing fancy, just download a .htm page, strip off all tags, then print out the result on to screen. A problem I encounter now is strange clipping phenomenon of text. I don't know how else to describe it than to illustrate it with a specific example.

Here is the code for cat10.c
Code: [Select]
#include <lib.h>
#include <daemons.h>
inherit LIB_DAEMON;
mapping FilesMap = ([]);

varargs int cmd(string str){
    object wget = new(WGET_D, this_object());
    if(!FilesMap) FilesMap = ([]);   
    FilesMap[wget] = this_player();
    wget->eventGet(str);
    return 1;
}

string refine(string kontent){
// who->eventPrint(kontent);

string *arr;
string *cap;
string *e;
    string s1,s2,s3, rep1,rep2, t1,t2,t3; string st,en;
string b;
string c1="<td class=\"TWFTTitle\">";
string c2="<td  class=\"TWFTBibleReading\">";
string *r1 = ({"","&nbsp;","&nbsp", "nbsp", "<br>", "<b>", "</b>", "-->", "\t"}); // Replace these strings with
string *r2 = ({""," ", " "," ","\n", "%^BOLD%^YELLOW%^", "%^RESET%^", "", ""}); // these strings.
string *start = ({"","<HEAD>","<script ", "<"}); // Remove everything between these and
string *end = ({"","</HEAD>","</script>", ">"}); // these (inclusive).

int feedback=3, count=1, checkcap=3;
string tmp=kontent;

//Replacing
count=1;
while(count < sizeof(r1)){
rep1=r1[count]; rep2=r2[count];
tmp=replace_string(tmp,rep1,rep2);
count++;
}

//Splicing
 count=1;
 while(count < sizeof(start)){
while(feedback>0){
feedback=sscanf(tmp,"%s"+start[count]+"%s"+end[count]+"%s", s1, s2, s3);
if(s2) {if(!s1) s1=""; if(!s3) s3=""; tmp=s1+s3;} //!!!!I reckon problem is here or line above!!!!
}
feedback=3; count++;
}


return(tmp);
}


varargs mixed eventReceiveWebData(string content, string file){
    object wget = previous_object();
    object who;
string finale;
    if(!FilesMap[wget] || !(who = FilesMap[wget])){
        map_delete(FilesMap, wget);
        return 1;
    }

finale=refine(content);
who->eventPrint(finale);
    return 1;
}


int help()
{
    write( @EndText
Syntax: cat10 <url>

EndText
    );
    return 1;
}

Here is what I typed in the game to use cat10 to access a web site
Quote
cat10 http://www.ucb.com.au/index.htm

Here is the actual HTML content of index.htm accessed on February 18th
Code: [Select]






 

 

 


<html>
<head>
  <link rel="stylesheet" type="text/css" href="styles.css">
  <script type="text/javascript" src="left.js"></script>
  <meta http-equiv="imagetoolbar" content="no">

  <title>UCB - Connecting Faith to Life</title>
</head>
<body>
<script type='text/javascript' src='exmplmenu_var.js'></script>
<script type='text/javascript' src='menu_com.js'></script>
<noscript>Your browser does not support script</noscript>

<TABLE WIDTH="100%"  BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR><TD>

<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" BACKGROUND="images/headbck.gif" WIDTH="100%">

<TR>
<TD><img alt=''  SRC="images/head1_1.gif" BORDER="0"><img alt=''  SRC="images/head1_2.gif" BORDER="0"><img alt=''  SRC="images/head1_3.gif" BORDER="0"><img alt=''  SRC="images/head1_4.gif" BORDER="0"><img alt=''  SRC="images/head1_5.gif" BORDER="0"><img alt=''  SRC="images/head1_6.gif" BORDER="0"><img alt=''  SRC="images/head1_7.gif" BORDER="0"><img alt=''  SRC="images/head1_8.gif" BORDER="0"><img alt=''  SRC="images/head1_9.gif" BORDER="0"</TD>
</TR>
</TABLE>

<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%" BGCOLOR="#FFFFFF">
<TR>
<TD><img alt=''  SRC="images/menublock.gif" WIDTH="780" HEIGHT="17" BORDER="0"></TD>
</TR>
</TABLE>


<TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0">

<TR>
<TD VALIGN="TOP" width="160px">

<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 ALIGN="LEFT">
<TR>
<TD><br /><A HREF="/" ONMOUSEOVER="on_img(p6,12);return true" ONMOUSEOUT ="on_img(p6,11);return true"><img alt=''  SRC="images/ic_home.gif" name="p6" WIDTH="100" HEIGHT="24" BORDER="0" VSPACE="0" HSPACE="0"></A></TD>
</TR>
<TR>
<TD><A HREF="https://secure.ucb.com.au" ONMOUSEOVER="on_img(p1,2);return true" ONMOUSEOUT="on_img(p1,1);return true"><img alt='' SRC="images/ic_donations.gif" name="p1" WIDTH="100" HEIGHT="24" BORDER="0" VSPACE="0" HSPACE="0"></A></TD>

</TR>
<TR>
<TD><A HREF="vacancies.htm" ONMOUSEOVER="on_img(p7,14);return true" ONMOUSEOUT="on_img(p7,13);return true"><img alt='' SRC="images/ic_vacancies.gif" name="p7" WIDTH="100" HEIGHT="24" BORDER="0" VSPACE="0" HSPACE="0"></A></TD>
</TR>
<TR>
<TD><A HREF="contact.htm" ONMOUSEOVER="on_img(p4,8);return true" ONMOUSEOUT ="on_img(p4,7);return true"><img alt=''  SRC="images/ic_contact.gif" name="p4" WIDTH="100" HEIGHT="24" BORDER="0" VSPACE="0" HSPACE="0"></A></TD>
</TR>
<TR>
<TD><A HREF="links.htm" ONMOUSEOVER="on_img(p5,10);return true" ONMOUSEOUT ="on_img(p5,9);return true"><img alt=''  SRC="images/ic_links.gif" name="p5" WIDTH="100" HEIGHT="24" BORDER="0" VSPACE="0" HSPACE="0"></A></TD>

</TR>
<TR>
<TD><A ONMOUSEOVER="on_img(p2,4);return true" ONMOUSEOUT ="on_img(p2,3);return true" TARGET='popup' HREF="#" ONCLICK="window.open('chat.htm#1', 'popup',
'toolbar=no,scrolling=auto,status=no,menubar=no,scrollbars=no,resizable=yes,width=650,height=550'); return false" ><img alt=''  SRC="images/ic_chat.gif" name="p2" WIDTH="100" HEIGHT="24" BORDER="0" VSPACE="0" HSPACE="0"></A></TD>
</TR>
<TR>
<TD>
<br /><br />

<A HREF="http://www.vision.org.au"><img alt='' TITLE="Visit VISION Online" SRC="images/logo_vision.jpg" WIDTH="105" HEIGHT="26" BORDER="0"></A><br /><br />
<A HREF="http://www.thewordfortoday.com.au"><img alt='' TITLE="The Word For Today" SRC="images/twftlogo.gif" WIDTH="100" HEIGHT="50" BORDER="0"></A><br /><br /><br />

<A HREF="http://www.ucbdirect.com.au"><img alt='' TITLE="Purchase Products Online" SRC="http://www.thewordfortoday.com.au/images/ucbdirect.gif" WIDTH="105" HEIGHT="52" BORDER="0"></A><br /><br />
<A HREF="http://www.prayforme.com.au"><img alt='' TITLE="Need Prayer" SRC="images/prayforme-logo.gif" WIDTH="103" HEIGHT="30" BORDER="0"></A><br /><br />
<A HREF="http://www.word4u2day.com.au"><img alt='' TITLE="Word 4 U 2day" SRC="images/W4U2Day-logo.gif" WIDTH="103" BORDER="0"></A><br /><br /><br />
<!-- <A HREF="needhelp.htm"><img alt=''  SRC="images/needhelp.gif" WIDTH="100" HEIGHT="51" BORDER="0"></A><br /> -->
</TD>
</TR>
</TABLE>

</TD>
<TD VALIGN="TOP">



<center>
<span class="cmteaser">
<span class="cmteaser">
<a href="http://www.vision.org.au/vis08b_main.htm" target="_blank"><img src="http://www.vision.org.au/images/Visionathon-banner_totala.gif" border="0" /></a><a href="https://secure.ucb.com.au" target="_blank"><img src="http://www.vision.org.au/images/Visionathon-banner_totalb.gif" border="0" /></a><br />

</center>
<br><center><a href="http://www.vision.org.au/vis08b_main.htm">Latest Updates</a> | <a href="http://www.vision.org.au/vis08b_why.htm">Why?</a> | <a href="http://www.vision.org.au/vis08b_gallery.htm">Gallery</a> | <a href="http://www.vision.org.au/vis08b_stories.htm">Testimonies</a> | <a target="_blank" href="https://secure.ucb.com.au/"><B>DONATE</B></a></br></center>

<div align="left"><br />
  <br />

</div>

<TABLE CELLPADDING="10" CELLSPACING="0" BORDER="0">
<TR>
<TD WIDTH="80%" VALIGN="TOP">


 






<br />
<table width="100%" border="0" cellspacing="0" cellpadding="2" align="left">
<tr>
<td width="100%" class="TWFTDate" align="left">Wednesday 18 February 2009</td>

</tr>

<tr>
  <td class="TWFTTitle">The privileges and responsibilities of membership</td>
</tr>
<tr align="center">
  <td>
    "<span class="TWFTScripture">You are...fellow citizens...members of God's household... a holy temple.</span>"<br />

    <span class="TWFTScriptureReference">Ephesians 2:19-21 NIV</span>   </td>
</tr>
<tr valign="top">
  <td class="TWFTContent">
  <p align="justify"> If your children stood outside your house pleading to get in, what would you think? Wouldn't you say, "Come in, you're my flesh and blood, I love you, you don't need to beg?" Well, we can come into God's presence at any time. We are "No longer foreigners...but fellow citizens...of the household of God...a holy temple" (Eph 2:19-21 NIV). What privileges:
<br/> (a) As "fellow citizens" we represent God's Kingdom on the earth. We are His ambassadors (See 2 Cor 5:20). "What does an ambassador do?" you ask. He stays in communication with his king, understands his will and makes sure it's carried out. He also knows he doesn't belong there permanently, so he lives ready for recall at a moment's notice. Getting the idea? (b) Because we belong to the "household of God" we can come confidently before God at any time, with any need, and know that we'll be received with love. God is the father you always hoped for and you are the child He always wanted. If you have any doubts, look at the cross; that's how much God values you. But remember, every family member is supposed to contribute, be loyal, and make sure the family's good name is protected. (c) We are "a holy temple". In the Old Testament God had a temple for His people, but now God has a people for His temple. The Bible says, "Do you not know that your body is a temple of the Holy Spirit, who is in you, whom you have received from God? You are not your own; you were bought at a price. Therefore honour God" (1 Cor 6:19-20 NIV).</p> </td>

  </tr>
  <tr>
<td  class="TWFTBibleReading">
  <b>Soulfood Bible Readings</b>&nbsp;&nbsp;<img src="images/bible.gif" width="17px" height="12px" border="0" /><br />
  Rom 12-14, Matt 15:15-28, Ps 28, Pr 5:3-6 </td>
  </tr>

<tr>
<td align="center">

  <p><span class="TWFTContent">
    <br />
    <br />
    To view any more information please visit our <b>NEW</b> Word For Today Site at<br />
    <a href="http://www.thewordfortoday.com.au?rf=ucb" target="_blank">http://www.thewordfortoday.com.au</a>
          <br />

    &copy; <a href="http://www.thewordfortoday.com.au/copyright.htm">Copyright</a> 1997-2008. All Rights Reserved. </span></p>
  <p>
        <a href="Gerald_Rowlands_prophecy_summary.pdf"><img src="images/geraldrowlands_prophecy1.gif" width="600" height="60" border="0" /></a></p></td>
</tr>
</table>


  </TD>


<td width="160" valign="top" align="center">
<br /><br /><br />
<P>
<CENTER><img alt=''  SRC="images/twftlogo.gif" WIDTH="100" HEIGHT="50" BORDER="0"></CENTER>
<br /><br />
Written by Bob & Debby Gass<br /><br />
<a href="author.htm">More about the author</a>
</td>

</tr>
</table>

</TD>
</TR>
</TABLE>
</TD></TR>
<TR><TD VALIGN="BOTTOM">
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%" BACKGROUND="images/bot_bck.gif">
<TR>
<TD VALIGN="BOTTOM" ALIGN="LEFT"><P><FONT FACE="Arial" SIZE="1" COLOR="#306898">&nbsp;<B>Phone</B> +61 (7) 3387 7300  <B>Facsimile </B>+61 (7) 3387 7333

<B>FREECALL</B>&nbsp;1800&nbsp;007&nbsp;770.  <a href="privacy.htm">Privacy Policy</a><br /></FONT><A HREF="http://www.ucb.com.au"><img alt=''  SRC="images/space.gif" WIDTH="103" HEIGHT="19" BORDER="0" HSPACE="0" VSPACE="0"></A></TD>
<TD VALIGN="BOTTOM"><img alt=''  SRC="images/tag.gif" WIDTH="246" HEIGHT="19" BORDER="0" HSPACE="0"></TD>
<TD ALIGN="RIGHT"><img alt=''  SRC="images/bot_corner.gif" USEMAP="#home" BORDER=0><MAP NAME="home"><AREA alt='' SHAPE=RECT COORDS="102, 21, 131, 50" HREF="/"></MAP></TD>
</TR>
</TABLE>


</TD></TR></TABLE>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>

<script type="text/javascript">
_uacct = "UA-1035608-1";
urchinTracker();
</script>
</body>
</html>


This is part of the result I receive on screen unfortunately (notice clipping around (a)):
Quote
Wednesday 18 February 2009



  The privileges and responsibilities of membership


 
    "You are...fellow citizens...members of God's household... a holy temple."
    Ephesians 2:19-21 NIV 


 
   If your children stood outside your house pleading to get in, what would you
think? Wouldn't you say, "Come in, you're my flesh and blood, I love you, you
don't need to beg?" Well, we can come into God's presence at any time. We are
"No longer foreigners...but fellow citizens...of the household of God...a holy
(a) As "fellow citizens" weWhat privileges:

represent God's Kingdom on the earth. We are His ambassadors (See 2 Cor 5:20).
"What does an ambassador do?" you ask. He stays in communication with his king,
understands his will and makes sure it's carried out. He also knows he doesn't
belong there permanently, so he lives ready for recall at a moment's notice.
Getting the idea? (b) Because we belong to the "household of God" we can come
confidently before God at any time, with any need, and know that we'll be
received with love. God is the father you always hoped for and you are the
child He always wanted. If you have any doubts, look at the cross; that's how
much God values you. But remember, every family member is supposed to
contribute, be loyal, and make sure the family's good name is protected. (c) We
are "a holy temple". In the Old Testament God had a temple for His people, but
now God has a people for His temple. The Bible says, "Do you not know that your
body is a temple of the Holy Spirit, who is in you, whom you have received from
God? You are not your own; you were bought at a price. Therefore honour God" (1
Cor 6:19-20 NIV).
 
 

  Soulfood Bible Readings 
  Rom 12-14, Matt 15:15-28, Ps 28, Pr 5:3-6

I traced my code and was able to localise scanf to be the source of problem but am unsure how to rectify the situation. I tried filtering out tabs (\t) and it didn't quite fix the problem either. Any advice would be greatly appreciated.

7
General / Query about Resolve and Wget
« on: February 12, 2009, 02:24:46 am »
I am trying to resolve domain name to IP using the command resolve. Somehow I keep getting "This mud is not using name resolution" response. Is there something I'm not doing right or haven't set up properly?

Quote
resolve http://www.geocities.com/appleguava1978/mediquest.html
This mud is not using name resolution.
>
resolve www.geocities.com/appleguava1978/mediquest.html
This mud is not using name resolution.
>
resolve www.geocities.com
This mud is not using name resolution.
>
resolve http://www.geocities.com
This mud is not using name resolution.
>
resolve http://www.geocities.com/appleguava1978
This mud is not using name resolution.
>
resolve www.geocities.com/appleguava1978
This mud is not using name resolution.
>


Also, I'm trying to download just a simple html page and nothing happens after I issued wget command. Could it be a virtual host? If that's the case, how do I obtain the actual address from command line within MUD?
Quote
wget http://www.geocities.com/appleguava1978/mediquest.html
Requesting url: http://www.geocities.com/appleguava1978/mediquest.html
>

Thanks a lot.

8
General / DikuMUD
« on: February 07, 2009, 08:27:03 pm »
Hi guys,

I have to say DS2 is by far the most well supported and documented library I've come across, and its underlying FluffOS has got to be one of the best out there also. The problem is I find some of the things I work on (closer to AI) demand a lot of computation resource which is becoming too taxing for an interpretor. For that reason I'm having a quick look at DikuMUD and derivatives. I can see there are many different variants: circlemud, merc, silly, smaug etc. Which of these is easiest to use and up to date (eg. still with ongoing improvements and not something that stopped back in 1996)? From what I can find in one night, Smaug seems to have a bit more online documents than the rest..

Thanks a lot.

9
General / Attempted to read '\0' into string
« on: January 17, 2009, 09:17:33 pm »
Hi guys I come across a minor technical problem. I'm trying to longcat a 250mb zip file which pretty much stores (not compressed) 40000 html files.

So I typed:
longcat Longman.zip

Error message:
Quote
2009.01.18-13.57,09
*Attempted to read '\0' into string!
Object: /secure/sefun/sefun at line 121

'<fake>' at /secure/save/creators/a/amylase (/<driver>) at line 0
'cmdAll' at /secure/save/creators/a/amylase (/lib/command.c) at line 162
'cmd' at /secure/cmds/creators/longcat at line 12
'read_file' at /secure/sefun/sefun at line 121
Trace written to /log/runtime

What I did next was I made a batch to copy all 40000 files onto one another under command line prompt ie. 1.html+2.html+3...+ k.html.. +40000.html and dumped the output to Result.txt

By doing that I hoped to eliminate any funny code that zip may have added to my previous Longman.zip. Then I issued this command
longcat Result.txt


This is what I receive on screen:
Quote
> Unable to read file /Result.txt

Any hints, tips please? Thanks alot. All I want is to longcat a series of text files lumped together but somehow it just won't happen. Any help would be greatly appreciated. Thanks.

10
General / How to access large file from nth byte
« on: November 09, 2008, 12:23:04 am »
Hi guys, a quick question about accessing files.  ???

I have a big dictionary file 250Mb containing roughly 12000 English words, definitions, tense and examples of use etc. It is literally a dictionary in text format. 12000 words and their information in tandem. Is there a function that will allow me to start accessing the file from any given byte? For example, I want to read 1000bytes starting from the 100,000,000th byte. I'm used to something called fseek in very old school Borland C. Is there something similar in LPC?  ???

Note, I don't want to seek line by line from the start of file every time - that takes too long. My NPC will be looking up lots of words back and forth and making associations etc. Starting from the start of the dictionary for each word will simply take too long.

Thanks!  :P

11
Code Vault / Eliza
« on: April 05, 2008, 05:26:16 am »
Hi guys. Over the last 1 - 2 years on and off I've looked around online for an LPC port of Eliza that would run under DS2. To my disappointment I haven't been able to find anything readily made for simple plug'n play. Came across quite a few different ports but nothing quite exactly for DS2. So over the next 7 or 8 months I'll probably start porting this good old basic one over. See how things go, I might try hook her up google search engine for additional amusement. Anyone got anything at hand already, to save me re-inventing the wheel?

Code: [Select]
1 KEY OFF : CLS
4 CLS
5 PRINT TAB(16)"**************************"
10 PRINT TAB(26)"ELIZA"
20 PRINT TAB(20)"CREATIVE COMPUTING"
30 PRINT TAB(18)"MORRISTOWN, NEW JERSEY":PRINT
40 PRINT TAB(19)"ADAPTED FOR IBM PC BY"
50 PRINT TAB(20)"PATRICIA DANIELSON AND PAUL HASHFIELD"
52 PRINT TAB(21)"BE SURE THAT THE CAPS LOCK IS ON
53 PRINT:PRINT TAB(16)"PLEASE DON'T USE COMMAS OR PERIODS IN YOUR INPUTS":PRINT
55 PRINT TAB(16)"*************************"
60 PRINT :PRINT :PRINT
80 REM*****INITIALIZATION**********
100 DIM S(36),R(36),N(36)
105 DIM KEYWORD$(36),WORDIN$(7),WORDOUT$(7),REPLIES$(112)
110 N1=36:N2=14:N3=112
112 FOR X = 1 TO N1: READ KEYWORD$(X): NEXT X
114 FOR X = 1 TO N2/2: READ WORDIN$(X):READ WORDOUT$(X): NEXT X
116 FOR X = 1 TO N3: READ REPLIES$(X): NEXT X
130 FOR X=1 TO N1
140 READ S(X),L:R(X)=S(X):N(X)=S(X)+L-1
150 NEXT X
160 PRINT "HI! I'M ELIZA. WHAT'S YOUR PROBLEM?"
170 REM ***********************************
180 REM *******USER INPUT SECTION**********
190 REM ***********************************
200 INPUT I$
201 I$="  "+I$+"  "
210 REM GET RID OF APOSTROPHES
220 FOR L=1 TO LEN(I$)
230 REM IF MID$(I$,L,1)="'"THEN I$=LEFT$(I$,L-1)+RIGHT$(I$,LEN(I$)-L):GOTO 230
240 IF L+4>LEN(I$)THEN 250
241 IF MID$(I$,L,4) <> "SHUT" THEN 250
242 PRINT "O.K. IF YOU FEEL THAT WAY I'LL SHUT UP...."
243 END
250 NEXT L
255 IF I$=P$ THEN PRINT "PLEASE DON'T REPEAT YOURSELF!":GOTO 170
260 REM ***********************************
270 REM ********FIND KEYWORD IN I$*********
280 REM ***********************************
300 FOR K=1 TO N1
320 FOR L=1 TO LEN (I$)-LEN (KEYWORD$(K))+1
340 IF MID$(I$,L,LEN(KEYWORD$(K)))<>KEYWORD$(K) THEN 350
341 IF K <> 13 THEN 349
342 IF MID$(I$,L,LEN(KEYWORD$(29)))=KEYWORD$(29) THEN K = 29
349 F$ = KEYWORD$(K): GOTO 390
350 NEXT L
360 NEXT K
370 K=36: GOTO 570:REM WE DIDN'T FIND ANY KEYWORDS
380 REM ******************************************
390 REM **TAKE PART OF STRING AND CONJUGATE IT****
400 REM **USING THE LIST OF STRINGS TO BE SWAPPED*
410 REM ******************************************
430 C$=" "+RIGHT$(I$,LEN(I$)-LEN(F$)-L+1)+" "
440 FOR X=1 TO N2/2
460 FOR L=1 TO LEN(C$)
470 IF L+LEN(WORDIN$(X))>LEN(C$) THEN 510
480 IF MID$(C$,L,LEN(WORDIN$(X)))<>WORDIN$(X) THEN 510
490 C$=LEFT$(C$,L-1)+WORDOUT$(X)+RIGHT$(C$,LEN(C$)-L-LEN(WORDIN$(X))+1)
495 L = L+LEN(WORDOUT$(X))
500 GOTO 540
510 IF L+LEN(WORDOUT$(X))>LEN(C$)THEN 540
520 IF MID$(C$,L,LEN(WORDOUT$(X)))<>WORDOUT$(X) THEN 540
530 C$=LEFT$(C$,L-1)+WORDIN$(X)+RIGHT$(C$,LEN(C$)-L-LEN(WORDOUT$(X))+1)
535 L=L+LEN(WORDIN$(X))
540 NEXT L
550 NEXT X
555 IF MID$(C$,2,1)=" "THEN C$=RIGHT$(C$,LEN(C$)-1):REM ONLY 1 SPACE
556 FOR L=1 TO LEN(C$)
557 IF MID$(C$,L,1)="!" THEN C$=LEFT$(C$,L-1)+RIGHT$(C$,LEN(C$)-L):GOTO 557
558 NEXT L
560 REM **********************************************
570 REM **NOW USING THE KEYWORD NUMBER (K) GET REPLY**
580 REM **********************************************
600 F$ = REPLIES$(R(K))
610 R(K)=R(K)+1:IF R(K)>N(K) THEN R(K)=S(K)
620 IF RIGHT$(F$,1)<>"*" THEN PRINT F$:P$=I$:GOTO 170
625 IF C$<>"   " THEN 630
626 PRINT "YOU WILL HAVE TO ELABORATE MORE FOR ME TO HELP YOU"
627 GOTO 170
630 PRINT LEFT$(F$,LEN(F$)-1);C$
640 P$=I$:GOTO 170
1000 REM *******************************
1010 REM *****PROGRAM DATA FOLLOWS******
1020 REM *******************************
1030 REM *********KEYWORDS**************
1049 REM *******************************
1050 DATA "CAN YOU ","CAN I ","YOU ARE ","YOU'RE ","I DON'T ","I FEEL "
1060 DATA "WHY DON'T YOU ","WHY CAN'T I ","ARE YOU ","I CAN'T ","I AM ","I'M "
1070 DATA "YOU ","I WANT ","WHAT ","HOW ","WHO ","WHERE ","WHEN ","WHY "
1080 DATA "NAME ","CAUSE ","SORRY ","DREAM ","HELLO ","HI ","MAYBE "
1090 DATA "NO","YOUR ","ALWAYS ","THINK ","ALIKE ","YES ","FRIEND "
1100 DATA "COMPUTER", "NOKEYFOUND"
1200 REM *********************************
1210 REM ***STRING DATA FOR CONJUGATIONS**
1220 REM *********************************
1230 DATA " ARE "," AM "," WERE "," WAS "," YOU "," I "," YOUR"," MY "
1235 DATA " I'VE "," YOU'VE "," I'M "," YOU'RE "
1240 DATA " ME "," YOU "
1300 REM ******************************
1310 REM *********REPLIES**************
1320 REM ******************************
1330 DATA "DON'T YOU BELIEVE THAT I CAN*"
1340 DATA "PERHAPS YOU WOULD LIKE TO BE LIKE ME*"
1350 DATA "YOU WANT ME TO BE ABLE TO*"
1360 DATA "PERHAPS YOU DON'T WANT TO*"
1365 DATA "DO YOU WANT TO BE ABLE TO*"
1370 DATA "WHAT MAKES YOU THINK I AM*"
1380 DATA "DOES IT PLEASE YOU TO BELIEVE I AM*"
1390 DATA "PERHAPS YOU WOULD LIKE TO BE*"
1400 DATA "DO YOU SOMETIMES WISH YOU WERE*"
1410 DATA "DON'T YOU REALLY*"
1420 DATA "WHY DON'T YOU*"
1430 DATA "DO YOU WISH TO BE ABLE TO*"
1440 DATA "DOES THAT TROUBLE YOU*"
1450 DATA "DO YOU OFTEN FEEL*"
1460 DATA "DO YOU OFTEN FEEL*"
1470 DATA "DO YOU ENJOY FEELING*"
1480 DATA "DO YOU REALLY BELIEVE I DON'T*"
1490 DATA "PERHAPS IN GOOD TIME I WILL*"
1500 DATA "DO YOU WANT ME TO*"
1510 DATA "DO YOU THINK YOU SHOULD BE ABLE TO*"
1520 DATA "WHY CAN'T YOU*"
1530 DATA "WHY ARE YOU INTERESTED IN WHETHER OR NOT I AM*"
1540 DATA "WOULD YOU PREFER IF I WERE NOT*"
1550 DATA "PERHAPS IN YOUR FANTASIES I AM*"
1560 DATA "HOW DO YOU KNOW YOU CAN'T*"
1570 DATA "HAVE YOU TRIED?"
1580 DATA "PERHAPS YOU CAN NOW*"
1590 DATA "DID YOU COME TO ME BECAUSE YOU ARE*"
1600 DATA "HOW LONG HAVE YOU BEEN*"
1610 DATA "DO YOU BELIEVE IT IS NORMAL TO BE*"
1620 DATA "DO YOU ENJOY BEING*"
1630 DATA "WE WERE DISCUSSING YOU--NOT ME."
1640 DATA "OH, I*"
1650 DATA "YOU'RE NOT REALLY TALKING ABOUT ME, ARE YOU?"
1660 DATA "WHAT WOULD IT MEAN TO YOU IF YOU GOT*"
1670 DATA "WHY DO YOU WANT*"
1680 DATA "SUPPOSE YOU SOON GOT*"
1690 DATA "WHAT IF YOU NEVER GOT*"
1700 DATA "I SOMETIMES ALSO WANT*"
1710 DATA "WHY DO YOU ASK?"
1720 DATA "DOES THAT QUESTION INTEREST YOU?"
1730 DATA "WHAT ANSWER WOULD PLEASE YOU THE MOST?"
1740 DATA "WHAT DO YOU THINK?"
1750 DATA "ARE SUCH QUESTIONS ON YOUR MIND OFTEN?"
1760 DATA "WHAT IS IT THAT YOU REALLY WANT TO KNOW?"
1770 DATA "HAVE YOU ASKED ANYONE ELSE?"
1780 DATA "HAVE YOU ASKED SUCH QUESTIONS BEFORE?"
1790 DATA "WHAT ELSE COMES TO MIND WHEN YOU ASK THAT?"
1800 DATA "NAMES DON'T INTEREST ME."
1810 DATA "I DON'T CARE ABOUT NAMES --PLEASE GO ON."
1820 DATA "IS THAT THE REAL REASON?"
1830 DATA "DON'T ANY OTHER REASONS COME TO MIND?"
1840 DATA "DOES THAT REASON EXPLAIN ANYTHING ELSE?"
1850 DATA "WHAT OTHER REASONS MIGHT THERE BE?"
1860 DATA "PLEASE DON'T APOLOGIZE!"
1870 DATA "APOLOGIES ARE NOT NECESSARY."
1880 DATA "WHAT FEELINGS DO YOU HAVE WHEN YOU APOLOGIZE?"
1890 DATA "DON'T BE SO DEFENSIVE!"
1900 DATA "WHAT DOES THAT DREAM SUGGEST TO YOU?"
1910 DATA "DO YOU DREAM OFTEN?"
1920 DATA "WHAT PERSONS APPEAR IN YOUR DREAMS?"
1930 DATA "ARE YOU DISTURBED BY YOUR DREAMS?"
1940 DATA "HOW DO YOU DO ...PLEASE STATE YOUR PROBLEM."
1950 DATA "YOU DON'T SEEM QUITE CERTAIN."
1960 DATA "WHY THE UNCERTAIN TONE?"
1970 DATA "CAN'T YOU BE MORE POSITIVE?"
1980 DATA "YOU AREN'T SURE?"
1990 DATA "DON'T YOU KNOW?"
2000 DATA "ARE YOU SAYING NO JUST TO BE NEGATIVE?"
2010 DATA "YOU ARE BEING A BIT NEGATIVE."
2020 DATA "WHY NOT?"
2030 DATA "ARE YOU SURE?"
2040 DATA "WHY NO?"
2050 DATA "WHY ARE YOU CONCERNED ABOUT MY*"
2060 DATA "WHAT ABOUT YOUR OWN*"
2070 DATA "CAN YOU THINK OF A SPECIFIC EXAMPLE?"
2080 DATA "WHEN?"
2090 DATA "WHAT ARE YOU THINKING OF?"
2100 DATA "REALLY, ALWAYS?"
2110 DATA "DO YOU REALLY THINK SO?"
2120 DATA "BUT YOU ARE NOT SURE YOU*"
2130 DATA "DO YOU DOUBT YOU*"
2140 DATA "IN WHAT WAY?"
2150 DATA "WHAT RESEMBLANCE DO YOU SEE?"
2160 DATA "WHAT DOES THE SIMILARITY SUGGEST TO YOU?"
2170 DATA "WHAT OTHER CONNECTIONS DO YOU SEE?"
2180 DATA "COULD THERE REALLY BE SOME CONNECTION?"
2190 DATA "HOW?"
2200 DATA "YOU SEEM QUITE POSITIVE."
2210 DATA "ARE YOU SURE?"
2220 DATA "I SEE."
2230 DATA "I UNDERSTAND."
2240 DATA "WHY DO YOU BRING UP THE TOPIC OF FRIENDS?"
2250 DATA "DO YOUR FRIENDS WORRY YOU?"
2260 DATA "DO YOUR FRIENDS PICK ON YOU?"
2270 DATA "ARE YOU SURE YOU HAVE ANY FRIENDS?"
2280 DATA "DO YOU IMPOSE ON YOUR FRIENDS?"
2290 DATA "PERHAPS YOUR LOVE FOR FRIENDS WORRIES YOU."
2300 DATA "DO COMPUTERS WORRY YOU?"
2310 DATA "ARE YOU TALKING ABOUT ME IN PARTICULAR?"
2320 DATA "ARE YOU FRIGHTENED BY MACHINES?"
2330 DATA "WHY DO YOU MENTION COMPUTERS?"
2340 DATA "WHAT DO YOU THINK MACHINES HAVE TO DO WITH YOUR PROBLEM?"
2350 DATA "DON'T YOU THINK COMPUTERS CAN HELP PEOPLE?"
2360 DATA "WHAT IS IT ABOUT MACHINES THAT WORRIES YOU?"
2370 DATA "SAY, DO YOU HAVE ANY PSYCHOLOGICAL PROBLEMS?"
2380 DATA "WHAT DOES THAT SUGGEST TO YOU?"
2390 DATA "I SEE."
2400 DATA "I'M NOT SURE I UNDERSTAND YOU FULLY."
2410 DATA "COME COME ELUCIDATE YOUR THOUGHTS."
2420 DATA "CAN YOU ELABORATE ON THAT?"
2430 DATA "THAT IS QUITE INTERESTING."
2500  REM *************************
2510 REM *****DATA FOR FINDING RIGHT REPLIES
2520 REM *************************
2530 DATA 1,3,4,2,6,4,6,4,10,4,14,3,17,3,20,2,22,3,25,3
2540 DATA 28,4,28,4,32,3,35,5,40,9,40,9,40,9,40,9,40,9,40,9
2550 DATA 49,2,51,4,55,4,59,4,63,1,63,1,64,5,69,5,74,2,76,4
2560 DATA 80,3,83,7,90,3,93,6,99,7,106,6                                                                                                           

12
Dead Souls Support / Sscanf peculiarity
« on: January 06, 2008, 03:30:55 am »
Hi there, just wondering if someone can help me with a quick problem.

I'm experiencing odd behaviour with sscanf, possibly more a bug I've made somewhere than actual defect in sscanf. I notice when I feed sscanf a pattern it cannot find, it terminates and produces this error message:

Code: [Select]
*Bad argument 1 to sscanf
Expected: string Got: 0.
Object: /secure/cmds/creators/cat4 at line 36

'' at /secure/save/creators/a/amylase (/) at line 0
'cmdAll' at /secure/save/creators/a/amylase (/lib/command.c) at line 162
'cmd' at /secure/cmds/creators/cat4 at line 36
Trace written to /log/runtime

To be more specific, this is the entire piece of code (not that big). The command just strips .htm files of all tags and prints out a readable, text-only version of the file:
Code: [Select]
#include <lib.h>
inherit LIB_DAEMON;

mixed cmd(string str) {
    string *arr;
    string tmp="", s1,s2,s3, rep1,rep2; string st,en;

string *r1 = ({"","&nbsp;","&nbsp", "nbsp", "<br>"}); // Replace these strings with
string *r2 = ({""," ", " "," ","\n"}); // these strings.
string *start = ({"","<HEAD>","<script ", "<"}); // Remove everything between these and
string *end = ({"","</HEAD>","</script>", ">"}); // these (inclusive).
int feedback=3, count=1;

    if( !str ) return "You must specify a file to cat.";
    else str = absolute_path((string)this_player()->query_cwd(), str);
    if( !file_exists(str) ) return "File " + str + " not found.";
    else if( !(tmp = read_file(str)) )
        return "Unable to read file " + str + ".";
    arr = explode(tmp,"\n");

//Replacing
count=1;
while(count < sizeof(r1)){
rep1=r1[count]; rep2=r2[count];
tmp=replace_string(tmp,rep1,rep2);
count++;
}

//Splicing
 count=1;
 while(count < sizeof(start)){
while(feedback>2){
feedback=sscanf(tmp,"%s"+start[count]+"%s"+end[count]+"%s", s1, s2, s3);
tmp=s1+s3;
}
feedback=3; count++;
}

write_file("webcat.tmp", tmp, 1); // Just writing final output into a file. Works fine for me as administrator but may be denied if player does not have enough disk write privilege. Anyway if that's the case just bring the whole more.c in here or temporarily unguard them etc. and either way should fix things up.
this_player()->eventForce("more webcat.tmp");

    return 1;
}

int help() {
    message("help", "Syntax: <webcat> [file | URL]>\n\n"     
      "Shows text content of a HTML file locally on the web.\n\n"
  "Eg1. webcat test.htm\n"
      "Eg2. webcat http://www.domain.com/index.htm",
      this_player());
}

Works fine with files that contain capital <HEAD> label. But as soon as I feed this command a file with small case <head>, it terminates abnormally with the error message I got up the top. Or if I replace HEAD in the command with HHHHHHHHHH, it again pukes right away.

Any advice please anyone. Thanks a lot.

13
Code Vault / Quick summary of progs
« on: January 01, 2008, 06:39:54 am »
Happy new year everyone! Thanks for all the help up to this point. Thought I might spend new year eve summarising a small handful of progs I got working over the last few years, after harrassing various people on and offline for directions.

I took a series of snap shots to quickly demonstrate what each prog is capable of doing and along with working codes attached. So here they are at this URL:
http://www.geocities.com/appleguava1978/mediquest.html

Things you'll find include the following:
1. Teleport to any location
2. Robot that reads the environment eg. items, livings, exits, messages...
3. Force increase maximum HP
4. Retrieve Yahoo astrology via sockets (inspired by Tricky's baseball socket tutorial)
5. Display ASCII art through 'look at'
6. Show health in bargraph (courtesy of Tigwyk)
7. Add timestamp to end of intermud dialogues (courtesy of Tricky)

All tested to work fine on DS 2.6.1

14
Hi everyone. As I upgraded DS2 version 2.1 on my machine to 2.4.2 today, I received the following error messages on executing teleport.c

Error message from within the game:
Quote
2007.05.10-23.43
*Can't catch eval cost too big error.
Object: /secure/sefun/sefun at /secure/sefun/load_object.c:14

'<function>' at /secure/save/creators/a/amylase (<function>) at /:0
'cmdAll' at /secure/save/creators/a/amylase (/lib/command.c) at line 160
'cmd' at /secure/cmds/creators/teleport at line 65
'load_object' at /secure/sefun/sefun at /secure/sefun/load_object.c:14
Trace written to /log/runtime

From \ds\win32\driver.exe c:\ds\lib\secure\cfg\mudos.cfg this is reported:
Quote
object /secure/sefun/sefun: eval_cost too big 5000000
object /secure/daemon/master: eval_cost too big 5000000

If I repeated the command "teleport" three times in a row, it worked better and better each time (exits later and later). For example first go it would display rooms 1 to 30 and exits with error. Second time it would display rooms 1 - 100 and then exits. Third time it would display up to room 150 then exits. By fourth time around and beyond, there was no longer this error message and I could teleport to various places successfully. If I then reboot and try issuing same command, back comes error message on first three attempts. Interestingly this time the exit points are different to previously (ie. previous exits at room 30, 100, 150; but when repeated, it exits at different rooms eg. rooms 80, 110, 160). Such inconsistency makes me suspect there could be instability with the driver. Teleport used to work smoothly in DS version 2.1 without any error message. Any valuable advice from anyone would be greatly appreciated. Thanks! The code for teleport.c is here http://lpmuds.net/forum/index.php?topic=225.0

15
Code Vault / Horoscope.c with daily Yahoo astrology update
« on: December 29, 2006, 03:20:17 pm »
Mudlib: DeadSouls 2.1 on Windows XP
Driver: MudOS v22.2b14
Filename: /secure/cmds/creators/horoscope.c

Hi guys. I've been trying to learn a bit of basics about sockets as well as string manipulation (hopefully in the future be able to come up with a chatterbot that is able to reside in MUD and also access internet resources). Anway, to start off Cratylus and Tricky suggested looking into dsversion.c which was subsequently torn apart and converted to horoscope.c by me. Cut a long story short: horoscope.c will try to extract date (in words or numbers) out of any given sentence, using that as birthday connect to Yahoo astrology, and print out whatever ridiculous advice is out there for the corresponding starsign.

Thanks everyone for answering my questions on ds channel and this forum. Feel free to do anything you please with my code. Please note socket part remains largely unchanged from the original dsversion.c

Code: [Select]
/* /secure/cmds/creators/horoscope.c
*  modified by Amylase 2006 from original dsversion.c
*  of DS2 Mudlib 2.1
*
*   Horoscope.c connects to http://HTTP_HOST/HTTP_PATH+starsign:HTTP_PORT
*   Currently it is set up to connect to port 80 of
*   http://astrology.yahoo.com/astrology/general/dailyextended/starsign where HTTP_HOST, HTTP_PATH and
*   HTTP_PORT have been pre#defined. String starsign is substituted by one of twelve starsigns
*   based on the argument supplied by initiator of this command.
*
*   A few ifs, loops and search functions in cmd() serve to extract numeric day and month out of given argument and
*   translate to appropriate string starsign for lookup.
*   Connection is negotiated by openHTTPConnection().
*   Http content is then retrieved by sendHTTPGet() and stored in the giant global string 'results'.
*   ProcessHTTPResult() explodes results into individual lines (NOTES_DELIM) and stores them in string array 'parts'.
*   ADVANCE_FROM_CAPTUREth line after first occurence of CAPTURE_STRING is printed.
*   For example in the case of Yahoo astrology, advice is 8th line after 'Provided by Astrology.com' (where
*   'Provided by Astrology.com' is zero-th line).
*
*   Syntax: horoscope [starsign | birthdate]
*   For example: 'horoscope gemini' or 'horoscope 20/6/1970' will both bring up today's advice for gemini.
*   Dates in words are also accepted. For example 'horoscope twentieth of June' yields the same result.
*   In fact you may even follow 'horoscope' with any sentence as long as it contains some sort of date to be digested.
*   For example: 'horoscope My date of birth is twentieth of June and I expect a present from you' will be accepted.
*   When conventional numeric date is supplied, dd/mm/yyyy is preferred over mm/dd/yyyy.
*   Minimal error correction mechanism has been implanted to recognise and correctly handle just over half the cases of mm/dd/yyyy.
*   When no argument is supplied, ie. simply typing 'horoscope' and enter, a random starsign will be used.
*  
* Necessary inputs/definitions:
* HTTP_HOST, HTTP_PATH, HTTP_PORT
* CAPTURE_STRING
* ADVANCE_FROM_CAPTURE
*
* Useful outputs:
* int day - day of birthdate
* int month - month of birthdate
* string starsign - corresponding starsign based on birthdate
* string results - entire html code for requested webpage
* string *words - individual words (all in small case) of the sentence after 'horoscope'
* string advice - contains the output advice
*/

#include <lib.h>
#include <network.h>
#include <socket_err.h>
#include <message_class.h>

inherit LIB_DAEMON;

#define HTTP_ADDRESS "216.109.127.241"
#define HTTP_HOST "astrology.yahoo.com"
#define HTTP_PORT 80
#define HTTP_PATH "/astrology/general/dailyextended/"
#define NOTES_DELIM "\n"
#define CAPTURE_STRING "Provided by Astrology.com"
#define ADVANCE_FROM_CAPTURE 8

#define SOCK_FIND 0
#define SOCK_CONNECTING 1
#define SOCK_CONNECTED 2
#define SOCK_DISCONNECTED 3
#define SOC_ERROR 4

int socket;
int status;
object player;
string starsign="";
string results;
string advice="";
void sendHTTPGet();
int http_file_found;

void ProcessHTTPResult()
{
    int i = 0, advance=0;
    string * parts;

    parts = explode( results, NOTES_DELIM );

    foreach(string line in parts){
if(advance>0 && advance<ADVANCE_FROM_CAPTURE+2) {advance++;}
if(advance==ADVANCE_FROM_CAPTURE+1) {player->eventPrint( ""+line); advice=line;} //This is where our final target is printed 
if(strsrch(line, CAPTURE_STRING) > -1) advance=1;
}
}

void read_callback( int fd, mixed message )
{
    if( !http_file_found ){
if( message[9..11] != "200" ){
    player->eventPrint( "Error, unable to locate page requested." );

    http_file_found = 3;
}
else
{
//     player->eventPrint( message ); Uncomment this to see http header debug
    http_file_found = 1;
}
    }
    else if( http_file_found == 1 ){
//player->eventPrint( message );
results += message;
    }
    else{

    }
}

void write_callback( int fd )
{
#ifdef _DEBUG
    player->eventPrint("Connected!");
#endif
    status = SOCK_CONNECTED;
    http_file_found = 0;
    sendHTTPGet();
}

void close_callback( int fd )
{
    if( status == SOCK_CONNECTED )
    {
// Process HTML here
#ifdef _DEBUG
player->eventPrint("Connection closed by host.");
#endif
ProcessHTTPResult();
    }
    if( status == SOCK_CONNECTING )
    {       
player->eventPrint("Connection attempt failed.");
    }
    socket_close( fd ) ;
    status = SOCK_DISCONNECTED;
}

void sendHTTPGet()
{
    string str ="GET "+HTTP_PATH+starsign+" HTTP/1.0\r\n"+
    "Host: "+HTTP_HOST+"\r\n" +
    "User-Agent: "+ player->GetName() + "@" + mud_name() + " " +
    mudlib()+ "/" + mudlib_version() +" ("+ query_os_type()+";) "+
    version() + "\r\n\r\n";
    int result = 0;
    results = "";
#ifdef _DEBUG
    player->eventPrint("Sending HTTP get request..." );
#endif
    if( status == SOCK_CONNECTED )
    {
result = socket_write( socket, (string)str );
#ifdef _DEBUG
player->eventPrint( "HTTP request sent to " + socket + " result = "+result );
#endif
    }
}

int openHTTPConnection()
{

    int sock, sc_result;
    string error;
    status = SOCK_FIND;


    status = SOCK_CONNECTING;
    sock = socket_create( STREAM, "read_callback", "close_callback" ) ;
    if (sock < 0) {
switch( sock )
{
case EEMODENOTSUPP :
    error = "Socket mode not supported.\n" ;
    break ;
case EESOCKET :
    error = "Problem creating socket.\n" ;
    break ;
case EESETSOCKOPT :
    error = "Problem with setsockopt.\n" ;
    break ;
case EENONBLOCK :
    error = "Problem with setting non-blocking mode.\n" ;
    break ;
case EENOSOCKS :
    error = "No more available efun sockets.\n" ;
    break ;
case EESECURITY :
    error = "Security violation attempted.\n" ;
    break ;
default :
    error = "Unknown error code: " + sock + ".\n" ;
    break ;
}
notify_fail( "Unable to connect, problem with socket_create.\n"
  "Reason: " + error ) ;
return 0 ;
    }
#ifdef _DEBUG
    write("Attempting to connect to "+HTTP_HOST+ " on port "+ HTTP_PORT + "\n");
#endif
    sc_result = socket_connect( sock, HTTP_ADDRESS + " " + HTTP_PORT,
      "read_callback", "write_callback" ) ;
    if( sc_result != EESUCCESS )
    {
status = SOCK_DISCONNECTED;
notify_fail( "Failed to connect.\n" ) ;
return 0 ;
    }
    else{
#ifdef _DEBUG
player->eventPrint( "Socket connecting..." );
#endif
    }

    socket = sock;
    return 1;
}

void hostResolved( string address, string resolved, int key )
{
    if( !resolved ){
#ifdef _DEBUG
player->eventPrint( "Unable to resolve "+address );
#endif
return;
    }
#ifdef _DEBUG
    player->eventPrint( "Resolved "+address+" to "+ resolved );
#endif
    player->eventPrint( "Retrieving updated release notes from: http://www.dead-souls.net\n" );
    openHTTPConnection();
}

void resolveHost()
{
    resolve( HTTP_HOST, "hostResolved" );
}

mixed cmd(string args) {
string arg1="",s1="",s2="";
int j=0, k=1, day=0, month=0;
string *months = ({ "","january", "february","march","april","may","june","july","august","september","october", "november","december"});
string *days = ({"","first","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth","eleventh","twelvethe","thirteenth","fourteenth","fifteenth","sixteenth","seventeenth","eighteenth","nineteenth","twentieth","twenty-first","twenty-second","twenty-third","twenty-fourth","twenty-fifth","twenty-sixth","twenty-seventh","twenty-eighth","twenty-nineth","thirtieth", "thirty-first"});
string *signsarr = ({ "","aries", "taurus","gemini","cancer","leo","virgo","libra","scorpio","sagittarius","capricorn","aquarius","pisces" });
string * words;
string * subdate;

    player = previous_object();
    if(args) {
arg1 = lower_case(args);
// player->eventPrint( "Complete argument = "+arg1);
words = explode(arg1," ");

//player->eventPrint("Word "+j+" = "+words[j]);

// Extracts day and month out of a birthday that may have been given in words
for(k=1;k<13;k++){  if( member_array(months[k], words) > -1 ) month=k;
if( member_array(signsarr[k], words) > -1 ) starsign=signsarr[k];
}
for(k=1;k<32;k++) if( member_array(days[k], words) > -1 || member_array(replace_string(days[k],"-",""), words) > -1) day=k;

// Extracts numeric day and month out of a birthday given in the format of dd/mm or mm/dd
for(j=0;j<sizeof(words);j++) {
if(sscanf(words[j],"%s/%s",s1,s2)>0){
subdate=explode(words[j],"/");
day=atoi(s1);
month=atoi(subdate[1]);
if(month>12) {day=month; month=atoi(s1);} //Here's my half-hearted effort at correcting some cases of mm-dd-yy
}//end sscanfif
}//endfor

/* if(month>0 && day>0) player->eventPrint("DAY ="+day+"       MONTH="+month);
>0 makes sure both month and day are both valid numbers and not other incidental strings or nothing  */

// Determine starsign from date of birth
if( (month==3 && day>=21) || (month==4 && day<=19)) {starsign="aries";} //Aries 21/3 - 19/4
if( (month==4 && day>=20) || (month==5 && day<=20)) {starsign="taurus";} //Taurus 20/4 - 20/5
if( (month==5 && day>=21) || (month==6 && day<=21)) {starsign="gemini";} //Gemini 21/5 - 21/6
if( (month==6 && day>=22) || (month==7 && day<=22)) {starsign="cancer";} //Cancer 22/6 - 22/7
if( (month==7 && day>=23) || (month==8 && day<=22)) {starsign="leo";} //Leo 23/7 - 22/8
if( (month==8 && day>=23) || (month==9 && day<=22)) {starsign="virgo";} //Virgo 23/8 - 22/9
if( (month==9 && day>=23) || (month==10 && day<=22)) {starsign="libra";} //Libra 23/9 - 22/10
if( (month==10 && day>=23) || (month==11 && day<=21)) {starsign="scorpio";} //Scorpio 23/10 - 21/11
if( (month==11 && day>=22) || (month==12 && day<=21)) {starsign="sagittarius";} //Sagittarius 22/11 -21/12
if( (month==12 && day>=22) || (month==1 && day<=19)) {starsign="capricorn";} //Capricorn 22/12 - 19/1
if( (month==1 && day>=20) || (month==2 && day<=18)) {starsign="aquarius";} //Aquarius 20/1 - 18/2
if( (month==2 && day>=19) || (month==3 && day<=20)) {starsign="pisces";} //Pisces 19/2 - 20/3

// player->eventPrint("Starsign = "+starsign);

} //endifargs
    else {starsign = signsarr[random(12)];} //Assign random starsign for nil argument

    //resolveHost();
    openHTTPConnection();
    return 1;
}

string GetErorMessage() {
    return "There was a problem";
}

string GetHelp() {
    return (
  "/secure/cmds/creators/horoscope.c \n\n"+
  "Shows today's advice from Yahoo astrology\n"+
  "Syntax: horoscope [starsign | birthdate (in words or dd/mm/yyyy) | any sentence that contains either starsign or birthdate]\n"+
  "Nil paramater for random advice.");
}

Pages: [1] 2