Notetaking Command in Quest

Sorry, new to the program.
I'm after to make a command that allows the player to make a note. Currently, I've set it up to make a new object, with the name of "note" + whatever you type. However it seems to be hidden or something? I see it in the debugger but not elsewhere & the "AddToInventory", or many other things can't find it
This is currently what I have setup:

<command>
    <pattern>note #text#</pattern>
    <script>
      create ("\"note\" + text")
      AddToInventory ("note" + text)
    </script>
    <scope>"inventory"</scope>
  </command>

Anyone know how to fix this? Or anything else I can try?
Thanks in advance


Hmm, too bad the LOG command still doesn't work.


First issue: AddToInventory ("note" + text) - the parameter to AddToInventory needs to be an object, not the name of an object.

Second, that makes an object whose name is whatever the player typed. This means that notes can only contain characters that are legal in an object name, and have to be unique. This seems kind of odd.

I think you more likely want something like:

<command>
  <pattern>note #text#</pattern>
  <script>
    name = GetUniqueElementName("note")
    create (name)
    mynote = GetObject (name)
    mynote.alias = "Note: "+text
    mynote.visible = true
    AddToInventory (mynote)
  </script>
</command>

This tutorial may be helpful:
http://docs.textadventures.co.uk/quest/keeping_a_journal.html


I used this tutorial, too: http://docs.textadventures.co.uk/quest/keeping_a_journal.html

This uses a string list instead of objects.

game.notes = NewStringList()

To add a note (multiple ways possible):

  <command>
    <pattern>note #text#</pattern>
    <script><![CDATA[
      list add (game.notes, text)
      msg ("You wrote: <i>''" + text + "''</i>")
    ]]></script>
  </command>

And to read them:

  <command>
    <pattern>notes; read notes</pattern>
    <script><![CDATA[
      msg ("Your notes: </br></br>" + FormatList (game.notes, "</br></br>", "</br></br>", "You haven't taken any notes.") + "")
    ]]></script>
  </command>



That's pretty much like the journal tutorial except I use FormatList() instead. I've changed it a bit up and added a command to remove specific notes.

      game.notes_raw = NewStringList()
      game.note_count = 1

The note writing command get also changed: game.notes_raw

  <command>
    <pattern>note #text#</pattern>
    <script><![CDATA[
      list add (game.notes_raw, text)
      msg ("You wrote: <i>''" + text + "''</i>")
    ]]></script>
  </command>

Then I added a turn script which will add numbers to each note, formats the text a bit and adding them to the real notes list, which is later used by the 'read notes' command:

  <turnscript name="TurnNoteCount">
    <enabled />
    <script><![CDATA[
      note_no = 1
      game.notes = NewStringList()
      foreach (n, game.notes_raw) {
        nt = "Note " + ToString (note_no) + ": <i>''" + n + "''"
        note_no = note_no + 1
        list add (game.notes, nt)
      }
    ]]></script>
  </turnscript>

The reading command is unchanged.

  <command>
    <pattern>notes; read notes</pattern>
    <script><![CDATA[
      msg ("Your notes: </br></br>" + FormatList (game.notes, "</br></br>", "</br></br>", "You haven't taken any notes.") + "")
    ]]></script>
  </command>

With the turn script notes are listed like this:

Your notes:

Note 1:''blablabla''

Note 2:''claclacla''

Note 3:''gragragra''

The following command will remove the note you want to and each remaining note in the list still have a correct number without anything missing:

  <command>
    <pattern>remove note #text#</pattern>
    <script><![CDATA[
      if (IsInt (text)) {
        msg ("You removed a note:  <i>" + StringListItem (game.notes, ToInt (text) - 1) + "</i>")
        list remove (game.notes, StringListItem (game.notes, ToInt (text) - 1))
        list remove (game.notes_raw, StringListItem (game.notes_raw, ToInt (text) - 1))
      }
      else {
        msg ("please type the number of thennote.")
      }
    ]]></script>
  </command>

If I type "remove note 2" and read the notes again it will list like this:

Your notes:

Note 1:''blablabla''

Note 2:''gragragra''


I assumed the OP specifically wanted to create note objects, so they could be left in different places.


I assume that too and I kinda like the idea. Though it would clutter my game, I think. But I think of the Idea to combine these two by adding the option to remove a note from the notebook in order to place it somewhere else. Notes as objects just opens up more opportunities for puzzles in a game. Like, pulling/creating a note object from my string lists.


I didn't find a good verb/command to pull the notes. This just works with the notes list from above. Just type,''copy note x'' to get the note as object. I limited the alias to the first 40 characters of the copied note and the complete note (should it ever be that long) is in the note's look attribute.

<command>
  <pattern>copy note #text#</pattern>
  <script><![CDATA[
    if (IsInt (text)) {
      msg ("You made a copy of a note:  <i>" + StringListItem (game.notes, ToInt (text) - 1) + "</i>")
      name = GetUniqueElementName ("note")
      create ("note")
      mynote = GetObject (name)
      mynote.alias = Left (StringListItem (game.notes, ToInt (text) - 1), 40)
      mynote.look = StringListItem (game.notes, ToInt (text) - 1)
      AddToInventory (mynote)
    }
    else {
      msg ("please type the number of a note.")
    }
  ]]></script>
</command>

Log in to post a reply.

Support

Forums