• Multiuser chat room

    From Ice@VERT to All on Thu Jun 9 12:15:00 2011
    so i want to make a multiplayer "mud" game, and was gonna use tele-arena as my model, since i rewrote it form worldgroup in C i figured i would make a synchronet port, that gave me 2 options, C or JS, and since i never played
    with JS before i took on a learning project :)

    anyhow, to better aid myself i broke the project into steps, first playing
    with the ini databasing which i think i pretty much got the hang of, and now
    im working on parsing my input routines.

    here's what i got thus far:

    while(1)
    {
    var cmd = console.getstr().toLowerCase();

    if((cmd=="exit") || (cmd=="x")) exit();
    else
    {
    console.writeln(format("You typed: %s",cmd));
    console.crlf();
    console.print(":");
    }
    }

    while that does work for single word commands i wanted to better learn how to parse it for multiple character commands.

    so like if i wanted to whisper to a user like "whisper <user> <message>"

    in C i would go:

    if((argc==3) && (!stricmp(argv[0],"whisper")))
    {
    whisper(argv[1],argv[2]);
    }

    can anyone point me in the direction for a better formula to grab
    pieces of the text and break it into subparts like above?

    i tried this way:

    var cmd = console.getstr().toLowerCase();

    console.writeln(format("You typed: %s",cmd));

    var parsed = cmd.split(" ",3);

    console.writeln(format("I parsed it to: %s %s %s",parsed[0],
    parsed[1],
    parsed[2]));

    which did seem to work but just seemed like a hard way to do something easier. any thoughts?

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Digital Man@VERT to Ice on Thu Jun 9 13:59:00 2011
    Re: Multiuser chat room
    By: Ice to All on Thu Jun 09 2011 04:15 pm

    so i want to make a multiplayer "mud" game, and was gonna use tele-arena as my model, since i rewrote it form worldgroup in C i figured i would make a synchronet port, that gave me 2 options, C or JS, and since i never played with JS before i took on a learning project :)

    anyhow, to better aid myself i broke the project into steps, first playing with the ini databasing which i think i pretty much got the hang of, and
    now im working on parsing my input routines.

    here's what i got thus far:

    while(1)
    {
    var cmd = console.getstr().toLowerCase();

    if((cmd=="exit") || (cmd=="x")) exit();
    else
    {
    console.writeln(format("You typed: %s",cmd));
    console.crlf();
    console.print(":");
    }
    }

    while that does work for single word commands i wanted to better learn how to parse it for multiple character commands.

    so like if i wanted to whisper to a user like "whisper <user> <message>"

    in C i would go:

    if((argc==3) && (!stricmp(argv[0],"whisper")))
    {
    whisper(argv[1],argv[2]);
    }

    can anyone point me in the direction for a better formula to grab
    pieces of the text and break it into subparts like above?

    i tried this way:

    var cmd = console.getstr().toLowerCase();

    console.writeln(format("You typed: %s",cmd));

    var parsed = cmd.split(" ",3);

    console.writeln(format("I parsed it to: %s %s %s",parsed[0],
    parsed[1],
    parsed[2]));

    which did seem to work but just seemed like a hard way to do something easier. any thoughts?

    That's a pretty common method of JS string parsing. See https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String for the JS String reference. Synchronet doesn't add any new/different string parsing classes.

    digital man

    Synchronet "Real Fact" #18:
    The first Synchronet BBS (Vertrauen) went live in July of 1991 (replacing WWIV).

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Tracker1@VERT/TRN to Digital Man on Sat Jul 2 19:30:00 2011
    On 6/9/2011 5:59 PM, Digital Man wrote:
    That's a pretty common method of JS string parsing. See https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String for
    the JS String reference. Synchronet doesn't add any new/different string parsing classes.

    There is pretty good regex support, could also do a custom buffer via inkey loop, which would also allow for listening for events while typing...

    --
    Michael J. Ryan - http://tracker1.info/

    ---
    þ Synchronet þ Roughneck BBS - telnet://roughneckbbs.com - www.roughneckbbs.com