If you are requesting technical assistance with Twine, please specify:
Twine Version:2.3.14
Story Format: sugarcube 2.34.1
Hi there i am new to Twine and i am trying to implement a fight logic to my story. I have an inventory stored in an array of strings. Depending on the item selected the logic will be diferent. I have created links from the array but i cant find the way to specify where i want them to be linked separately.
Here i create the array
<<for _i to 0; _i lt $enemyAttack.length; _i++>>
<<set _link to $enemyAttack[_i]>>
[[_link|Combat]]<br>
And from there i have no idea how to keep implementing my code as if the link is for example “a gun” i want to develop a type of attack diferent than with the knife.
Thanks in advance
<<set $enemyAttack to ["a knife", "a gun", "a stone", "a rock"]>>
There's a man standing right behind you. You only have time enough to draw a weapon.
<<for _i to 0; _i lt $enemyAttack.length; _i++>>
<<set _link to $enemyAttack[_i]>>
You want to draw <<link _link _link>><</link>>
<</for>>
It should send the reader to a passage dedicated to each specific weapon.
The code will send the player either to a passage named “a knife”, or “a gun” etc.
Then you could write and code whatever you need in each of those.
For instance “a knife” passage might start like this ($character_melee should have been set):
You draw your knife as quickly as you can and swing it before your opponent.
<<set _dice to random(1,6)>>
<<if _dice gt $character_melee>>You cut your opponent's arm.<<else>>Your opponent dodges your weapon<</if>>
Uauh is working!!! Thanks a lot i apreciatte your time, help and pattiente. Can i ask you why is puting the “a” before the weapons. ex “You want to draw a knife”