Looking for help with a custom Verb

So I made a verb for the sole purpose of pulling up the values of some variables from the player via an object in the player's inventory. Sort of an in-game menu until I properly modified the GUI. I made the verbs via the object menu, and it uses the following attributes:

Pattern: Command Pattern
Default: Text
Text: Blank/Unused
Name: Blank/Unused

Object Separator: with; using
Menu Caption: With which object?
Default Text: That doesn't work.
If No Objects are available, show this message: There are no objects available to do that with.

I'm using the object by clicking on it, then selecting the command rather than writing it (I plan to have the command bar disabled). When I do, it actually runs successfully, but then it tacts this on at the end:

Error running script: Error compiling expression 'game.command_successful':
RootExpressionElement: Cannot convert type 'Object' to expression result of 'Boolean'

I've done some searching on the forums, but it's still left me a bit confused as to where this is coming from. I'm familiar with programming, although XML is a strange new world for me. What it seems like (and this is my guesswork) is that verbs are supposed to return a boolean to the main game and it's somehow returning an object instead. I have no idea where it'd be getting the object from, though.

On the object side, the object's response to the verb is a script comprised entirely of the print value function, like below:

msg ("Player Attributes:")

So I'm a little stumped. I'm hoping someone might be able to point me in the right direction in terms of addressing this. ^.^;;


I am a little confused how you are doing this, and I am wondering if you have added a verb element. The best way to add a verb to an object is via the Verbs tab of the object itself:
http://docs.textadventures.co.uk/quest/tutorial/using_scripts.html

By the way, when Quest says RootExpressionElement: Cannot convert type 'Object' to expression result of 'Boolean' it really means "null", not "object".

XML is pretty straightforward, but unless you are creating a library, you never need to see it. Quest code is something else, and is useful to know to some degree.


Actually, that's exactly how I created it. I made the verbs via the 'Verbs' tab of the object (henceforth called 'menu'), and populated the scripts there, I never even touched the verbs section itself save to pull down that info for this post.

Under the Verbs tab for the menu object are the three verbs I built (they all do the same thing, just different variables) showing the value as the script and the source as the menu object. It's good to know that it's actually referencing a null, but I still don't know how it's producing that. I added the verbs in the same manner as shown in that tutorial (I think I might've actually followed that) so I'm not sure where the difference would be.

It's good to know that there's such a clear separation between the two languages, too! I am trying to learn QC as well, although I haven't been able to put in as much time as hoped.


'Verb' Elements (Verbs are Script Attributes with some additional coding to make them Verbs) are actually/technically (as the underlying quest coding) a specialized 'Command' Element, while I don't exactly understand it, it's something like this: they get their parent Object as their only input Argument, and thus they are, attached only to and function only with, its parent Object, whereas the 'Command' Element isn't limited to a parent Object as it has no parent Object.

What you're doing sounds more complex than what little I understand about how Verbs and Commands work (they can be connected together), unless I'm not understanding what you're trying to describe what you're doing.


if you want a more simple functionality, you can do this, an example:

<object name="player">
</object>

<object name="action_button">
  <attr name="parent" type="object">player</attr>
  <attr name="alias" type="string">actions</attr>
  <attr name="take" type="boolean">false</attr>
  <attr name="drop" type="boolean">false</attr>
  <attr name="inventoryverbs" type="simplestringlist">explore;search;talk;fight;magic;item;equipment;storage;rest;sleep</attr>
  <attr name="explore" type="script">
    // scripting
  </attr>
  <attr name="search" type="script">
    // scripting
  </attr>
  <attr name="talk" type="script">
    // scripting
  </attr>
  <attr name="fight" type="script">
    // scripting
  </attr>
  <attr name="magic" type="script">
    // scripting
  </attr>
  <attr name="item" type="script">
    // scripting
  </attr>
  <attr name="equipment" type="script">
    // scripting
  </attr>
  <attr name="storage" type="script">
    // scripting
  </attr>
  <attr name="rest" type="script">
    // scripting
  </attr>
  <attr name="sleep" type="script">
    // scripting
  </attr>
</object>

<object name="info_button">
  <attr name="parent" type="object">player</attr>
  <attr name="alias" type="string">info</attr>
  <attr name="take" type="boolean">false</attr>
  <attr name="drop" type="boolean">false</attr>
  <attr name="inventoryverbs" type="simplestringlist">looks;stats;spells;gear;items;help;hints</attr>
  <attr name="looks" type="script">
    // scripting
  </attr>
  <attr name="stats" type="script">
    // scripting
  </attr>
  <attr name="spells" type="script">
    // scripting
  </attr>
  <attr name="gear" type="script">
    // scripting
  </attr>
  <attr name="storage" type="script">
    // scripting
  </attr>
  <attr name="items" type="script">
    // scripting
  </attr>
  <attr name="help" type="script">
    // scripting
  </attr>
  <attr name="hint" type="script">
    // scripting
  </attr>
</object>

<verb>
  <property>explore</property>
  <pattern>explore</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

<verb>
  <property>search</property>
  <pattern>search</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

<verb>
  <property>talk</property>
  <pattern>talk</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

<verb>
  <property>fight</property>
  <pattern>fight</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

<verb>
  <property>magic</property>
  <pattern>magic</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

<verb>
  <property>item</property>
  <pattern>item</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

<verb>
  <property>equipment</property>
  <pattern>equipment</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

<verb>
  <property>storage</property>
  <pattern>storage</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

<verb>
  <property>rest</property>
  <pattern>rest</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

<verb>
  <property>sleep</property>
  <pattern>sleep</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

<verb>
  <property>looks</property>
  <pattern>looks</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

<verb>
  <property>stats</property>
  <pattern>stats</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

<verb>
  <property>spells</property>
  <pattern>spells</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

<verb>
  <property>gear</property>
  <pattern>gear</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

<verb>
  <property>items</property>
  <pattern>items</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

<verb>
  <property>help</property>
  <pattern>help</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

<verb>
  <property>hints</property>
  <pattern>hints</pattern>
  <defaultexpression>You can't do that!</defaultexpression>
</verb>

to add to Pixie's comments about quest coding (let's see if I get this description/explanation more accurate this time, lol):

quest has it's own language 'aslx', which is generally made up of two (or three) types of languages:


  1. (see code box below)
the 'xml/html like (web/online)' coding part with the tags: <xxx>xxx</xxx> or <xxx />, which acts like your "physical" stuff:

// most of the XML tags can be used within quest's scripting too, for example: msg ("you stop to catch your breath...<br>having caught your breath, you greet the npc")

<asl version="###"> // beginning asl tag block
  // the 'asl' block IS your game / GAME OBJECT !!!
  // I still use an older version/engine/(quest.exe) of quest, so I use: version="550", but the current is either: version="560" or version="570", so replace the '###' with the 3 digits that is your version number: the rightmost number is always zero: version="##0"
  // mass of game code/content, everything has to be within the 'asl' tags
</asl> // ending asl tag block

// these are your (default, for english language users) library files:
// (quest is a very powerful program, the engine is made up of library files, as well as your game, along with this game file's contents too. So, you can create your own engine, completely changing quest, if you're a good programmer and know quest's underlying coding well)
<include ref="English.aslx" />
<include ref="Core.aslx" />

// example of a custom (your own library file to be included in your game and/or engine's initialization:"built-up" creation)
<include ref="my_library_file.aslx" />

<game name="NAME_OF_YOUR_GAME">
  // this is your special 'game' Game Settings Object, which has lots of global/game-wide controls/toggles/features/attributes and also outside of game info for people looking at playing your game (author, version history/number, first published, category, difficulty, cruelty, description of your game, game id random generated hash string for the quest engine or just the quest servers / online, etc etc etc attributes)
  <attr name="gameid" type="string">SOME_RANDOMLY_GENERATED_HASH_STRING</attr>
  <attr name="author" type="string">NAME_OF_AUTHOR</attr>
  <attr name="version" type="string">1.0</attr>
  <attr name="firstpublished" type="string">2017</attr>
  <attr name="description" type="string">This is my example game, I hope you enjoy it</attr>
  <attr name="start" type="script">
    // these scripts are the first things done when the game begins, before you're able to start playing/doing stuff
    // some examples of common scriptings to be done:
    // intro scripting, for example: msg ("Hi, welcome to my game")
    // character creation scripting
  </attr>
  // etc Attributes
</game>

<object name="room">
</object>

<object name="player">
  <attr name="parent" type="object">room</attr>
</object>

// etc Elements: Objects, Exits, Verbs, Commands, Functions, Turnscripts, Timers, Object Types / Types, etc etc etc

default (for english language users) new game code:

(using my older version of quest)

<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="NAME_OF_GAME">
    <gameid>SOME_RANDOMLY_GENERATED_HASH_STRING</gameid> // this syntax is the (for me annoyingly) defaulted (quest forced/changed into) short form of a String Attribute
    <author>NAME_OF_AUTHOR</author>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
  </object>
</asl>

  1. the second type of language is the scripting language, which (it's syntax) is similar to c++/Java, though it has some features from Python (List Attributes instead of Arrays, and has Dictionary Attributes):

an example:

(the 'CDATA' tags is for telling quest that the '<,>' characters/symbols are to be seen as greater than or lesser than operations/operators, and thus NOT as syntax tags)

<game name="NAME_OF_GAME">
  <attr name="start" type="script">
    <![CDATA[
      msg ("Name?")
      get input {
        // the 'get input', 'show menu / ShowMenu', and 'ask / Ask' automatically (hidden from you) do this for you: result = YOUR_INPUT
        player.alias = result
        msg ("Age?")
        get input {
          player.age_integer = result
          if (player.age > 17) {
            player.age_string = "adult"
          } else if (player.age > 12) {
            player.age_string = "teen"
          } else if (player.age > 3) {
            player.age_string = "child"
          } else if (player.age > 0) {
            player.age_string = "baby"
          }
          show menu ("Sex?", split ("male;female", ';"), false) {
            player.sex = result
          }
        }
      }
    ]]>
  </attr>
</game>

  1. the 3rd type of language is JS (JavaScript), which you can use to do stuff that quest can't do or can't do easily, such as using the JS to modify quest's or your game's UI/GUI.


So you have an object called "menu", you go to the Verb tab, add a new verb, and give it the script:

msg ("Player Attributes:")

... and it gives that error? The only thing I can think of is that your verb clashes with an existing attribute. We had someone using "enter" as a verb recently, but "enter" is also the attribute Quest looks for when you enter a room, so it caused errors. What verbs are you adding?


P.S.

here's the link for the doc on the web languages:

ht.tps://www.w3schools.com/

the basics of html and css is pretty simple if you already know how to code a bit already, and especially if you know the basics of a main language (c++, java, python, etc)


Thank you both for your aid. And the three verbs I'm using are attributes/measures/script.

Regarding what you said hegemonkhan, my verbs look nothing like that in code view, which might be the problem. Instead they appear underneath the menu object, which is underneath the player object, and each one looks like this:

      <object name="Menu">
        <inherit name="editor_object" />
        <attributes type="script">
          msg ("Player Attributes:")
          msg ("Player Body: " + player.attri_power)
</attributes>

Not sure why. The verb itself then shows up down near the bottom with just this to its name:

<verb>
    <property>attributes</property>
    <pattern>attributes</pattern>
    <defaultexpression>"You can't attributes " + object.article + "."</defaultexpression>
  </verb>

Thank you for the link, too. I'm familiar with the basics of html and css (I've used them in websites before) but I definately need brushing up on them. Funnily enough, they're the two scripting languages I tend to abide the least, historically. XD Something about the way they're laid out is hard for me to parse.

I'm going to go play with it using the information provided, and hopefully sort it out.


I just created an object called "menu", and have it verbs "attributes" and "script" and it works fine.

    <object name="Menu">
      <inherit name="editor_object" />
      <script type="script">
        msg ("Script")
      </script>
      <attributes type="script">
        msg ("Atts")
      </attributes>
    </object>
  <verb>
    <property>script</property>
    <pattern>script</pattern>
    <defaultexpression>"You can't script " + object.article + "."</defaultexpression>
  </verb>
  <verb>
    <property>attributes</property>
    <pattern>attributes</pattern>
    <defaultexpression>"You can't attributes " + object.article + "."</defaultexpression>
  </verb>

It could be something else.


where the 'Verb' or 'WHATEVER' Element tag blocks are in code (vertically), doesn't matter (aside from the obvious stuff like outside of your game code: the 'asl' tag block, and/or within another Element, for examples), aside from the library file reference tags:

<include ref="xxx.aslx" />

, and maybe the 'game' Game Settings Object, as well as desired/required containment heirarchy.


you used 'Menu' for your Object, I used 'actions_button' and 'info_button' for my Objects. You then got the individual Script Attributes (Verbs) within your 'menu' Object, and I got my individual Script Attributes (Verbs) within my two Objects.

Both of our individual 'Verb' tag blocks for our individual Script Attributes, are correct/the-same (again, where they are vertically in code, doesn't matter).

The individual Script Attributes (our Verbs) must be within Objects, which they're correctly so, for both of us.

Verbs are actually just Script Attributes with some addition coding (which is why you see/have Attributes being created in code along with its matching 'Verb' Element tag) to make the Script Attributes act as Verbs do (Verbs are to act like Commands, as they're Commands, in the underlying quet coding).


P.S.

it's possible you're having conflicts by naming your Attributes as 'script' and 'attribute', as these are built-in terms/labels for quest's built-in and/or underlying coding

try to make you names/labels more unique and not what quest uses...

I'm afraid to use 'element' for the damage/magic types: fire, water, air, earth, etc...

so instead I use 'elemental', as I don't think Alex used this for quest... I hope not, lol.

Unfortunately... 'type' is such a useful word for describing so many things... and not many people know of similes for it (including me, lol), I need to get a theasures and see if there are any other words that mean the same as 'type'... lol


an easy and common way to make things unique, is to add: 'my/my_' in front of it:

my_script
my_attribute
my_type
my_talk
my_take
etc etc etc

or something like that... if you need something better or more describing than 'my', lol.


it's possible you're having conflicts by naming your Attributes as 'script' and 'attribute', as these are built-in terms/labels for quest's built-in and/or underlying coding

I wondered that too, but they are fine.


Finally figured it out.

It's a problem with CombatLib, somehow, which I'd planned to use and incorporate some of the functionality from later on. I'm not sure where it conflicts, but as soon as I removed that, everything worked again. I have no idea why.

Thank you both for all your help, you gave me a lot to go on with debugging this mess. ^^


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

Support

Forums