Change Script on a String List Attribute (with a side of Trying to Isolate Certain Text)

I'm experimenting with some interactive poetry and would like to avoid at all costs the poem being broken up by inapplicable commands, misspellings, and otherwise invalid input/response.

  1. I've messed around a bit with StartNewOutputSection and HideOutputSection, but there's really no way for me to call that every turn and not hide the poem lines as well, or to discern whether the last message was part of the poem.
  2. I've looked at the default commands and verbs - both in the Quest editor and in the Core files on Notepad - to see if I can edit the output section functions into the default responses, but it looks like text is the only acceptable content.
  3. I could create a new div with Java or something, but I've never been able to figure out how to insert things like object attributes into (or run functions on) divs created in such a way.
  4. I could do something with the custom status feature on the sidebar; however, the change script I've assigned to it to doesn't fire when I add a new list item to the attribute it displays. (And aesthetically it's far from ideal; I'd rather the poem sit at the top with auto margins than off to the side, and formatting it later so it's pretty will be a pain because my experience with the sidebar is that it Does Not Like It when you touch its width.)
  <game name="Poem Experiment">
    <gameid>227eb777-07b1-4788-9c54-a69c48f1d882</gameid>
    <version>1.0</version>
    <firstpublished>2018</firstpublished>
    <customstatuspane />
    <showpanes />
    <turnoffcompass />
    <turnoffinventory />
    <turnoffplacesandobjects />
    <poem type="stringlist">
      <value>First line here!</value>
      <value>Second line here!</value>
      <value>Third!</value>
    </poem>
    <changedpoem type="script"><![CDATA[
      JS.setCustomStatus (FormatList(game.poem, "<br/>", "<br/>", "Begin..."))
    ]]></changedpoem>
    <start type="script">
      JS.setCustomStatus ("Begin...")
    </start>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <description type="script">
      wait {
        list add (game.poem, "Fourth!")
      }
    </description>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
  </object>

Debugger tells me the list add was successful (I can see that "Fourth!" is included on the list), but the pane doesn't update.
Right now I'm just using a turn script that updates it every turn, but that seems less optimal. Not that I'm doing anything intensive. But in the future I might need to do something like this without using a turn script, for whatever reason, and then I'll need to understand anyway.

Any explanation of my current issue, or ideas to more effectively accomplish what I'm trying to do, would be appreciated!


Sorry, but this question is too complex for my pea size brain. If I knew the answer to your problem I would tell you. :(


I'm experimenting with some interactive poetry and would like to avoid at all costs the poem being broken up by inapplicable commands, misspellings, and otherwise invalid input/response.

It sounds like you either want to uncheck 'Display commands entered by the player' under the 'Room Descriptions' tab, or create a game book.


I've messed around a bit with StartNewOutputSection and HideOutputSection, but there's really no way for me to call that every turn and not hide the poem lines as well, or to discern whether the last message was part of the poem.

Anything in a msg("") will remain on the screen.

Anything in the first parameter of a ShowMenu("", , ) will be cleared.


I've looked at the default commands and verbs - both in the Quest editor and in the Core files on Notepad - to see if I can edit the output section functions into the default responses, but it looks like text is the only acceptable content.

I don't know what you mean...

...but it sounds like you just want to override the commands, scripting whatever responses you please.

http://docs.textadventures.co.uk/quest/#Commands

http://docs.textadventures.co.uk/quest/overriding.html


I could create a new div with Java or something, but I've never been able to figure out how to insert things like object attributes into (or run functions on) divs created in such a way.

If you wanted to create a new div with Javascript, and you wanted to print the value of player.alias:

Code View:

s = "Your alias is " + player.alias + "."
js = "var newDiv = $('<div id=\'poem-div\'/>"+ s + "</div>');"
JS.eval(js)

To add that to an element (I'll use divOutput):

JS.eval("$('#divOutput').append(newDiv);")

I could do something with the custom status feature on the sidebar; however, the change script I've assigned to it to doesn't fire when I add a new list item to the attribute it displays.

Just a theory (untested), but try this:

wait {
  game.poem = ListCombine (game.poem, Split("Fourth!", ";"))
}

I'd rather the poem sit at the top with auto margins than off to the side

You could try to add some CSS to the <div> element when you create it. Make its position fixed. Make its width and padding identical to that of the divOutput element.


NOTE:

There are 1,001 other ways to handle things.


PS

I just tested my theory about game.changedpoem out, and it works.

game.poem = Split("Stanza1;Stanza2", ";")
game.changedpoem => {
  msg (FormatList(game.poem,"<br/>", "<br/>", ""))
}
wait {
  game.poem = ListCombine (game.poem, Split("Stanza 3!", ";"))
}

Of course, you could just ask XanMag how he did this:

http://textadventures.co.uk/games/view/3z2xb2ruhkgq1t88wcpr7w/into-the-dragons-den


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

Support

Forums