Hi, all!
I use Twine 2.1.3 and Sugarcube 2.18.0, and I have these two definitions:
<<set $spider = {
name: "Araignee"
}>>
<<set $C01 = {
opponent: $spider
}>>
I thought that <<print $C01.opponent.name>> would print "Araignee", but it doesn't. I'm told that opponent is undefined. How come?
Thanks in advance.
Comments
Are you sure you have correctly spelt the property names in your actual code?
NOTE: Due to how the state of all known story variables get cloned/copied each time passage traversal occurs, the $spider variable and the $C01.opponent property will end up referencing two different but initially 'equal' objects.
Once this occurs changing the value of $spider.name will not result in the value of $C01.opponent.name changing as well.
I have deleted that and put everything in "StoryInit", and now that works. So, I have the workaround (the most important) but not the explanation. If <<include>> doesn't work in "StoryInit", that's a pity. I very much like a modular design for every project of mine, an old habit.
Still, thanks for your help :-)
note: Using TWEE notation, and the Start passage as the starting point.