Forum rules - please read before posting.

Popup Value Resetting at Runtime

edited September 2018 in Technical Q&A
Hey Chris (all),

I've been looking through here but can't find anything relevant to my new problem. I have a custom action I've made that can set or get an Inventory Items property value, the custom action works perfectly as required however there is a very weird issue that I'm struggling with. I've created the custom action by butchering other actions as I'm not very advanced at all when it comes to scripting.

Essentially I have certain evidence items that the player can pick up. At time of pick up I check whether they are wearing gloves or not (or whether they have previously touched the item without gloves on) and then based on that information I can then set the property value of the piece of evidence they have just collected. So if they used their gloves then set property value 0, if they used their gloves this time but touched the item with their hands previously then set property value as 1 and if they never used their gloves at all then property value is 2. So with the custom action I have I can, within the action list editor, select the relevant inventory item via a popup and then in the below pop up I can set which property value to set (either 0, 1 or 2). So I can set these up so that if A happens then set property value to 0, if B then 1 and if C then 2 however when I then click play at runtime all the property value fields reset to 0 in the action list? So I'm left with if A then 0, if B then 0 and if C then 0.

If I change these values in the actionlist at runtime during play mode then they don't change and it works fine however that's obviously not a fix at all. Not sure if it matters but the values stay at 0 then once I exit play mode too. I'm really not sure what is forcing these values to reset back to 0 at runtime, I presume a snippet of my custom action code is required to assess the problem, I'll send this if acceptable however I'll await the ok from Chris, I don't believe this will be an issue however always worth checking first when it comes to AC code, even though it is a custom action.

Thanks in advance,


  • Inventory properties are not designed to be changed - they're read-only.

    The Inventory: Property to Variable Action can be used to transfer a property value to a variable so that it can be read/set with the Variable: Check / Variable: Set Actions, but it can't be "transferred back" to the inventory item.

    When defining them in the Inventory Manager, you're affecting their default values within the Inventory Manager asset file.  At runtime, copies of each item are made - so, if you did want to make changes, you'd have to be sure to apply them to the runtime copies themselves and not the original asset.

    This is basically just a case of referring to RuntimeInventory instead of InventoryManager in your script(s).

    However, changes you make won't be saved - either when exiting play mode, or when loading a save game file.  A tutorial for writing your own global save data can be found here.
  • Hey Chris, thanks for the quick response as usual.

    Doesn't sound like I'll be able to do what I want then? I made sure that I was accessing the runtime inventory in my script so no issues there however even if I followed the tutorial you kindly linked for writing my own global save data to save the new property value I'm stuck with regards to how I actually set the value considering the fact that I'm unable to specify values in the action list editor because of them resetting to 0 at runtime.

    It's not to worry, I'll have to look into possibly just setting up a few global variables that can track each items 'property' but I'll remove the actual properties from the Inventory and just use Global variables. It'll mean I'll have a few more variables to create but it's not an issue at all.

    So it seems I've just misunderstood the use of Inventory Properties, obviously if I'm the only one requiring the above then just ignore me. Thanks Chris, whilst it wasn't the answer I was hoping for it at least gives me the answer I needed to know what I now need to do to rectify. Thanks again.
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.