Hi, I already asked this on the Q&A forum but only got 1 reply which was not related to the question so I am hoping for a better response here.
In Twine 2 / Sugarcube 2
I have a series of arrays holding data for NPCs generated in the process of my game.
The code is below but in summary a for loop counted against the number of NPCs creates a table displaying the names of the NPCs, What I am looking for is a way to select a name from the table and go to a passage which will populate with information from the series of arrays.
The simple solution would be to have the loop number each entry and then use a text box for the player to enter the number and have the game capture that to reference the array position for the next passage. But this feels crude and hackish.
What I want is a way to select the information by a single click by turning the name into a link, Abandoning the loop is acceptable for a better solution but I don't want to limit the number of stored records if at all possible.
(Note the passage is currently in a prototype stage so presentation is a low priority)
Currently you have <<print $NPCGender.length >> Generated characters
<<for $i=0; $i<$NPCGender.length; $i++>>\
<<print "Name: ">> /*Male*/<<if $NPCGender[$i] lte 3 >> <<print $MFNameList[$Firstname[$i]]>><<print ", ">> <<print "Nickname: ">> <<print $MNNameList[$Nickname[$i]]>><</if>>/*Female*/<<if $NPCGender[$i] gte 4 >> <<print $FFNameList[$Firstname[$i]]>><<print ", ">> <<print "Nickname: ">> <<print $FNNameList[$Nickname[$i]]>><</if>><<print ", ">> Gender: <<print $GenderList[$NPCGender[$i]]>>