Figured out how to use Pixie's Debug Tool in online editor

The Pixie provided some debug tools back in 2016:

https://textadventures.co.uk/forum/quest/topic/d3yfsxzzckwbhy-weev7pq/debug-tools

Which created helpful :

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 Problem
If you're using the online editor and you copy all of the code, the editor throws up the message "Sorry, an internal error occured." and reloads. For some reason, the case expressions and the regex variable must be entered manually (I believe because they contain quotation marks).

The Work-Around
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)) {


}

Then, using the online script editor, create 3 case expressions (make sure to include the quotes) within switch that was created:
"move"
"get"
"set"

Then, within the "move" case, paste the following code:

    o = GetObject(text2)
    if (o=null) {
      error ("I cannot find a location called " + text2)
    }
    else {
      set (player, "parent", o)
    }

Within the "get" case, paste the following code:

    o = GetObject(text2)
    if (o = null) {
      error ("I cannot find an object called " + text2)
    }
    else {
      o.parent = player
    }

Within the "set" case, there are 3 steps. 1st, paste the following code:

    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 recognized")
    }
    att = StringDictionaryItem(dict, "attribute")
    value = Eval(StringDictionaryItem(dict, "value"))
    set (obj, att, value)

2nd, use the online script editor to set a variable or attribute, and enter
regex = "(?<object>.+)\\.(<attribute>\\S+)\\s*=\\s*(<value>.+)"
into the expression box.

3rd, move that line of code to the top of the "set" case.


The issue with the regex is that the online editor's code view breaks when attempting to save a piece of code that includes a < and > pair within a quoted string.


You can always use the <! [CDATA[]]> tag to avoid it complaining about the < or > use.
P.s. remove the space in the above tag when implementing, trying to show it in full here doesn't work since it thinks its meant to be used.


You can always use the <‍![CDATA[]]> tag to avoid it complaining about the < or > use.

I've never seen that work with the online editor.


What about doing "/<"?


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

Support

Forums