Forum Discussion
Keypad Input simulation - 8th digit glitch
Hi Cassie. Very late in responding to your kind words. I hope it worked perfectly for your project.
I know this is a long shot but I don't suppose you figured out the failure of logic in the first post (file)?
I haven't solved it myself and was hoping some math guru could explain where it goes wrong in the file.
Anyway, no worries. Glad you liked the demo.
- Nathan_Hilliard3 hours agoCommunity Member
That actually appears to be a bug in how Storyline is adding to values over 7 digits. With multiplication alone, the number can extend to 17 digits. If you add anything to a number over 7 digits however, even adding 0, the number gets truncated and just increases by a factor of 10. Probably some kind of rounding error in the internal math. I'm kind of suprised that this would still exist after this long.
I tried some variations on the calculation, but they all ended up with the same result. The fix for this would be to use a JavaScript trigger to add the values. Create another numeric variable called keypress. Use it to hold the key value clicked by the user (0 to 10). Then, create one more true/false variable called triggerAdd.
Now instead of using the multiply by 10 and add 1 triggers for each key click, add the following JavaScript triggers for each:
Finally, create the following Execute JavaScript trigger:
Using this code:
let kp = Number(GetPlayer().GetVar("keypress")); let val = Number(GetPlayer().GetVar("INPUT_DRIVER_ID")); val = val * 10 + kp; GetPlayer().SetVar("INPUT_DRIVER_ID", val);
The remaining triggers should be OK.
Demo: https://360.articulate.com/review/content/f6491348-9628-410c-aad9-5286ea856bce/review