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 option1Will 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
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.