Howdy, Stranger!

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

Error with onclick function (Snowman)

Hi!
In my game I'm trying to make it so when you press a button, it will print "Your relationship with Frances has improved!" and then add 1 to this value. Below is my javaScript:
<%
s.FRANCES = function(rstatusup) {
	print("Your relationship with Frances has improved!");
	s.FRANCES = rstatusup + 1;
}
s.FRANCES(0);
%>
<button onclick="rstatusup">Flirt with Frances</button>

What this should be doing is, when you click the "Flirt with Frances" button, it should print "Your relationship with Frances has improved!" and also add 1 to the s.FRANCES value. Instead, when I click the button, I get this error:
⚠ Uncaught ReferenceError: rstatusup is not defined (file:///C:/Users/Alec/AppData/Local/Temp/nw5148_20689/index.html#stories/26d38271-fd3c-5baa-24b7-e9da21c5a0fc/test: 1)

Am I doing something wrong or missing some code that is exclusive to Twine? Maybe someone fluent in JavaScript can help?

Comments

  • Read my answer to your Help! How do you call functions in Snowman! thread.

    There are three main reasons the button element's onclick event is not working:

    1. It is incorrectly referencing a variable instead of a function.
    2. The variable it is referencing is a parameter of a function.
    3. Your can't externally reference a function parameter.
Sign In or Register to comment.