Input Number Variable

Hey so I am wondering if someone can help me out?

I am building a concept for a quiz where rather than selecting an answer you would be able to bet points against an answer being correct. The points bet on the correct answer get doubled, and points bet against incorrect answers are lost.

On the most part I have this working, but I have encountered a small bug that I am wondering if anyone has found a work-around for?

I have 4 Numeric entry fields - one for each answer option - these start off with '0' in the boxes, if  you come to type in the box and you delete the '0' but 'forget' to type in another number it records as an error as only numbers should be in the numeric field!

Is there a way to set the variable back to '0' if the control loses focus when the box is blank?

(attached is a very rough example - if you click outside the box when nothing is in it)

4 Replies
Jeff Forrer

One suggestion. When the user clicks the button, add a trigger to show another layer with a message to the user to enter a number 1 or greater, on condition if the entry is less than 1.  Add another trigger to show your target layer on click of the button, if the entry is greater than or equal to 1.  That way the user has to enter a valid number to show your message.

Lizzie Angell

Thanks Jeff

I tried to do something a bit like that - but the variable needs to adjust the main score as you put the numbers in - therefore has to use 'when control loses focus'.

When you click and the field is blank it wont register as being 'more than' or 'less than' any more as there is no number to compare to - I wondered about putting it so that if the number variable = blank make it '0' but there is no way to do this in Storyline.

Thor Melicher

Lizzie,
It's been awhile but I did find a possible solution for your problem.  At least, it works for the example you posted. :)

The idea is to:

  • Create another variable
  • Set it to the numeric entry field when it loses focus and 
  • Before subtracting from the total score, check to see if the variable is greater than or equal to 0

I created a variable called CheckAnswer and this is how the trigger order looks like:

If the numeric entry field has nothing in it then CheckAnswer will be NaN (not a number) and will prevent the subtraction from occurring.  Although it doesn't set the box back to 0 it does prevent the error. :)