[Solved] Use variables in references?

How do I…

How do I create a part of a path to a variable from others variables values?

What is the expected result

The path is built with the values of the used variables. So for the example shown in the screenshot, if the object has an id of 1 and Result.Color of 2, the condition should be met since the value of dice.1.1 is “r”. But for some reason this condition is never met (log message does not appear in log at all). So I guess there’s something missing with the references.

What is the actual result

The condition is not met.

Related screenshots

For me, the rules for structure naming are a difficult concept. Here are several examples. The one highlighted is similar to yours. It has a period before the [ . That creates another level or structure without a name. I’m not sure how you would read its value since it doesn’t have a name. You don’t need a period between a variable name and an opening bracket. Meaning fruit.[“apple”] would be fruit[“apple”] while fruit[“apple”]quantity would be fruit[“apple”].quantity A period after a closing bracket or brace but not before [

Here’s how the debugger looks:

I would also avoid using numbers like in my 1st two with a structure. Numbers are usually used for arrays and it could cause a problem. It also might be more difficult to understand and debug if you’re not sure if it’s a structure or an array. If you need to use a number with a structure, it’s best to start it with a letter like “level1” or “level” + ToString(Variable(n)) or “level” + VariableString(n)

Thanks for the hint, removing all (!) dots fixed the problem.

But I agree, this is not intuitive at all.

1 Like