Am I being dumb?

I'm doing something weird here, I think. And would appreciate opinions on whether it's good weird or bad weird, and if there's a more "sane" way to do it.

My character creation menu ends up with quite a lot of internal state (a lot like the parser in some ways). I'm making a command with the pattern "^(character )?(?

Now, the weirdness comes in because the character creation system has some state which isn't really a property of the character, and I don't want to load him down with a ton of temporary attributes. So I figured I can just use 'this' (setting attributes on the Command itself).

But then I want to initialise those parameters to a sensible value; and the method that rolled off the end of my fingers is something that feels natural, looks elegant in a weird kind of way, but I get the impression some coders would say it's crazy:

this.input_mode = "menu"
this.guidance = true
this.required_attributes = Split("name;pronouns;class;race", ";")
this.all_attribute_synonyms = Split("name,title;age;sex,gender;class,job;race", ";")
// ... etc etc ...

this.script => {
  // code to parse `text` and set some variables
}

useless_dictionary = NewStringDictionary()
dictionary add (useless_dictionary, "text", text)
do (this, "script", useless_dictionary)

Yet again, I forget the < in the post.

And yet again, trying to edit my post gives "You can't post that here".

Paragraph 2 should read:

My character creation menu ends up with quite a lot of internal state (a lot like the parser in some ways). I'm making a command with the pattern "^(character )?(?<text>.*)$" ... which removes the first question mark from the pattern when you finish it. So at a later point you can come back and type "character race elf" or "character male"; but until you've defined the mandatory options, the initial "character" in the command is optional and all other commands are disabled.

(though that's mostly irrelevant)


This will cause problems I would guess, as this will be in the "script" attribute:

this.script => {
  // code to parse `text` and set some variables
}

The best way to initialise objects (you cannot do this with commands though) is in their initialisation script. Look for the tick box on the Features tab.

Also, you probably want a space after (character )?


This will cause problems I would guess, as this will be in the "script" attribute:

I'm not sure why that's a problem; that's where it's supposed to be. Maybe this is what learning LISP does to your brain … too much experience on a system that likes to mix code and data :p


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums