Expression text not printing correctly

I created a game verb called paint
I then typed in the expression field "You can't paint the "+object.article+"."

The problem is the object.article does not display the object name.


object.article gives the object's article – him, her, it, or them. It's used in the default verb messages t say something like "you can't eat him."

If you want the object's alias, you'd use "You can't paint the "+GetDisplayAlias (object)+"."


Hi rangel.
When I select expression in the drop down menu and type in "You can't paint the "+GetDisplayAlias(object)+"."

The result displayed is
"You can't paint the {GetDisplayAlias (object}"


Sorry about that. I'm not used to this feature because it isn't available on the web version. I assumed it would work like an expression. But that doesn't seem to be the case; it looks like it's being mangled somewhere along the line. Looking through the code, I'm assuming that your expression is being placed in the defaultexpression attribute; which should just be eval'ed. So all I can assume is that the editor is somehow changing the expression before saving it.

I really can't understand why this should happen; we might have to fall back on the expertise of someone who has a Windows computer here.


The strange thing is that it works without any problems when used in the adventure "Quest Test Adventure Tutorials and Templates'.
May be there is something I need to do in the adventure to make this work. I might have to experiment more.


Can you post the code for the verb in question? If you don't want to share the game, you should be able to open it in code view and copy the part from <verb name="paint"> to </verb>.
(When posting code in the forums, put a line of 3 backticks (```) above and below it to stop the forum mangling it)

I can't figure out what the issue is unless it's some bug in the editor; but seeing the affected code might help to shed some light on it.


Hi mrangel

This is my code

<verb>
    <pattern>paint</pattern>
    <defaulttext>"You can't paint the "+GetDisplayAlias (object)+"."</defaulttext>
    <property>paint</property>
    <defaultexpression>"You can't paint the " + GetDisplayAlas(object) +  "."</defaultexpression>
    <defaulttemplate>"You can't  paint the " + GetDisplayAlias (object) + "."</defaulttemplate>
  </verb>

If I type 'paint book'
I get the mesage "You can't paint the "+GetDisplayAlias (object)+"."

OK ... that dropdown allows you to set 3 different attributes, which have different values. Changing it from "text" to "expression" changes which one you are currently editing, but it doesn't change the text value that you already entered.

You need to change the dropdown back to "Text" and delete the value, and then do the same for "Template".

The value that you've got for the "Expression" version (in defaultexpression) is correct and should work. But the verb checks defaulttext first, if that doesn't exist it tries defaulttemplate, and only if those both don't exist it tries defaultexpression.

(Or you could delete the unnecessary values in the Attributes tab if there is one; or in code view. It should look like:

  <verb>
    <pattern>paint</pattern>
    <property>paint</property>
    <defaultexpression>"You can't paint the " + GetDisplayAlias(object) +  "."</defaultexpression>
  </verb>

I used the code that you suggested but now I'm getting this error

Error running script: Error evaluating expression 'Eval(this.defaultexpression, params)': Error compiling expression '"You can't paint the " + GetDisplayAlas(object) + "."': FunctionCallElement: Could find not function 'GetDisplayAlas(Element)'


Should be GetDisplayAlias(Element).


Sorry, didn't notice that :)

I just copied and pasted your code, and removed the defaulttext and defaulttemplate lines. Didn't notice the typo in the function name.


Dcoder: It should be 'object' and not 'Element', as Quest does not recognize 'element'.

All is working OK now thanks mrangel. My typo sorry.


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

Support

Forums