Forum rules - please read before posting.

Parameter and replacement tokens

Hi,

I created an action called 'Variable: Set', whose source is a Component Variable. The method is set to 'Formula', so I used a Replace token and subtracted 1.

The next action is 'Menu: Update Content'. I used the same Component variable replacement token to update my menu's label.

This works well, but there's an issue when I use parameters. For the 'Variable: Set' action, if I use a string parameter instead of 'Replacement token - 1', and then use a parameter for 'Menu: Update Content' to set the new label, only the component variable value gets subtracted by 1.

For example, when the component variable value is 3, the Menu label still shows 4. When the component variable value turns to 2, the Menu label still shows 3, and so on. I'm sure there must be a workaround, but I was wondering if there's a way to resolve this while keeping my actions organized. Any advice would be greatly appreciated. Thank you.

Comments

  • I'll need to see the finer details to understand the situation fully. Can you share screenshots of the ActionList, the Variables component, and the Menu Element's properties?

  • edited November 2023

    Thank you for your prompt response and assistance! I have attached three images for clarity: https://imgur.com/a/KfqnDBE

    AssetActionList.png: Here, I've highlighted the relevant actions as 1 and 2, which use string properties. For action 1, my intention was to subtract 1 from the Component Variable. In action 2, I aimed to update the New Label with the new number, reflecting the result from action 1. For instance, if the Component Variable's integer value was initially 5, it should be reduced to 4, and this updated value (4) should be displayed on the label.

    In the scene (InScene.png), I utilized the Replacement token of the Component Variable.

    With my current ActionList setup, the Component Variable is updated, but the New Label is not immediately reflecting this change. It only updates when the ActionList is triggered again. This means if a player activates the ActionList once, the Component Variable value changes from 5 to 4, but the New Label still shows 5. It's only after the player interacts with the hotspot again that the Component Variable value changes to 3, and then the New Label updates to 4.

    Interestingly, when I don't use properties, the system works as expected.

  • edited November 2023

    Thanks, recreated.

    It's a case of the tokens being "processed" at the time the ActionList: Run Action is run. Their values then become a snapshot of what they were at that time.

    Instead of using a pair of String parameters to represent the same variable, use a Component Variable parameter to reference it once.

    Then, rather than overriding the fields with your String parameters, use the [paramval:X] token to reference the "live" variable value.

    That is, set your Variable: Set's "Statement" field to [paramval:7] + 1, and Menu: Update content's "New label" field to [paramval:7]. (Replacing "7" with the ID of the Component Variable parameter)

    Details of the [paramval:X] token can be found in the Manual's "Text tokens" chapter.

  • edited November 2023

    Thank you so much for your guidance. I didn't know about [paramval:X]. I'll look up more and try it out. 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.