Hi, I’m using Harlowe 3.1.0 and I’ve been trying to figure out if there’s a way to do this. I’m trying change the background of a div element in a passage according to a variable that gets established in an earlier passage.
My variable is $scene, which can be different strings like “beach”, “store,” etc.
I was trying to see if I can concatenate a string to make a div element. I’ve tried a few things like the following:
(text: “
and
(for: each _loc, …(arr: $scene)[
(text: “<div class=‘img-box’” + “id=’” + $scene + “’>”)
]
…and here is the passage that I’m working on, for reference:
<div class="content-container">
<div class="img-box" id="beach"> <!--This is the element I'm trying to replace with dynamic id references-->
<div class="info-container">
<div class="location-info">
<h2>$scene</h2>
</div>
<div class="target-info">
<!-- Begin RNG Images -->
<!-- End RNG Images -->
</div>
</div>
</div>
<div class="text-box">
<div class="story-container">
<div class="test-tube-box">
(display: "Info")
</div>
<div class="story-text">
<!-- Begin Story Text -->
<!-- End Story Text -->
</div>
</div>
</div>
</div>
However, neither one is having much success. I was wondering if I’m missing character escapes to make it work, or if it is just not going to work. I saw some posts about possibilities with Sugarcube, but I am more familiar with Harlowe and didn’t want to change story formats.
Additionally, I saw some ideas for how JS could be used, but I am unfamiliar with how to integrate JS with Twine variables. If anyone has an idea of where I’m going wrong, or how to get a working solution, I’d appreciate the help.