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

Triggering a twine sugarcube widget with javascript?

$
0
0
Hello all. Simple question... how do I trigger a twine widget from pure javascript code?
setup.enemycd = function () {
	var elem  = document.getElementById("enemycdbar");
	var width = 1;
	var id    = setInterval(frame, state.active.variables.enemy_cd2);

	function frame() {
		if (width >= 100) {
			clearInterval(id);
                        <<twine_widget>>;
		}
		else if (state.active.variables.enemy_is_stunned != 0) {}
		else {
			width++;
			elem.style.width = width + '%';
		}
	}
};

Basically once the width of the "enemycdbar" hits 100%, my <<twine_widget>> is triggered. Obviously the "<< >>" syntax is just to show what I'm trying to achieve, I know it's not the right way to do it in pure javascript >_<.

Viewing all articles
Browse latest Browse all 1844

Trending Articles