Quantcast
Channel: Twine Forum
Viewing all articles
Browse latest Browse all 3830

Question about using an external js file in combination with the animated dice script.

$
0
0
hello all,

I would like to use the animated dice script (a javascript from long ago ;)) inside my Twine game. If I execute test.html (a plain html structure) everything works as expected (see .zip file), but if I copy paste the html table containing all the code (inside a twine passage) I get an error (see .jpg file). I think this has something to do with globals? but I'm not sure and I'm puzzled how to fix it and get it to work in my game.

I've included all the files (including the error message screen shot). I use twine 1.4.2 in combination with sugarcube-2 (the latest version).

*****
page 2 of my twine game:

<<script type='text/javascript' src='d6.js'>><</script>>

<table width="90%" align="center">
<tr>
<td align="center">
Press button to roll dice:

<<script>>
function check(result) {
document.getElementById("total").textContent = result;
}
D6.dice(2, check);
<</script>>

<span id="total"></span>
</td>
</tr>
</table>

****

I have also tested loading the external js file via a "Config" script file in twine with this syntax (TheMadExile tip):
(function ($) {
$(document.head)
.append('<script type="text/javascript" src="d6.js"></script>');
})(jQuery);

but same error: "bad evaluation: D6 is not defined"


I hope someone can help me out with this?

With kind regards, Jeroen Wolf

Viewing all articles
Browse latest Browse all 3830

Trending Articles