Third inventory pane: Can't get verbs for child objects in an open container to work.

I modified Pixie's Second Inventory Pane library so that I could create a third one for books (specifically in this case a Bible).

The idea worked fine if only verses are in there. For a regular book it could be lines or sentences, etc. But it took me some time to learn how to modify the library to show visible child objects correctly. Once I did that, the child object verbs give an error that "I can't see that."

I'm not sure what to try next, but I've tried many variations on scopes and list functions.

Here's what the functions I've modified look like now. It does work to show the child objects when a "Book" is opened (chapter it would be in a regular book), i.e. pages or verses, etc.

  <function name="UpdateInv3">
    contents = GetAllChildObjects(game.thirdinventoryholder)
    visob = FilterByAttribute (contents, "visible", true)
	alph = ObjectListSort(visob, "name")
    SetInv3(alph)
  </function>

  <function name="SetInv3" parameters="objects"><![CDATA[
    if (TypeOf(objects) = "object") {
      game.thirdinventoryholder = objects
      allob = GetAllChildObjects(objects)
      objects = FilterByAttribute (allob, "visible", true)	  
    }
    if (not TypeOf(objects) = "objectlist") {
      error ("Got a " + TypeOf(objects) + " instead of a list of objects (or an object) in SetInv3")
    }
    s = ""
    count = 1
    foreach (o, objects) {
      verbs = ""
      foreach(verb, o.inventoryverbs) {
        if (verbs <> "") {
          verbs = verbs + ","
        }
        verbs = verbs + "\"" + verb + "\""
      }
      if (s <> "") {
        s = s + ", "
      }
      if (HasString(o, "listalias")) {
        s2 = Replace(o.listalias, "\"", "\\\"")
      }
      else {
        s2 = GetDisplayAlias(o)
      }
      s = s + "\"k" + count + "\": {\"Text\":\"" + s2 + "\",\"Verbs\":[" + verbs + "],\"ElementId\":\"" + o.name + "\",\"ElementName\":\"" + GetDisplayAlias(o) + "\"}"
      //s = s + "\"k" + count + "\": {\"Text\":\"" + GetDisplayAlias(o) + "\",\"Verbs\":[" + verbs + "],\"ElementId\":\"" + o.name + "\",\"ElementName\":\"" + GetDisplayAlias(o) + "\"}"
      count = count + 1
    }
    s = "{" + s + "}"
    JS.updateInventory3("Inventory3", s)
    ]]></function>  

Please and thanks for any help or advice. I've looked through the forums and the documentation and tried several things, but maybe I'm missing something completely and have been messing about with the wrong area of the code? I mean, I can see them in the pane, but is there something i'm missing to make them also "verbable?"

The sorting alphabetically allows me to choose the order items appear in the inventory pane by using naming convention.


So, what I mean as an example. When "Genesis" is "opened" "Genesis 1:1" shows. But when closed, it disappears from the pane. But Genesis 1:1 isn't readable... only Genesis.
Eventually, If I can get it to work, I'd want another level too. So One would open Genesis, Open the chapter, then read a verse.
Or a regular book. Open a chapter or a page, then read a paragraph, sentence, etc.

I currently have "Book" type for the book level, so those can be searched, opened, read, and Studied. And a versetype so those can be read, prayed, shared, meditated, and studied.

Again, thanks for any help or thoughts.


The code you have looks valid.

What do you mean when you say verbs "don't work"? Does it give an error message when you try to use them? Knowing what the error is could make it easier to track down the problem.


I get "I can't see that" if I type "Look" but if I click on a verb on the object in the object pane (no matter which one) it says "I can't see that" (genesis 1:1) ... if I clicked the child object with the alias "Genesis 1:1". The actual object's name is a010101genesis1 1 which allows me to make it display in the desired order AND let me see what it is.


The verbs and the type in the library look like this:

  <verb>
    <property>pray</property>
    <pattern>pray</pattern>
    <defaultexpression>"You can't pray " + object.article + "."</defaultexpression>
  </verb>
  <verb>
    <property>study</property>
    <pattern>study</pattern>
    <defaultexpression>"You can't study " + object.article + "."</defaultexpression>
  </verb>
  <verb>
    <property>share</property>
    <pattern>share</pattern>
    <defaultexpression>"You can't share " + object.article + "."</defaultexpression>
  </verb>
  <verb>
    <property>meditate</property>
    <pattern>meditate</pattern>
    <defaultexpression>"You can't meditate on " + object.article + "."</defaultexpression>
  </verb>
  <type name="scriptureversetype">
    <visible type="boolean">false</visible>
    <take type="boolean">false</take>
    <drop type="boolean">false</drop>
    <inventoryverbs type="stringlist">
      <value>Read</value>
      <value>Pray</value>
      <value>Share</value>
      <value>Meditate</value>
      <value>Study</value>
    </inventoryverbs>
    <study>{random:You consider the original language of the verse: You consider the historical context of the verse: You consider the literary context of the passage: You try to consider the author's intent.}</study>
    <linkcolour>DeepSkyBlue</linkcolour>
    <read type="script">
      msg ("You read the verse.")
    </read>
    <pray type="script"><![CDATA[
      if (GetBoolean(player, "Bornagain")) {
        msg ("You pray, {this.read}")
        firsttime {
          game.score = game.score +1
          msg ("One point for discovering that praying this scripture can be effective!")
        }
      }
      else if (ListContains(ScopeVisible(), Holy Spirit)) {
        msg ("You pray, {this.read}")
        msg ("You feel The Spirit...")
        firsttime {
          game.score = game.score +1
          msg ("One point for discovering that praying this scripture can be effective!")
        }
      }
      else {
        msg ("You aren't sure of the value in that.")
      }
    ]]></pray>
    <share type="script">
      if (ListContains(ScopeVisible(), Holy Spirit)) {
        msg ("You share a moment with the Holy Spirit as you read the verse aloud.")
      }
      else {
        msg ("It doesn't seem like anyone nearby wants to hear that verse right now.")
      }
    </share>
    <meditate type="script"><![CDATA[
      msg ("You meditate on the verse. ")
      do (this, "read")
      if (GetBoolean(player, "Bornagain")) {
        goingwithin
        msg ("Something to consider about the verse inwardly")
      }
      else if (ListContains(ScopeVisible(), Holy Spirit)) {
        msg ("You feel The Spirit...")
      }
      else {
        msg ("{random:Ohhhmmmmmmmmmmm... oh, wait...:You're not even sure what it means to meditate on a scripture.:You consider it, then unconsider.:You think you've heard of a spiritualist doing such a thing, but have no idea how.}")
      }
    ]]></meditate>
  </type>

And it's been working fine until I had the brilliant idea to nest chapters and verses inside books so that they could be "opened" to and "closed" and keep the inventory pane fairly clean and well-sorted.

As soon as the nesting and visibility became part of the equation, I lost the functionality of the verses.


I have it set so that when you "open" genesis, the Scripture verse becomes visible.


Is the bible in scope and open or rransparent? Or are you using a background scope script to make the verses accessible? That's likely to be where the error is.


Mr. Angel!!

That's very likely the missing piece! I'd forgotten that part of the proper setup to using Pixie's Inventory Library is adding a Scope Script! I added it as I was following the instructions, but never went back to modify the scope. Pixie's original instructions say to scope as follows.

foreach (o, GetDirectChildren(verses_known)) {
  list add (items, o)
}

Just looking at it, I can see that I'll need to ScopeVisibleForRoom (verses_known) in order to keep the game scope in line with the functions in the library!

You're one of my heroes Mr.Angel!


Actually! ScopeAllVisibleForRoom is warned about in the documentation because it causes a crash!

I forgot until I'd put it in there... so I figure putting a second post here with the solution would help anyone who ends up doing something like this in future.

The correct modification to the above script is GetAllChildObjects (verses_known)

Now it works perfectly! Thanks again Mr. Angel!


I love your game idea. I hope I might get to play it. Will you publish it on Quest when it's made? Maybe, you can send me a pm when it's up?


I'd love to! (although I see in the forums that people are having trouble publishing to the site lately)

I also might be glad to share it with you in bits of the development stages... I don't know a ton of people who would like to playtest unfinished text adventure games haha.


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

Support

Forums