Blog Post
TobiasNoeske
Community Member
For this week's challenge I once more used my number cruncher game example from Challenge 278 and added some achievements.
As all fellow gamers know there are some achievements which you simply get for playing, other require some endurance but hardly any skill and some require a lot of skill (or plain luck in case you're unskilled). My achievements are no exception to these general rules.
Can you reach all achievements? Do you have what it takes to be a real number cruncher?
https://360.articulate.com/review/content/0ef6cafb-c6c6-4a82-86f9-5f23359f270d/review
Disclaimer: Still doesn't work in Internet Explorer and leading 0 will always be present in the numeric input field.
As all fellow gamers know there are some achievements which you simply get for playing, other require some endurance but hardly any skill and some require a lot of skill (or plain luck in case you're unskilled). My achievements are no exception to these general rules.
Can you reach all achievements? Do you have what it takes to be a real number cruncher?
https://360.articulate.com/review/content/0ef6cafb-c6c6-4a82-86f9-5f23359f270d/review
Disclaimer: Still doesn't work in Internet Explorer and leading 0 will always be present in the numeric input field.
PaulRodger
5 years agoCommunity Member
Tobias this was good. Just a couple of points is there any way to be able to type in the field without having to delete the 0? I felt I lost some time doing that. The speech bubble at the end slightly covers his face (not a biggie) but it might look a bit nicer if the stem was brought back a bit
- TobiasNoeske5 years agoCommunity MemberI so far have not found any way to remove the 0. As stated above I recycled an older project which had the same issue which I couldn't resolve until now. Apparently unlike text input variables you can't set a numeric variable to "blank". If I use a text variable instead I can't do any calculations. Converting variable types would probably require some JavaScript which I hardly have any experience with.
By the way: you don't need to delete the 0, just type the desired number behind the 0.
As for the speech bubble: Well spotted. I'll fix that.- MathNotermans-95 years agoCommunity Memberi do think Storyline treats variables always as strings...so internally a Number will be converted to a string anyway...
How to do that yourself ?
So how to use strings for your input... and then convert them as Numbers..well thats easy...
to convert any string to a Number Javascript has an standard function called parseInt()
parseInt(input);
this will return a Number...
samples:
===========================
var input = "12";
var myNum = parseInt(input);
console.log(myNum);
=====================
var input = "05";
var myNum = parseInt(input);
console.log(myNum);
===========================
Note: If the first character cannot be converted to a number, parseInt() returns NaN.
So if using a space or non-numeric character you get NaN as return... so you have to check that too... buildin function isNaN( ) can handle that...
var input = "";
var myNum = parseInt(input);
if(isNaN(test){
console.log("this :"+myNum+": aint a number, NaN");
}else{
console.log(myNum);
}
===========================
Hope this helps a bit :-)- TobiasNoeske5 years agoCommunity MemberThanks, that certainly helped! As mentioned before I hardly know any JS so any idea and common way to solve typical issues is highly welcome.