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

[SugarCube 2.9.0] Cloning an object and all sub-objects, and a question about the Set macro.

$
0
0
Hello,
I'm looking to clone an object and all of its sub-objects (and their properties) into a new object with a different name, but I didn't see a way of doing this in SugarCube 2's documentation. I saw quite a few methods of doing this through JavaScript/jQuery on stackoverflow, but I'm not familiar enough with JS to know which method would be 'proper' in this situation.

Side question:
I noticed that you can group variable assignments and object creation with the Set macro, like so:

Individually:
<<set $foo to {}>>
<<set $foo.bar to {}>>
<<set $foo.bar.foobar to {}>>
...

Grouped:
<<set $foo to {},
$foo.bar to {},
$foo.bar.foobar to {},
...
>>

Is there any benefit to doing it one way over the other?

Thank you for your time.

Viewing all articles
Browse latest Browse all 1844

Trending Articles