Alaparser

by Alathon
Command parser for MUDs
ID:901869
 
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..
Note that the project is in a pretty early version. It works just fine, but I'm likely to make changes to it still, for more features. Some of these features may cause radical changes, but I'll try to keep that to a minimum.

The parser already supports enough features to be fully functional for any MUD usage; the ones left are basically niceties (Such as being able to define aliases for a command). You can check the issue tracker on GitHub for regular updates, and I'll try and keep the version on the BYOND hub as up-to-date as possible, until the library is on a more stable version.

It might be worth including a small summary of how your parser differs from the others on BYOND in your hub description, for people trying to decide which to use.
In response to DarkCampainger
DarkCampainger wrote:
It might be worth including a small summary of how your parser differs from the others on BYOND in your hub description, for people trying to decide which to use.

Ah, great point; thanks. I'll look into that this week.
Updated hub entry description some, with a small bullet-point list of why to use Alaparser. It could be a comparison chart for each of the parsers, but I'm not really sold on going ahead with that until someone actually ends up using Alaparser in the first place ;)
thinking about trying this out... as im creating a mud for use in telnet... however... the whole parser stuff is quite confusing to me... 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... 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..
In response to IScet
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!
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 ;(
In response to IScet
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?'.
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..
In response to IScet
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.
The parser as of now backings enough peculiarities to be completely useful for any MUD use; the ones left are fundamentally amenities (Such as having the capacity to characterize pseudonyms for an order). You can check the issue tracker on GitHub for normal overhauls, and I'll attempt and keep the form on the BYOND center as a la mode as could be expected under the circumstances, until the library is on a more steady form.





________________________________________________
Unlock the key of your success by [url=http://www.test-king.com/onlinecourses/ CFA-Level-1.htm]Testking cfa course[/url] and testking.By using [url=http://www.test-king.com/ cert-ITIL-V3-Foundation.htm]itil foundation[/url] our latest and study material, you can easily pass [url=http://www.quincy.edu/]www.quincy.edu[/url]