Please specify version and format if asking for help, or apply optional tags above:
Twine Version: 2.3.8
Story Format: Sugarcube 2
I’m setting up an Entity system that uses passages to initialize an Entity that is then processed by functions before being returned to the original call, like so:
- <<set $foe to getEntity(“goblin”)>>
- This calls a function that uses state.display(“foe_goblin”) to init the new goblin Entity object
- Function returns object reference and stores in $foe
However, this doesn’t work. I can confirm that everything works up to the point the object is stored in the $foe variable (it gets an undefined). While I can get around this using other means, I’d like to know why $foe isn’t its value when the function is returning the object.
I come from a Java and C++ background, so I’m iffy on JS and designing object-oriented systems with Twine, FYI.