I'm using the latest Sugarcube and have run into some dumb problem. Code looks something like this:
So, it causes a error - dialog opens, but $battle.chardescr happens to be completely at the mercy of random - on link [?] press it either works as intended first couple of times, becomes undefined or _i == 0 and thus it shows description for only the first ally in array. I don't change array inside the loop, it doesn't change in 40ms period, so i assume it's replace macro that's at fault? Similar code for a different functionality reloads the page and always works as intended, but it maybe due to bug having not enough rolls to kick in.
Code:
<<timed 40ms>>
...
<<for _i = 0; _i < $battle.allies.length; _i++>>\
...
<<replace _temp>>\
...
<<capture _i>><<link "[?]">>
<<set $battle.chardescr = $battle.allies[_i]>>
<<script>>
Dialog.setup("Character Detail");
Dialog.wiki('<<display "BattleCharacterDetail">>');
Dialog.open();
<</script>>
<</link>><</capture>>
...
<</replace>>
...
<</for>>
...
<</timed>>