Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

[Sugarcube 2.x] State variables in beta8 release - SugarCube.State is not defined

Hey there,

I have a variable in my StoryInit Passage on which i rely in a custom Macro.

StoryInit:
<<set $videoQuality to "hd">>
<<html5loadvideo "wasteland" "media/video/wasteland.mp4">>

Story javascript:
Macro.add("html5loadvideo",{	handler:function(){
	
	/* video qualitaty settings */
	
	var vQ = SugarCube.State.active.variables.videoQuality;

	var fileName = this.args[1];
        var src = fileName.replace(".mp4", '_'+vQ+'.mp4');
	src = src.replace(".ogg", '_'+vQ+'.ogg');
	
	if ($("#"+this.args[0]).length == 0){
		$("body").append('<video id="'+this.args[0]+'" class="html5backgroundvideo" poster="'+this.args[2]+'"  style="display:none;" preload="none"><source src="'+src+'"></video>');
	}
	}
});

Unfortunately I get the following error since beta8 release - I used alpha7/beta2 before:
Error [StoryInit]: cannot execute macro <<html5loadvideo>>: SugarCube.State is undefined.

Help appreciated!

Thanks in advance!

Best regards,
Matthias
Sign In or Register to comment.