Forum rules - please read before posting.

Struggling with adding parameter values together

Happy holidays, first of all - none of this is urgent, so don't worry about rushing to help with my question in the upcoming few days!

I'm running into a bit of a problem with using parameters, and hopefully I'm just missing out on something obvious; is there a way for me to add a Global Variable parameter to another value? As far as I can tell, I'm only able to add Integers and Floats to Global Variables, and not add them together.

If this is unclear, here's a more detailed explanation of what I'm trying to achieve;
I've created an actionlist called "DiceRoll", with three parameters; Attribute, Skill, (Both Global Variables, both Floats) and Target (a Float). In the prototype I'm working on, whenever the player performs an action that requires a dice roll, the Actionlist is triggered.

For example, let's say the player interacts with a Hotspot called "Broken Car", and one of the Interaction Icons is "Repair". The player chooses this interaction, and the Hotspot actionlist, in turn, runs "DiceRoll" with the following parameters;
1. Attribute set to Dexterity (Global Variable, Float)
2. Skill set to Repair (Global Variable, Float)
3. Target set to 8 (Manually as a Float parameter in the Broken Car interaction ActionList)
4. Finally, at the start of "DiceRoll", a random number is generated. (RN, also a Float)

I'd like to add both Attribute and Skill to that number before comparing it to Target, (RN + Attribute + Skill >= Target) but I'm struggling to find a way to do so - the only parameter I seem to be able to add is Target, the Float. Is there a way to add Global Variable parameters to each other, or extract the value in the parameters and random number to add to a single "Total" variable? Or is there a much simpler way of doing this that I'm missing?

Comments

  • You'd need to extract them, as AC won't be aware of exactly what type of variable is assigned to a "Global Variable" parameter.

    One way to approach this would be to create a pair of Global Float variables that act as "temp variables". You can transfer the parameter values to these temporary variables using the Variable: Copy Action, and then sum them using Variable: Set.

  • I'm able to copy the parameters to Global Floats, but I'm still not able to add them together or to a single "Total" Global Variable. Right now I'm working around it with some custom code, but I figured I'd ask in case I was missing something!

  • The Variable: Set Action has a "Formula" option when dealing with Float and Integer variables. Inside this, you can use variable tokens to add multiple variables together.

    For example:

    [var:1] + [var:2]
    
  • That makes sense - I was trying to add them by name or as you would in code, but didn't try [var:X]! Much appreciated, everything's working fine now!

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.