Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

How to access Harlowe variables in Javascript

$
0
0
Hello!
I'm trying to make some randomization with images and it would be super useful to access variables I set in Harlowe inside the Javascript, but I can't find out how to do that...

Here's an example of what I want:
(set: $has_book to true)

<div id="img_holder">
   <img class='overimg' src='bg.png'>
</div>
<script type="text/javascript">
   var images = ['left','right','left2','right2'];
   if ($('$has_book').value==101)
   {
      $('#img_holder').append("<img class='overimg' src='" + images[Math.floor(Math.random() * images.length)] + ".png'>");
   }
</script>


So, the idea is to access $has_book from inside the Javascript, is that possible?
Thank you

Viewing all articles
Browse latest Browse all 1844

Trending Articles