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

Taking the current value of a changing variable.

$
0
0
Hey,

It appears I've run into another problem which I can't solve by plain googling. For my game I need to be able to select a commander, for which I've created a loop. However I want the player to be able to click a button to select the commander which they prefer. The code for this is as following.
<<for _i = 1; _i lt 65; _i++>>
 <<if $AreaStats[_i].State is "Allied">>
  <<if $Commander[_i*3-2].Active>><<print $Commander[_i*3-2].Image>>
   <<print $Commander[_i*3-2].Troops>>
   <<print $Commander[_i*3-2].Morale>>
   [[Select|Attack2][$AttackingCommanderNumber to (_i*3-2)]]
  <</if>><<if $Commander[_i*3-1].Active>><<print $Commander[_i*3-1].Image>>
   <<print $Commander[_i*3-1].Troops>>
   <<print $Commander[_i*3-1].Morale>>
   [[Select|Attack2][$AttackingCommanderNumber to (_i*3-1)]]
  <</if>><<if $Commander[_i*3].Active>><<print $Commander[_i*3].Image>>
   <<print $Commander[_i*3].Troops>>
   <<print $Commander[_i*3].Morale>>
   [[Select|Attack2][$AttackingCommanderNumber to (_i*3)]]
  <</if>> 
 <</if>>
<</for>>

Now the problem appears to be in this part.
[[Select|Attack2][$AttackingCommanderNumber to (_i*3)]]
This takes the latest value of _i instead of the value of _i at the time of creating that part.

When googling I found someone who had a similar issue which was solved by doing something like + _i +, but I could not seem to get that working.

Thanks a lot in advance.

Viewing all articles
Browse latest Browse all 1844

Trending Articles