0 votes
by (170 points)

Hello reader. I'm trying to use the Setting API to add an option to change the font size. While attempting to add a font size option as a range, it would give me an error stating this:

"Error [StoryInit]: <<run>>: bad evaluation: Setting.addRange is not a function."

I am sure that this is definitly the code causing the problem, as it's the only addRange method in the game.

<<run 
Setting.addRange("fontSize", {
	label    : "FontSize.",
	default  : 16,
	min      : 8,
	max      : 24,
	step     : 1,
	onChange : function () {
	document.getElementById("interface").style.fontSize = settings["fontSize"];
	}
});
>>

This snippet is almost a copy from the example in the in SugarCube documentation. I successfully used the Setting.addHeader() method on the line preceding this one, so I'm not sure what is happening here.

This is the first question I've asked on here, so hopefully I did a good job.

1 Answer

+1 vote
by (63.1k points)
selected by
 
Best answer
You need to upgrade your install of SugarCube. The one packed with the current (non-beta) version of Twine is almost a year old now. See here for instructions: http://www.motoslave.net/sugarcube/2/docs/#guide-installation-twine2

Note that you can use <<run>> and <<script>>, but the Settings API methods are typically best called in Story JavaScript, since it's processed earlier, avoiding any potential weirdness.
by (170 points)
I see now. Thank you for the information.
...