Forum Discussion
Storyline not seeing a numerical variable as numerical
Setting the number of attempts a user has for drag and drops does not seem to work if the base slide is set to "Reset to initial state." That basically makes sense. So I created a numerical variable called "Try". As you can see in this course, the variable is set to increase by one each time the user selects the "try again" button. I displayed the variable so I could see what is happening. It is telling me that the variable is NAN. And, therefore, does not count the attempts to go to Incorrect layer after three attempts have been made. I don't know why it does not see "try" as a numerical value. Can you help me?
- WaltHamiltonSuper Hero
Something went awry with the creation of your variable. When I deleted it, and recreated it, it worked.
There is a bug in the logic. The test to see if there have been three tries happens before the variable Try is incremented. So it considers the first try to be Try 0, and doesn't show the incorrect layer until try four.
- KyleGomon-d40c4Community Member
Thank you Walt. I tried recreating it too, prior to submitting this discussion. It still did not work for me. I will try it again. Thanks for your help.
- KyleGomon-d40c4Community Member
I recreated the variable with a different name and it worked. š
- JoeFrancisCommunity Member
2 interesting things:
- If I set the initial value of Try to 1, I can proceed through the interaction, incrementing with each incorrect attempt as expected
- If I insert a slide ahead of the interaction and set the value of Try to 0 there, I can proceed through the interaction, incrementing with each incorrect attempt as expected
Curiously, I had something similar happen, where I was declaring an array in Javascript (initially populated with comma-delimited zeroes, which corresponded to variables within Storyline which have 0 as their initial values). With each round-trip through the LMS, more of the numeric variables would get flipped to NaN, until all eventually return as NaN.
Does Articulate not understand that zero IS a number?
- KyleGomon-d40c4Community Member
That IS curious! This course is now working for me as there IS a slide before this one. Maybe the lesson here is to use the number 1 as the starting point, just in case.
- JoeFrancisCommunity Member
Or...explicitly declare the value of Try as 0 in the slide just prior to the interaction, and don't trust the Default Value in the Variables dialog to carry through.