Adding or making visible displayverbs on objects on the fly

I'm trying to add an image gallery to my game by using unlock codes but after entering a code and apparently successfully adding the "coverimage" verb to my gallery's verb list then I can't see the newly added verb on the object's display verb list.

      <object name="Gallery">
        <inherit name="editor_object" />
        <usedefaultprefix type="boolean">false</usedefaultprefix>
        <alias>Gallery</alias>
        <displayverbs type="stringlist" />
        <useindividualverblist />
        <enteracode type="script">
          msg ("Enter a gallery unlock code")
          get input {
            switch (result) {
              case ("1234") {
			    list add (Gallery.displayverbs, "coverimage")
                msg ("Cover image unlocked!")
              }
            }
          }
        </enteracode>
		<coverimage type="script"><![CDATA[
            msg ("<img src='https://i.imgur.com/someimage.jpg' />")
          ]]>
		</coverimage>
      </object>


<useindividualverblist />

There are three separate verb lists for an object:

  • inventoryverbs (set in the editor)
  • displayverbs (set in the editor)
  • generatedverbslist (created automatically the first time an object is viewed, based on the object's verbs tab)

I notice that you have set the useindivisualverblist flag ("Only display verbs from this object's Verbs tab"), which causes the engine to ignore displayverbs/inventoryverbs and use generatedverbslist only.

If you want to displayverbs and inventoryverbs, you need to untick that box.


I removed the useindivisualverblist flag and I can see it appear now but it's showing as "coverimage" instead of something with spaces and casing like "Cover Image" and an error message "I don't understand your command." comes up when I click on the new verb,


The displayverbs list should contain exactly the text that you want it to type in the command bar when the verb is clicked on.

If you want it to appear as "Cover image", you would put:

list add (Gallery.displayverbs, "Cover image")

I also notice that your code there doesn't check if the player has already entered that code; meaning that if they accidentally enter the same code again, they could end up with the same verb appearing twice on the menu. So it might be better to have something like:

          msg ("Enter a gallery unlock code")
          get input {
            switch (result) {
              case ("1234") {
                if (ListContains (this.displayverbs, "Cover image")) {
                  msg ("You already unlocked that image.")
                }
                else {
                  list add (this.displayverbs, "Cover image")
                  msg ("Cover image unlocked!")
                }
              }
            }
          }

I'm now seeing the "Cover Image" display verb when I start the game rather than after I unlock it, and when I do unlock it I get 2 displayed doing the same action.

Screenshots: https://imgur.com/a/xi7Mf7W

      <object name="Gallery">
        <inherit name="editor_object" />
        <usedefaultprefix type="boolean">false</usedefaultprefix>
        <alias>Gallery</alias>
        <displayverbs type="stringlist" />
        <enteracode type="script">
          msg ("Enter a gallery unlock code")
          get input {
            switch (result) {
              case ("1234") {
                if (ListContains (this.displayverbs, "Cover image")) {
                  msg ("You already unlocked that image.")
                }
                else {
                  list add (this.displayverbs, "Cover image")
                  msg ("Cover image unlocked!")
                }
              }
            }
          }
        </enteracode>
        <coverimage type="script"><![CDATA[
          msg ("<img src='https://i.imgur.com/someimage.png' />")
        ]]></coverimage>
      </object>

It you have a verb on the verbs tab,it will be in the generatedverbslist. You can remove that by ticking "Disable automatically generated display verb list for this object" (the attribute usestandardverblist). This will force the menu to display only displayverbs or inventoryverbs (so if there are any other verbs you want to be accessible, you will need to add them to displayverbs or inventoryverbs manually)


Ah I think I have it working now! Thanks a lot!


Log in to post a reply.

Support

Forums