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

How to call js functions with SugarCube 2 [Twine 1]?

$
0
0
I've got this function in my "script" passage:
function fadeInText(id, delay) {
var elem = document.getElementById(id);
setTimeout(function () {
elem.style.opacity = 1;
}, delay * 1000)
}

I would like to call it in passages to fade in specified text areas or other elements on entering the passage (selected via <div id="...">)

I'm very frustrated as I simply cannot call that function from my passage. I've tried calling it using <<script>> or via <<run>>, but I only get errors such as "expression not defined" or unspecified js errors. Is it not possible to call a JS function from out of a passage? What is my mistake? I also couldn't find any section in the SugarCube documention that clearly addresses my question.

Viewing all articles
Browse latest Browse all 3830

Trending Articles