ID:143496
 
Code:
var/Parser/Parser = new()


client
Command(T)
Parser.Parse(T)

Command
priority = 1
roomedit
format = "'roomedit' ; text(room_edit_options)"
var/list/room_edit_options[] = list("option1","option2")
Process(mob/user,arg1)
//Room Edit code here


Problem description:
This code is entirely dependant on AbyssDragon's Parser library (http://developer.byond.com/hub/AbyssDragon/Parser). Without it, this probably doesn't make a whole lot of sense. Anyway, I'm finally writing the MUD I've always wanted to write (don't try and dissuade me, I'm a madwoman!). So, of course, I need to be able to parse text received from telnet clients.

Along the way I realized I needed some functionality for limited arguments in commands. I finally managed to figure out how to make AbyssDragon's parser take arguments from a list, but now I've got another problem; the user has to literally put quotes around the argument to make the command proc.

E.g.

roomedit "option1"
Will be recognized as a valid argument.

roomedit option1
Will not be recognized as a valid argument.

I can only assume this behavior occurs because I'm "typecasting" the argument in a sense by calling text(room_edit_options) but due to the parser's limitations (or at least my perceptions of those limitations), I can't broaden it out to simply be var(room_edit_options).

The only workaround I've come up with thus far is writing a proc that automatically adds quotes to the beginning and end of a text string. I would be quite comfortable with this method, only I have no clue where to call the proc without editing the library directly (which I am quite wary to do.) As it stands for now, the argument isn't an actual variable (seperate from the rest of the command) that I can manipulate until after Process() has come and gone, which by then is too late.

Oh, and if anyone has any suggestions on how to get around the apparent BYOND Bug that has telnet clients hitting enter before they can send or receive data to the rest of the program, I'd love to hear it.

Thanks in advance,
Evre
I don't know that much about AbyssDragon's parser, but I think one of the limitations was having to use full words and I don't think he ever added any way to use partial words.

If you haven't gotten too far in your program yet, you might consider experimenting with Ebonshadow's Parser, which I know using a chunk of my code that locates objects based on partial words, so I know it supports it. But I don't know which parser is easier to use, since I've always built my own from scratch. :P

And no, there's currently no way to avoid hitting Enter to join the MUD. Apparently this has something to do with the program checking to see if the it is being accessed through telnet or DreamSeeker, and they've never focused on telnet functionality enough to improve it.

In response to Foomer
I'm not sure what you mean by having to use full words. In the documentation (and indeed, in the code I've produced thus far) it's shown that it can match partial words to their whole-word counterparts.

From the readme:
~'examine' - allows any shortening of the argument ("exam", "e".. in this case)


I gave Ebonshadow's a glance and it looked like it might have been a little harder for me to use, but I'll give it another look. I'd hate to have to redo everything I've done so far. Thanks, though, I think I just needed someone else to tell me to move on and try something else to actually do it.

As for the telnet issue, would there possibly be some kind of workaround where I'd have the player connect to a C*/Python/whatever server and have the server send the return carriage for them, then pass the user along to the game itself? Or is there a flaw in my thinking there?
In response to Evre
Okay, maybe you're not talking about what I thought you were talking about. :P As I said, I'm not very familiar with AbyssDragon's parser.

I don't think there have been enough people around here fiddling with BYOND's telnet capabilities to know very many workarounds. Alathon would probably be the best one to ask, but I haven't seen him post for a while.

For the most part, if you're going to take the telnet route, you're on your own!
format = "'roomedit' ; text(room_edit_options)"

// Should be

format = "'roomedit' ; anything(room_edit_options)"



That fixes it. I feel like an idiot.