I’m having weird problems with clone(), whenever I’m not cloning a simple variable with a string or numerical value. The two problems I noticed are the following:
1). Let’s say I set an array and try to make another as a clone copy of the former one:
<<set $array1 to [
{blah:“bledeblah”,blues:10},
{onemore:[“much”,“stuff”],},
]>>
<<set $array2 to []>> /* I assume this is not necessary, but just in case */
<<set $array2 to clone($array1)>>
Fine, sometimes I found out the inner values match, but then if I do this:
<<if $array1 eq $array2>>
or
<<if $array1 is $array2>>
the result is always false, and I don’t know why.
2). Let’s then stick to the basic <<set $array2 to $array1>> then. I’d like to avoid using it because I understood that it won’t make $array2 an independent array with the same data: it will make them somehow dependant, and changing one may change the other. That’s what I understood anyway, correct me if I’m wrong.
Anyway, let’s say I have no other option than doing it with the simple “set” way. Then the same problem arises when a “goto” order comes in.
To bring a bit more of context, in my game almost everything happens in the same “main” passage. Everything unfolds by “display” connections to different passages, activated by variables, and by “replace” orders coming from widgets. Everytime you click something, an “update” widget makes the passage div’s “display” content to be replaced with the same “display” links as before, thus running it again but with the new variable/array info.
As long as I use this “custom” update method, copying one array to another by the “set” command works just fine, but as I said, if a “goto” kicks in (like pressing enter on a textbox), suddenly <<if $array1 eq $array2>> goes false, even though if I print their inner data, everything seems to match between them.
If the data is the same, could it be the spaces between the commas or something like that? Could it be the “array spaces” get rearranged when loading a passage, making the “is/eq” checks to be false?
How can I prevent this?
EDITS: Sorry, had lots of typos