Alaparser

by Alathon
[Share] [Zip]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://Alathon.Alaparser##version=11

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://Alathon.Alaparser##version=11

138 downloads
Version v0.2
Date added: Jul 31 2012
Last updated: Aug 10 2012
3 fans
Command parser for MUDs [More]
An easy to use, expandable command parser meant for text-based games and MUDs. It works by allowing you to define commands that follow a format of sequential arguments, and will resolve the arguments for you (Such as finding mobs, making sure something is a number, etc).

Why use Alaparser over the alternatives?


  • The entire library is built to be extendable and overridable, such that you can get it to work exactly like you want. None of the other parsers currently available are built to be extended.
  • Despite that, Alaparser works out-of-the-box by simply creating a single datum, defining the structure for commands and sending client input to the parser.
  • Things which games often want to customize (Such as what text should match a mob or obj) are made to be very easy to customize.
  • AbyssDragon.Parser has outstanding bugs, that won't get fixed because AbyssDragon is no longer on BYOND. It also requires quotes around text arguments, which is very impractical for MUDs you connect to via telnet.
  • Ebonshadow's MUD parser has severe constraints on command format, and does not resolve command arguments very well.
  • There is no noticeable performance difference between the ones I've tested (Alaparser, and AbyssDragon.Parser); both pretty much parse between 4000 - 6000 commands per second, which is enough unless you have over a few thousand players online in a single DD instance. In which case you probably have other problems (And a great MUD!).


Documentation for the library is an on-going process, and is not entirely done yet. There is a fairly comprehensive demo as part of the library, that showcases many of the different features of the command syntax.

This project is also hosted on GitHub here, feel free to submit issues there (or here), patches, etc..

Advertisement

Comments

Alathon: (Aug 7 2012, 6:56 am)
IScet wrote:
Still do not get it exactly... in my example of code... for instance... how can I get look to simply run my ShowMap() code from the parser... i have the lib checked... but maybe i need to see exactly MY commands running it cause I can not even remotely wrap my mind around this..

It sounds like you're more struggling with the basics of how BYOND even works. If that is the case, this might not be the right place to start. You may want to read some general BYOND tutorials first, that explain how verbs, procedures and so on work.
IScet: (Aug 6 2012, 10:04 pm)
Still do not get it exactly... in my example of code... for instance... how can I get look to simply run my ShowMap() code from the parser... i have the lib checked... but maybe i need to see exactly MY commands running it cause I can not even remotely wrap my mind around this..
Alathon: (Aug 6 2012, 12:19 pm)
IScet wrote:
Code:
> Command
> say
> format = "say; any";
> command(client/C, txt) {
> C << "You say, '[txt]'"
> }
>


if this is correct I can not get it to work at all... was just going for barebones because it wont work... I have the Alaparser checked under my Libs... then I type say hello and does not work...

Thats because thats not all you need to do. Defining commands lets the library know what you want commands to be structured like, but the parser isn't ever getting what the client types.

First things first, go ahead and update the library to the newest version, I just updated it.

Then check the documentation under readme.dm, under 'How do I set up the library to work?'.
IScet: (Aug 6 2012, 8:42 am)
Code:
Command
say
format = "say; any";
command(client/C, txt) {
C << "You say, '[txt]'"
}


if this is correct I can not get it to work at all... was just going for barebones because it wont work... I have the Alaparser checked under my Libs... then I type say hello and does not work...

mob/proc/ShowMap()
var
buf = ""
top = min(y+client.view, world.maxy)
bottom = max(y-client.view, 1)
left = max(x-client.view, 1)
right = min(x+client.view, world.maxx)

for(var/yy = top, yy >= bottom, yy--)
for(var/xx = left, xx <= right, xx++)
var/turf/T = locate(xx,yy,z)
var/mob/M = locate() in T
if(M)
buf += M.text
else
buf += T.text
buf += "\n"
mb_msgout(buf)
mb_msgout("Location: [x],[y]")

mob/verb
Look()
ShowMap()
North()
step(usr,NORTH)
ShowMap()
South()
step(usr,SOUTH)
ShowMap()
East()
step(usr,EAST)
ShowMap()
West()
step(usr,WEST)
ShowMap()


This is the rest of my code that I had setup in verbs and stuff and working fine... all this before I realized that I can't use verbs for TELNET and now I can't get it all to work at all ;(
Alathon: (Aug 6 2012, 6:27 am)
IScet wrote:
im looking through your demo commands file... which im guessing is where all of my commands must go as i cannot use verbs on telnet...

You shouldn't ever need to modify the library itself inside the library project. For the most part, in which .dm file something resides doesn't make much of a difference.

In your own game project/dme, you should create your own .dm file(s) that house the commands.

is mb.escapes color output to the world and oview easily doable there for like the say commands and stuff? sorry like i said... parser scene has still got my confused..

How you want to think of it is more-or-less like this:

- This library will allow you to define Command objects, that have a command() proc. That proc is run, when the parser matches what the client types, to the format you provide for the Command. This is no different than, f.ex, a verb. Let me show you an equivalent verb and Command (more-or-less):

mob/verb/tell(mob/M in world, txt) {
src << "You tell [M], '[txt]'";
M << "[src] tells you, '[txt]'";
}


Command
format = "tell; search(mob@world); any";

command(client/C, mob/M, txt) {
C << "You tell [M], '[txt]'";
M << "[C.mob] tells you, '[txt]'";
}


As you can see, the arguments you define within the verb (mob/M in world, txt) are quite similar to the 'format' variable of a Command. If you wanted to use color-formatting etc within command(), you're entirely free to do so. What happens after command() is called, is up to you!