title: Is there a Way I can add requiredState to a textNode?
body: <p>I'm trying to use requiredState{} in a text game I am making (Html and js linked) so that certain text only appears if you have a specific state. Anyone know how to do this? (Or anything with the same effect, so long as it works with the game.) There is no opening html or DOCTYPE tags because the project is being made in codepen.io</p>
  <pre><code>&lt;div class=&quot;container&quot;&gt;
    &lt;div id=&quot;text&quot;&gt;Text&lt;/div&gt;
    &lt;div id=&quot;option-buttons&quot; class=&quot;btn-grid&quot;&gt;
      &lt;button class=&quot;btn&quot;&gt;Option 1&lt;/button&gt;
      &lt;button class=&quot;btn&quot;&gt;Option 2&lt;/button&gt;
      &lt;button class=&quot;btn&quot;&gt;Option 3&lt;/button&gt;
      &lt;button class=&quot;btn&quot;&gt;Option 4&lt;/button&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <pre><code>const textElement = document.getElementById('text')
  const optionButtonsElement = document.getElementById('option-buttons')
  
  let state = {}
  
  function startGame() {
    state = {}
    showTextNode(1.1)
  }
  
  function showTextNode(textNodeIndex) {
    const textNode = textNodes.find(textNode =&gt; textNode.id === textNodeIndex)
    textElement.innerText = textNode.text
    while (optionButtonsElement.firstChild) {
      optionButtonsElement.removeChild(optionButtonsElement.firstChild)
    }
  
    textNode.options.forEach(option =&gt; {
      if (showOption(option)) {
        const button = document.createElement('button')
        button.innerText = option.text
        button.classList.add('btn')
        button.addEventListener('click', () =&gt; selectOption(option))
        optionButtonsElement.appendChild(button)
      }
    })
  }
  
  function showOption(option) {
    return option.requiredState == null || option.requiredState(state)
  }
  
  function selectOption(option) {
    const nextTextNodeId = option.nextText
    if (nextTextNodeId &lt;= 0) {
      return startGame()
    }
    state = Object.assign(state, option.setState)
    showTextNode(nextTextNodeId)
  }
  
  const textNodes = [
    {
      id: 1.1,
      text: &quot;What is going on? Where am I? No. That's not what I need to ask. A better question would be...&quot;,
      options: [
        {
          text:'Who... am I?',
          nextText: 1.2,
        },
      ]
    },
    {
      id: 1.2,
      text: &quot;I, I don't know. I can't remember. I need to survive. I need food, water, and shelter the basics of survival. Maybe I'll remember more in time. Until then, I must survive.&quot;,
      
    }
  ]
  
  startGame()
  </code></pre>