- Oct 25, 2018
- 22
- 39
I'm trying to link to different captured creatures in an array using unique ids generated using Date now function, and their names which brings up a video. but it just overwrites the id with the last one pulled from the array in the for loop. all the information displays on TrainingArea properly, but when i go to Viewcreature it overwrites the id with the last creature captured (and subsequently the last loop) so all links lead to the last creature. Any help is appreciated.
I can grab info out of the array like this below but it only works for a limited number of times (set manually)
HTML:
:: TrainingArea
<<for _creature range $creatures>>
<<set _creatureID = _creature.id>>
<!-- Link to the single ViewCreature passage and pass the creature ID -->
<<link _creature.name>>
<<set $currentCreatureID = _creatureID>>
<<goto "ViewCreature">>
<</link>>
- HP: <<_creature.currentHP>> / <<_creature.maxHP>>
- Attack Damage: <<_creature.damage>>
- Relationship: <<_creature.relationship>>
<!-- Equip option based on relationship level -->
<<if _creature.equipped>>
(Equipped for battle)
<<elseif _creature.relationship >= 100>>
[[Equip for battle->EquipCreature]]
<<set $currentCreatureID = _creatureID>>
<</if>>
<<silently>>
<!-- Testing links to set relationship levels (Hidden from the player) -->
**[Set Relationship:**
<<link "10">>
<<set $creatures[$creatures.indexOf(_creature)].relationship = 10>>
<<goto "TrainingArea">>
<</link>>
<<link "30">>
<<set $creatures[$creatures.indexOf(_creature)].relationship = 30>>
<<goto "TrainingArea">>
<</link>>
<<link "50">>
<<set $creatures[$creatures.indexOf(_creature)].relationship = 50>>
<<goto "TrainingArea">>
<</link>>
<<link "100">>
<<set $creatures[$creatures.indexOf(_creature)].relationship = 100>>
<<goto "TrainingArea">>
<</link>>
**]**
<</silently>>
<<print "\n">>
<</for>>
[[Back to Hub->HubArea]]
HTML:
:: ViewCreature
<<set _creature = $creatures.find(c => c.id == $currentCreatureID)>>
**<<print _creature.name>>**
<!-- Display relevant information and videos based on creature name -->
<<if _creature.name == "Hinata">>
<<set _videos = [
"Videos/Hinata/Viewcreature/Hinataview1.mp4",
"Videos/Hinata/Viewcreature/Hinataview2.mp4",
"Videos/Hinata/Viewcreature/Hinataview3.mp4",
"Videos/Hinata/Viewcreature/Hinataview4.mp4",
"Videos/Hinata/Viewcreature/Hinataview5.mp4",
"Videos/Hinata/Viewcreature/Hinataview6.mp4"
]>>
Hinata stands before you, her posture slightly hunched, eyes flicking nervously as she waits for your command. Despite her shyness, there’s a subtle eagerness in her stance, as if she’s hoping to prove herself useful, even if she’s unsure how to do so. Her desire for approval is clear, though she struggles to meet your gaze directly.
<<elseif _creature.name == "Krystal">>
<<set _videos = [
"Videos/Krystal/View/Krystalview1.mp4",
"Videos/Krystal/View/Krystalview2.mp4",
"Videos/Krystal/View/Krystalview3.mp4",
"Videos/Krystal/View/Krystalview4.mp4",
"Videos/Krystal/View/Krystalview5.mp4",
"Videos/Krystal/View/Krystalview6.mp4",
"Videos/Krystal/View/Krystalview7.mp4",
"Videos/Krystal/View/Krystalview8.mp4"
]>>
Krystal stands tall, her posture proud yet subdued. She’s clearly aware of her strength and beauty, but the subtle lowering of her head betrays her recognition of your dominance. Though she doesn’t look directly at you, it’s obvious she’s waiting for your next move, ready to follow your orders with a quiet grace that contrasts with her inner pride.
<<elseif _creature.name == "Raven">>
<<set _videos = [
"Videos/Raven/View/Ravenview1.mp4",
"Videos/Raven/View/Ravenview2.mp4",
"Videos/Raven/View/Ravenview3.mp4",
"Videos/Raven/View/Ravenview4.mp4",
"Videos/Raven/View/Ravenview5.mp4"
]>>
You step into the training room, the air thick with anticipation. Raven is already there, standing at attention, her eyes fixed on you with an intensity that is almost unnerving. Her naked body is tense, every muscle poised for your command. The dim light casts shadows that highlight the curves of her form, making her look like a statue of pure, unadulterated desire.
She inhales sharply, her breath hitching as she waits for your next move. Her eyes, though silent, convey an unspoken hunger, a craving for whatever you have in mind.
<</if>>
<<set _selectedVideo = _videos.random()>>
<!-- Display the selected video with autoplay and loop -->
<<= '<video src="' + _selectedVideo + '" autoplay loop controls style="width: 100%; max-width: 800px; height: auto;"></video>'>>
- HP: <<print _creature.currentHP>> / <<print _creature.maxHP>>
- Attack Damage: <<print _creature.damage>>
- Relationship: <<print _creature.relationship>>
What would you like to do?
<!-- Links to separate passages -->
[[Watch from across the room->WatchCreature]]
<<if _creature.relationship >= 10>>
[[Hug->HugCreature]]
<<else>>
You need a relationship level of 10 or higher to hug <<print _creature.name>>.
<</if>>
<<if _creature.relationship >= 30>>
[[Feed->FeedCreature]]
<<else>>
You need a relationship level of 30 or higher to feed <<print _creature.name>>.
<</if>>
<<if _creature.relationship >= 70>>
[[Missionary Sex ->SleepWithCreature]]
<<else>>
You need a relationship level of 70 or higher to access this event with <<print _creature.name>>.
<</if>>
<<if _creature.relationship >= 80>>
[[Anal From behind ->Anal From Behind]]
<<else>>
You need a relationship level of 80 or higher to access this event with <<print _creature.name>>.
<</if>>
<!-- Equip option based on relationship level -->
<<if _creature.relationship >= 100 and not _creature.equipped>>
<<link "Equip <<print _creature.name>> for Battle">>
<!-- Unequip any currently equipped creature -->
<<for _c range $creatures>>
<<if _c.equipped>>
<<set _c.equipped = false>>
<<set $creatures[$creatures.indexOf(_c)] = _c>>
<</if>>
<</for>>
<!-- Equip the selected creature -->
<<set $creatures[$creatures.indexOf(_creature)].equipped = true>>
<<goto "ViewCreature">>
<</link>>
<</if>>
<<if _creature.equipped>>
<<print _creature.name>> is currently equipped for battle.
<</if>>
[[Back to Training Area->TrainingArea]]
HTML:
<<set _creature1 = $creatures[0]>>
<<if _creature1>>
<<set _creatureID1 = _creature1.id>>
<!-- Display the first creature's details -->
<<link _creature1.name>>
<<set $currentCreatureID = _creatureID1>>
<<goto "ViewCreature">>
<</link>>
(ID: <<print _creatureID1>>)
- HP: <<_creature1.currentHP>> / <<_creature1.maxHP>>
- Attack Damage: <<_creature1.damage>>
- Relationship: <<_creature1.relationship>>
<!-- Equip option based on relationship level -->
<<if _creature1.equipped>>
(Equipped for battle)
<<elseif _creature1.relationship >= 100>>
<<link "Equip for battle">>
<<set $currentCreatureID = _creatureID1>>
<<goto "EquipCreature">>
<</link>>
<</if>>
<<print "\n">>
<</if>>
<<set _creature2 = $creatures[1]>>
<<if _creature2>>
<<set _creatureID2 = _creature2.id>>
<!-- Display the second creature's details -->
<<link _creature2.name>>
<<set $currentCreatureID = _creatureID2>>
<<goto "ViewCreature">>
<</link>>
(ID: <<print _creatureID2>>)
- HP: <<_creature2.currentHP>> / <<_creature2.maxHP>>
- Attack Damage: <<_creature2.damage>>
- Relationship: <<_creature2.relationship>>
<!-- Equip option based on relationship level -->
<<if _creature2.equipped>>
(Equipped for battle)
<<elseif _creature2.relationship >= 100>>
<<link "Equip for battle">>
<<set $currentCreatureID = _creatureID2>>
<<goto "EquipCreature">>
<</link>>
<</if>>
<<print "\n">>
<</if>>
<<set _creature3 = $creatures[2]>>
<<if _creature3>>
<<set _creatureID3 = _creature3.id>>
<!-- Display the third creature's details -->
<<link _creature3.name>>
<<set $currentCreatureID = _creatureID3>>
<<goto "ViewCreature">>
<</link>>
(ID: <<print _creatureID3>>)
- HP: <<_creature3.currentHP>> / <<_creature3.maxHP>>
- Attack Damage: <<_creature3.damage>>
- Relationship: <<_creature3.relationship>>
<!-- Equip option based on relationship level -->
<<if _creature3.equipped>>
(Equipped for battle)
<<elseif _creature3.relationship >= 100>>
<<link "Equip for battle">>
<<set $currentCreatureID = _creatureID3>>
<<goto "EquipCreature">>
<</link>>
<</if>>
<<print "\n">>
<</if>>
[[Back to Hub->HubArea]]
Last edited: