Note: This is a work in progress. It does not cover all errors, but is slowly getting closer to that state…
Occasionally we hear about a situation where the desktop version of Quest will not start. It has never happened to me, which makes finding the root cause very tricky, but for whatever reason Quest has got a double entry in the list of recently played or recently edited games. You might see an error message like this:
System.InvalidOperationException: An error occurred while creating the form. For more information, see Exception.InnerException. Error: An exception was thrown in the constructor call for the type 'GameBrowser.PlayBrowser' that matches the specified binding constraint. ---> System.Windows.Markup.XamlParseException: An exception was thrown in the constructor call for the type 'GameBrowser.PlayBrowser' that matches the specified binding constraint. ---> System.ArgumentException: An item with the same key has already been added.
Follow these steps (thanks Jay!):
We need to delete two keys, “Recent” and “EditorRecent” (in fact you only need to delete one; the former if the play browser is a problem, the latter if the edit browser is the problem, but if you are not sure it is safest to delete both). Right-click on the word “Recent” and then choose “Delete” from the popup menu. Choose yes to confirm. Do the same for “EditorRecent”. Close the Rededit program (no need to save).
Note that when you open Quest, the “recent” lists will be empty until you begin using Quest again, but that is preferable to not being to open Quest at all!
There are all sorts of problems that can arise as you code with Quest. Computer languagers are fussy things that expect you to type to very strict rules, and Quest is no different. Some things to check:
hitpointsin one place and
hit pointsin another and
Hit pointsin a third, it is not going to work)
return; if it is not “None” then there must be
This can happen if you move the player in script on the room. Say you want to turn a player back from an exit. You might think it is a good to set up the script that runs on the destination room so it moves the player back to the original room. What happens is that the player is moved twice, and so Quest thinks it has to show the room description twice - and to add to the confusion, it does it for the current room, which will be where the player ends up.
The solution is to avoid moving the player on any of the built-in room scripts. In the example above, the script should be on the exit that goes to the destination, without moving the player at all.
Occasionally you may see this error:
Error running script: Error evaluating expression ‘(not GetBoolean(game.pov.parent, “visited”)) and HasScript(game.pov.parent, “beforefirstenter”)’: GetBoolean function expected object parameter but was passed ‘null’
This happens when the player’s “parent” attribute is set to null, and can happen if you try to move the player to a variable that has not been set (and Quest will think an object name you have mis-spelled to be a variable).
Sometimes Quest is clever and will warn you or take some action if you try to give something a bad name (if you try to add an object called “game” it will call it “game1”). However, there are other times it will not…
Quest automatically assigns names to anything you do not name yourself (for example, most of the exits in your game will have no name). It will name the first one K1, the second K2, and so on. What this means is that if you name anyhing in your game ‘K’ following by a number you are in danger of having a name collision!
You will probably never need them in a text adventure, but
pi are both mathematical constants. Quest will happily let you assign a value to them, but will ignore the assignment.
e = GetExitByLink (room, room2) msg (e) -> 2.71828182845905
This only applies to local variables, you can give these names to attributes.
Trying to use any of these as the name of an attribute will confuse the editor. You will not get an error, but it will not do what you expect when you save your game and then load it (whether during player or when editing). The problem is that these all have special meaning for Quest when it is loading XML files, and it will, for example, assume your “object” attribute is a real object.
You can use attribute names with spaces in them for strings, number, objects and scripts, but not for lists or dictionaries.
Various attributes are already used by Quest. Do not do anything with “type” or “elementtype”. Obviously “name”, “parent”, “alias”, etc. have specific meanings in Quest, and trying to use them for something else will cause problems.
Runtime errors occur when playing the game. Quest has tried to run a script, and realised there is an issue. You will get an error in the game output that will usually consist of two parts. Here is an example:
Error running script: Error compiling expression 'game.myflag': RootExpressionElement: Cannot convert type 'Object' to expression result of 'Boolean'
The first part is in this format:
Error running script: Error compiling expression '[whatever]':
[whatever] is the important part, as that is the code that Quest cannot understand.
If you are using the desktop version, copy the bit inside the single quotes (without the quotes) and go to Tools - Code view, press [Ctrl]-F, and paste in the text you just copied. Now you can search your game to quickly locate the code. Bear in mind that the same text could be at several places in your game, and some may be okay, so check each occurance.
If using the web version, it is not as easy, but you could download your game, open it in a text editor and then search for the error. You would have to then correct the on-line version, and it still may not be clear how to do that.
Either way, it may be easier to check any scripts you have changed recently, and see if the text is there using “Code view” for each script.
The second part of the message indicates what the error actually is.
RootExpressionElement: Cannot convert type '[something]' to expression result of 'Boolean'
This occurs when the text inside an
if condition, does not work out to a Boolean. If
[something] is “Object”, then the code has resulted in
null, and may be because an attribute does not exist (or has been spelled wrongly).
ArithmeticElement: Operation 'Add' is not defined for types 'Int32' and 'Object'
This could be ‘Subtract’ or whatever, and the types may be different. Again “Object” indicates
null, and this is telling you that you are trying to add (or whatever) a number and null. Again, this is probably because an attribute does not exist or has been misspelled.
Unknown object or variable '[something]'
In this case, Quest has found
[something] in a script, but has no idea what it is. It could be an object that you misspelled or a local variable that you have not given a value to yet.
If the function name is wrong, you will get something like this:
Error running script: Error compiling expression 'msg2("some text")': FunctionCallElement: Could find not function 'msg2(String)'
If you have the wrong number of arguments, you might one of these (first is for hard-coded functions):
Error running script: Expected 1 parameter(s) in script 'msg("some text", "more text")' Error running script: Too many parameters passed to OutputText function - 2 passed, but only 1 expected
If you try to set a value from a function that does not return a type, you might see one of these:
Error running script: Error compiling expression 'msg("some text")': FunctionCallElement: Could find not function 'msg(String)' Error running script: Error compiling expression 'OutputText("some text")': Value cannot be null.Parameter name: key
For hard-coded functions, you will get an error if you do not set a value and it has a return type, and if you send it the wrong type in the parameters:
The following errors occurred: Error: Error adding script attribute 'start' to element 'game': Function not found: 'GetBoolean' Error running script: Error evaluating expression 'GetBoolean("other text", "some text")': GetBoolean function expected object parameter but was passed 'other text'
You might see this error when you change the display or inventory verbs of an object during a game (it is possible with other lists too):
Error running script: Cannot modify the contents of this list as it is defined by an inherited type. Clone it before attempting to modify.
Somewhere in your game you will have a line like one of these:
list add (sword.inventoryverbs, "Equip") list remove (hat.displayverbs, "Flatten")
The problem is that the two list attributes, “inventoryverbs” and “displayverbs” are set on the object’s type, not on the object itself (if you are using the desktop version, go to the Attributes tab, and check its source). You cannot modify the listwhen it belongs to the type.
There are two solutions. The easiest is to add something to the the list in the editor (bottom of the __ tab). That will add the list attribute to this object. You can then delete the entry; once the attribute is on your object, it is there.
Alternatively, you can gve the object a new list. The
Splitfunction offers an easy way to do that:
sword.inventoryverbs = Split("Look at;Take;Equip", ";")