Forum rules - please read before posting.

Adding Journal Pages from Global Variables


I've read through the tutorial and several forum discussion on creating a journal, and I'm running into an issue I haven't been able to resolve.

I'm feeding text into a global variable in iterations so that it creates an ongoing journal using the variable tokens. This works very well, and I was also pleased that AC utilizes text area to allow for line breaks.

At the end of the day in game terms, I trigger an action series that adds the page to the journal using the token, then resets the text variable to blank to allow for new content the next day.

The problem is that when the variable changes, the journal page I added previously created resets itself to the new variable value. The token value overwrites prior values for existing journal pages.

I tested this by putting in actions that open the journal and set a breakpoint just before the global variable is changed. Works perfectly to this point, and displays the journal page content as expected.

In the past, adding a short engine wait has often fixed this sort of concern, but I've also added a wait up to 10 seconds, and it still replaces the journal page text with the new value of the global variable.

I'm also making sure to apply Speech/Gather text after the actions are created, and the IDs appear as expected.

I'm using Unity 2020.3.25f1 and AC 1.74.5.

Thanks to anyone for support


  • edited March 2022

    The new page text entered into the Menu: Change state Action is transferred directly to the Journal without processing.

    That is, if the text is a variable token, then the Journal page too will consist of that token - it'll only be converted to the variable's value as it gets displayed. If that variable value changes, then so too will the journal.

    To get around that, you'll need a custom script function that instead converts the token text before adding it to the Journal:

    public void AddProcessedPageText ()
        MenuJournal journal = PlayerMenus.GetElementWithName ("MyMenu", "MyJournalElement") as MenuJournal;
        string journalText = AdvGame.ConvertTokens ("[var:0]");
        JournalPage newPage = new JournalPage (-1, journalText);
        journal.AddPage (newPage, false);

    This can be called by placing it in a C# script, attaching to a prefab, and then calling that prefab's function with the Object: Call event Action.

  • Ah, understood. And that makes perfect sense when remembering that the journal is a menu element, and global variables tokens will be used as dynamic data.

    The custom script works perfectly, and should help out others with a similar need.

    (I'm at [var:107], for the record, so already going a little crazy on the globals.)

    Thank you for your help and the versatility of AC. It's getting me further into rpg territory than I would have expected.


  • No problem. I think this is a good case for a "Pre-process text tokens?" option in the Action itself, which would avoid the need for the above script.

  • It's nice to wrapped things up in actions, particularly when this could be used for multiple journals and with multiple global variables.

    I did also appreciate the reminder on calling events on an object. I tend to binge project work, then take nice long breaks so I forget half of it. :)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.