Forum rules - please read before posting.

Set popup variable content at runtime

I need to store specific values for AC hotspots that are enabled/disabled from a Playmaker FSM (PM is used for game logic - it enables/disables hotspots and assigns specific actions to them according to various conditions), so that when the player clicks on these (at any time later in the game), the actions that follow are dynamic.

I want to store this information in an AC popup variable with an index specific to the hotspot (I change the data in the popup at that index). My issue is that AC doesn't seem to be able change a popup's content within an ActionList. If I use the Variable - Set or Variable Copy operations on a popup, I can only impact it's index, not the content to which it refers. I know I could write a script such as:

GlobalVariables.SetPopupValue (int variableID, int value); (I need to set the second value)

But wouldn't it be possible in the ActionList editor to have the ability to specify a value for the Variable - Set operation when the variable is a popup?

A few other questions if anyone has done this before and could help:

- Call an AC ActionList from a Playmaker FSM (I'm currently using variables and an AC ActionList running in the background to interface the plugins, but would be easier to be able to directly call an AC ActionList, possibly with parameters). Didn't find anything like this on the AC Wiki

- A script that retrieves the Constant ID number of a "Remember Hotspot" component attached to a hotspot. The idea is to be able to have the "Use" and "Examine" interactions of a hotspot call a generic ActionList to retrieve the hotspot's ID, instead of having to create an ActionList for each hotspot (I have many) which then calls a generic ActionList to pass parameters (trying to do something similar to the object ID passed on for the "Inventory Interactions"). An alternative to this would be to add an ID by default to AC hotspots which would be always passed on to a called ActionList as the first parameter.


  • Found an answer to my first question about linking with PM here:

    Perhaps this could be added to the section in AC's manual about integrating with Playmaker?
  • The "labels" of a popup variable can't be saved.  They're not designed to be changed at runtime, and are there more for reference / in-game display.

    If you want total control over the storage of information in a variable, use a String.  Through code, you can divide your "sub-content" with a special character such as a colon, and then split into an array again when you need to read it.  AC does this itself when saving certain data types - see for example, the GetSaveData and LoadData functions of ActiveList.cs.

    Any AC ActionList or ActionListAsset can be invoked by calling its Interact() method - see Section 5.19 (Interaction scripting) in the Manual.

    An object's Constant ID number can be retrieved with:

    myGameObject.GetComponent <ConstantID>().constantID;
    (For a complete reference of all AC public functions and variables, see the Scripting Guide).

    If a Hotspot's Interaction has a GameObject parameter, then the Hotspot can be linked to that parameter within the Hotspot Inspector.
  • Thanks Chris for this update regarding the hotspot unique ID.

    As far as using strings with a separator instead of arrays, this is not a solution for me and I would rather have liked to be able to use the popup variable labels, as:

    - Using a string which would be parsed to retrieve strings for hundreds of elements is cumbersome, not as elegant as just referencing an index in an array of strings
    - The game is multilingual and the ability to use AC's features for translation management is a plus (which would not be available if I manage everything in a single string)

    Is there any way in which you could in a future release provide array type variables or allow ActionLists to access and modify the popup labels at runtime?
  • edited October 2017
    Having popups be modifiable opens up a can of worms so far as reliable saving goes, and from what I can see this is a very specific issue unique to your game.  Cumbersome or not, it is at least possible with a string.

    The conversion between a string and a string array is fairly trivial, and only needs to be done at the point of saving / loading.  The actual play-by-play management of the variables can be handled in a separate script, and the values can then be sent to the String Variable with the OnBeforeSaving custom event.

    It's also the case that while PopUp labels are translated, these translations cannot be modified at runtime either - so I'm not sure of the benefit of using PopUps would allow.
  • I see the issue with being able to modify popup labels.

    I was really only using popup variables as arrays and wasn't intending to modify translated text at runtime, but point to a given popup index from an array. Let me explain what I'm trying to do:

    Game scenario -> specific conditions trigger events in a PlayMaker FSM ->
    these events enable/disable AC hotspots and determine which AC dialogue will be
    displayed when player clicks on the hotspot (this is where I need to link a given hotspot ID with
    a given index in the popup which contains the dialogue texts). The dialogue text displayed can change for a same hotspot during different parts of the game (managed by the PlayMaker FSM)

    When the player clicks (if he/she does at a given point in the game) on an activated hotspot, it calls an ActionList which seeks the dialogue to display for its hotspot index.

    Basically, what I really need is an int array (I was using a popup variable as you don't have arrays):

    > int array index = hotspot ID
    > int array content at this index = index in dialogue popup variable of text to use (I don't need to modify the text in the popup and can use AC's translation features)

    I'm pretty sure being able to have array variables would be useful to many people?

    I could of course mix AC with C# scripting to do this, but I'm trying to keep everything within AC & PlayMaker.

    Let me know if I've made my need clearer and your thoughts on how to proceed.
  • edited October 2017
    Having a modifyable int array variable type is technically near-identical as modifiable PopUp labels, so the same issue still applies.

    I see your point about keeping within AC / PM, as obviously AC itself is a visual-scripting tool.  But the line does have to be drawn somewhere - and you are trying to achieve something it wasn't expressly designed for, as well as involving another asset.

    IMO scripting is the better option over trying to fit AC around your needs.  I don't know what your coding experience is, but I can help if you need it.  The general principle, as I see it, is as follows:
    1. Create a script that exists in all scenes.  This can be done by marking it as DontDestroyOnLoad, or simply by attaching it to AC's PersistsentEngine prefab.
    2. Store an int array in this script that you e.g. read/write through custom Actions
    3. Use the OnBeforeSaving and OnAfterLoading custom events to convert the array to/from a Global String variable

    However, I'm not sure if this is even the only approach.   Have you considered e.g. altering the value of, say, an ActionList's Integer parameter value that determines what Actions play following an "ActionList: Check parameter" Action?  I'm not completely clear on the fundamental need for this, so please feel free to offer a more detailed explanation on the initial scenario.

  • I'm starting to think that going through scripting is the only solution. I have a background in programming, so not really an issue there (wanted to avoid this however, as I have very little knowledge of Unity itself, having just moved to this platform).

    Your initial suggestion is correct, as the second one would only work if I was calling different ActionLists and wanted to act immediately upon a given condition occurring in my PlayMaker FSM.

    As it stands, these scenario conditions only turn several hotspots on or off and there can therefore be many possible outcomes (player clicking or not on one or more of the many hotspots). When a hotspot is clicked, I also want to call a unique ActionList (not have one per situation), so I therefore need something that is dynamic and has "memory", e.g. an array.

    Thanks anyway for your support Chris, one of the best I've ever experienced (do you manage to get some sleep?). Will get back to you if I have any issues.
  • You're welcome, thanks for your understanding.
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.