Debug tools?

Hi!

I'm working on a text game in Quest and I've noticed that debugging takes forever since when I fix a bug I have to restart my game to find another one. Is there a way to make like a debug tool that allows me to set certain object flags and teleport to locations and edit my inventory?

I don't know if that's possible but I hope it is.


Okay, set up a new command. Set it to use a regular expression instead of a command pattern, and put this in:

^cheat (?<text1>move|set|get) (?<text2>.+)$

Then paste in this code:

switch (LCase(text1)) {
  case ("move") {
    o = GetObject(text2)
    if (o = null) {
      error ("I cannot find a location called " + text2)
    }
    else {
      player.parent = o
    }
  }
  case ("get") {
    o = GetObject(text2)
    if (o = null) {
      error ("I cannot find an object called " + text2)
    }
    else {
      o.parent = player
    }
  }
  case ("set") {
    regex = "(?<object>.+)\\.(?<attribute>\\S+)\\s*=\\s*(?<value>.+)"
    if (not IsRegexMatch(regex, text2)) {
      error ("Sorry, wrong format")
    }
    dict = Populate(regex, text2)
    obj = GetObject(StringDictionaryItem(dict, "object"))
    if (obj = null) {
      error ("Sorry, object not recognised")
    }
    att = StringDictionaryItem(dict, "attribute")
    value = Eval(StringDictionaryItem(dict, "value"))
    set (obj, att, value)
  }
}

Now you can do:

CHEAT MOVE My bedroom
CHEAT GET lantern
CHEAT SET player.health=60
CHEAT SET Mary.parent = lounge
CHEAT SET bronze sword.inventoryverbs = Split("Lookat;Drop;Destroy", ";")

So the first one moves you to another room, the second puts an item in your inventory, the third sets an attribute just as in normal Quest code.


The Pixie,
would this be a good candidate for a debug/test library that can then be removed before the final release?


Yes


Thank you!


Okay so I have a problem. I've done what you said, but whenever I paste in the code and press OK, the editor throws up an error message:

"Sorry, an internal error occured."

and reloads, erasing the code I pasted. If I paste it again, it does the same thing.


I have just tested it, and using the off-line editor it is fine, but on-line it does as you describe. The problem line is the one starting regex =. Not sure what the solution is, or even if there is one.


Unfortunately using the offline editor is not an option for me. Thanks anyway!


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

Support

Forums