0 votes
by (120 points)

Hello everyone,

I am new to SugarCube and i've been struggling with the following problem. 

I have a array (myArray) that contains several elements. I try to set a variable through the link setter before moving to next passage as follows:

<<set $myArray to [{prop:"A"}, {prop:"B"}, {prop:"C"}]>> 

<<for _i to 0; _i lt $myArray.length; _i++>>
	Get [[nextPassage][$myVariable to $myArray[_i]]]
<</for>>

The problem is that $myArray[_i] is not affected to myVariable. The $myVariable is undefined when i want to use print it in nextPassage. (Error: <<print>>: bad evaluation: Cannot read property 'prop' of undefined)

Can you please tell me how i could implement this functionnality without having to write manually one by one the content of myArray ? 

Cheers,

Dranzeur

1 Answer

0 votes
by (68.6k points)

You need to use the <<capture>> macro.

...