I've been racking my brain on this for some time now and I can't think of a way to do it. I want to create a set of links inside of a for loop using the length of the array as the number of links and the items in each slot in the array as the link names. So if I have an inventory array consisting of 3 items i'd want 3 links with the items in each slot as the link names. This part, I can do.
The part I'm stuck on is they will all link to the same passage but I can't figure out how to pass through the variable that the user wants. Say the user wants to use or equip item 2 out of the 3. How can I pass the value of item 2 through the link if it's generated in a for loop for an array of unknown size?
In my example, I'm using objects to store items in classes and subclasses (Armor.TypeOfArmor.MaterialOfTypeOfArmor.Properties). Where TypeOfArmor is helm, shield, chest etc... MaterialOfTypeOfArmor is iron, steel, wood, etc... and properties are things like name, defensive capabilities, durability etc...
Code I have:
<<for $i to 0; $i lt Object.keys($Armor.Helm).length; $i++>><<set $temptext to Object.keys($Armor.Helm)[$i]>>
<<print ($i+1) + ". ">>ChosenHelm
This code currently spits out all the links I want properly but doesn't pass the MaterialOfTypeOfArmor through the link that I want.
Can anyone help with this problem?
The trick is to use a <<print>> macro to create a markup link based on the relevant variables. ... the above should generate three markup links which all have a Target Passage Name of ChosenHelm and with Link Texts of:
I want the next passage to be passed a variable based on which link was clicked in a way that I can use it to change the $Character.Helm variable to either point to the specific helm in $Armor.Helm.TypeofHelm.PropertiesofHelm Datamap object or have that part saved to another array to just become an array consisting of Typeofhelm.PropertiesofHelm so I can use it and have the game recognize it's "equipped".
Basically the character will go into their inventory and click on a link generated and I want the game to set a variable based on which link they clicked. so if they click the third link then the game will set a variable so I can use it to tell the $Character object that the steel helm is equipped. same with the second link or fourth link, or hell, if I include 20 helms, I want it to know that the player clicked that 20th link.
Any way I can do this using a <<click>> macro or anything?