Can you refer to an object property via a variable?

Hello all, so I would like to be able to access and set my player’s object properties using another variable. This doesn’t work but is there a way to do it? Thanks.

<<set $skillname = “Crafting”>>
<<set $player.$skillname = 5>>

If you are requesting technical assistance with Twine, please specify:
Twine Version:
Story Format: 2.314

Ah, figured it out, brackets ftw.

<<set $player[$skillname] = 5>>

1 Like

For further details on this answer, see Greyelf’s excellent reply to this same question over at r/twinegames.

1 Like