Forum rules - please read before posting.

Saving a List globally

Hi all,

At certain points in my game, the player pulls out a notepad. On the notepad are notes that are essentially collected by performing actions within the game. I want to integrate this list of notes into AC as much as possible, for saving and loading and so on.

Currently, my solution is to make a global variable of type string, with my notes as comma-separated values. "This is my note 1, this is my note 2..." I then read this global value, convert this to a List, then generate my text elements from this list.

When I come to add notes, I will have to somehow to append the List, then convert it back to a string and then edit the global variable.

Is this crazy? I can't see a better way to do it.

Thanks

Will

Comments

  • p.s. I know about the diary system, but I don't think this would work for me as the notes need to be clickable with actions on each.

    https://adventurecreator.org/tutorials/creating-diary-system

  • What sort of actions / interactivity are you looking for?

    It would be worth considering the use of Documents. Each note could be defined as a separate Document in the Inventory Manager, and the Document: Add or remove Action can be used to add them to the player's inventory at runtime.

    A list of Documents can be listed in an InventoryBox menu element of type Collected Documents, so you can create a menu that lists all those currently held. By default, clicking one will open up the Document menu to view it properly (i.e be able to read through each page). The Document menu is one of the defaults created by the New Game Wizard.

    If you want to do something different upon clicking a document from the list, you can hook into the OnMenuElementClick custom event to control exactly what happens.

  • Thank you, I've essentially got it working now with Unity UI and custom objects, I might just worry about saving with AC later.

  • IS there any possibility global Lists will be added to the variables manager. I'm finding I need them constantly. I would like a list of all rooms I have been to for example.

  • edited September 2019

    My feeling is that trying to manage/read/set list values in Actions would make things much too cumbersome and more trouble than they're worth.

    In the specific case of your example, a workaround would be to create a list of "room" inventory items that get added to the player via each scene's OnStart. These items could be placed in a special category so they aren't visible to the player, and then the Inventory: Check Action could be used to see if they're held by the player (and hence the player has visited a given scene).

    If you're scripting-inclined, however, it's also possible to place custom data types (such as an array) in String variables, since you can combine/split strings with a given separator. For example, let's say the player's visited scenes 1 and 3, but not 2. That could be represented in a single string (0 meaning not visited, 1 meaning visited) with:

    1|0|1

    Custom script / Actions could then extract and combine such a string into readable data.

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.