Welcome to the Achaea Forums! Please be sure to read the Forum Rules.

Parsers

CidusiiCidusii Member Posts: 345 ✭✭✭✭✭ - Grand Achaean
Just wondering what other people think regarding writing scripts for Achaea:

Is it better to have 1 parser scanning received lines of text for all of the potential trigger lines out there for Achaea, or to split it up into multiple parsers so that each parser is only looking for a number of those lines? At the moment I have multiple parsers: 1 for eating afflictions, 1 for sip afflictions, 1 for applying afflictions, 1 for smoking afflictions, and one that checks for miscellaneous stuff such as prone/transfixed etc. Not sure if it's the best way to go in the long run however.

Comments

  • IocunIocun Member Posts: 3,506 @@ - Legendary Achaean
    I'm not quite sure what you mean by "parser" in this context. A trigger? A script that takes input from triggers?
  • CidusiiCidusii Member Posts: 345 ✭✭✭✭✭ - Grand Achaean
    Basically a function that checks for trigger lines.

    I guess as an example from the HTML5 basic sipper source code:

    parse: function (event, message) {
                if (message.match(/^The (?:elixir|tonic) heals and soothes you\.$/gm) ||
                    message.match(/^Your mind feels stronger and more alert\.$/gm) ||
                    message.match(/^The (?:elixir|tonic) flows down your throat without effect.$/gm))
                {
                    IRE_AutoSipper.can_sip = false;
                }
    
                if (message.match(/^You may drink another health or mana elixir or tonic\.$/gm))
                {
                    IRE_AutoSipper.can_sip = true;
                    IRE_AutoSipper.check();
                }

  • IocunIocun Member Posts: 3,506 @@ - Legendary Achaean
    edited January 2014
    Does that mean you just have a single trigger to match anything, have it call such parsing functions and then have the parsing functions determine what that line actually is and how to handle it?

    I guess it depends on your client, but in most cases, this would be much less efficient than having individual triggers for all the effects and letting the client itself handle the parsing.

    PS. I'm probably just revealing my ignorance of how the HTML5 client works though. I guess I won't be able to answer your question without more understanding of that.
  • CidusiiCidusii Member Posts: 345 ✭✭✭✭✭ - Grand Achaean
    I'm actually not sure. I've just been slowly retrofitting the auto sipper source code to do what I need. Basically when I load up for example my Herb balance function it does this:

    $(document).on("onMsgRecv.autoHerb", autoHerb.parse);

    Then in the parse function it checks the function against a number of if/elseif statements matching messages to see what that message is. I'm not sure if that counts as a single trigger matching anything as you mentioned or what, as I've basically been learning HTML5 on the fly.
  • VadimusesVadimuses Member Posts: 1,104 @ - Epic Achaean
    I didn't realize html5's client was like this, but if it is, that is insane. That is just throwing away years of good MUD client design away and not very friendly to work with at all.
  • CidusiiCidusii Member Posts: 345 ✭✭✭✭✭ - Grand Achaean
    @Vadimuses I'm not an experienced coder or anything and was just attempting to reverse engineer the source code they gave for the autosipper. There are probably much more efficient ways of doing things! How does mudlet handle parsing for lines?
  • VadimusesVadimuses Member Posts: 1,104 @ - Epic Achaean
    I was just commenting on the design of the client. In Mudlet this is far to deal with because there are actual UI items for you to work with and not build your own if chains and other ways of parsing.

    Good luck on your project
  • TectonTecton The Garden of the GodsAdministrator Posts: 2,507 Admin
    Vadimuses said:
    I didn't realize html5's client was like this, but if it is, that is insane. That is just throwing away years of good MUD client design away and not very friendly to work with at all.
    Wasn't necessarily like that, that was one way of doing it to keep it all contained in a single redistributable package. We've updated the way we handle packages in the new version of the client, so packaging things is a lot more straightforward.
  • VadimusesVadimuses Member Posts: 1,104 @ - Epic Achaean
    Oh, excellent.
Sign In to Comment.