Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

Object reference and changing multiple values

$
0
0
I work on Twine 2, with story format Harlowe 1.2.3.
I wanted to prepare a few objects, e.g:
(set: $object1 to (datamap: "name", "Object 1", "value", 1))
(set: $object2 to (datamap: "name", "Object 2", "value", 2))

and then I want to create an object which is the reference to one of this previous objects
e.g.:
(set: $currentObject to $object1)
Now everything's ok, when I call : (print: $currentObject's name) the result is "Object 1", when I change: (set: $currentObject to $object2) and call again (print: $currentObject's name) the result is proper: "Object 2".
When I change one of the values of datamap (set: $currentObject' value to 5) and when I change the current object and back to previous one - everything seems to work fine. The problem is when I want to change more than one value of current object.
E.g.:
This works:
(set: $currentObject to $object1) ... (set: $currentObject's value to 5) ... now I can change current object, then back to object1 and the value is changed,

This don't work and I don't know why:
(set: $currentObject to $object1) ... (set: $currentObject's value to 5, $currentObject's name to "New Object's name")
and change object to $object2 and then I back to the object1 - it shows the old, unchanged values.
I don't know why, when a I change 1 value - everything's ok, when I want to change more - it don't work at all.

Viewing all articles
Browse latest Browse all 1844

Trending Articles