Greetings
Twine 2.0, SugarCube 1.0.34.
I have the whole concept planned out, but then I got an error and realized the fault of it.
The loop is this:
The problem is
Can this even be done, and if so, how? I know I can just manually list every item with a separate if statement, but I'd tried that and the formatting becomes an issue because always a new, empty line is created if amount of an item (I use static indexes) is 0, not to mention the giant amount of sheer text that is required to be copypasted. An unnecessary baggage.
Best Regards
Twine 2.0, SugarCube 1.0.34.
I have the whole concept planned out, but then I got an error and realized the fault of it.
The loop is this:
<<for $i=0 ; $i < $TotalConsumableItems && $ConsumableItems[$i] > 0; $i++>> <<nobr>><<print $ConsumableItems[$i] + "x " + $ConsumableItemsDetails[$i].name>> <<if $ConsumableItemsDetails[$i].hpbonus > 0>> [+$ConsumableItemsDetails[$i].hpbonus @@color:red;HP@@] <</if>> <<click "(Look at)">> <<set $invEquipScreenItem = $ConsumableItemsDetails[$i].name>> <<set $invEquipScreenAction = "lookat">> <<goto invEquipScreen>> <</click>> <<if $ConsumableItemsDetails[$i].type == "food">> <<click "(Eat)">> <<set $invEquipScreenItem = $ConsumableItemsDetails[$i].name>> <<set $invEquipScreenAction = "consume">> <<goto invEquipScreen>> <</click>> <<elseif $ConsumableItemsDetails[$i].type == "drink">> <<click "(Drink)">> <<set $invEquipScreenItem = $ConsumableItemsDetails[$i].name>> <<set $invEquipScreenAction = "consume">> <<goto invEquipScreen>> <</click>> <</if>> <</nobr>> <</for>>
The problem is
<<set $invEquipScreenItem = $ConsumableItemsDetails[$i].name>>At the first iteration the $i is equal to 0, and I'd like the created set macro use $ConsumableItemsDetails[0].name. Not the $i that's remaining after the entire loop, which is static for all the buttons and is equal to the latest item in the array.
Can this even be done, and if so, how? I know I can just manually list every item with a separate if statement, but I'd tried that and the formatting becomes an issue because always a new, empty line is created if amount of an item (I use static indexes) is 0, not to mention the giant amount of sheer text that is required to be copypasted. An unnecessary baggage.
Best Regards