New games every week!
JSE - Variables
Blog
30th April 2021
Right then, time to tackle variables.. Aaargh!!!
-=-=- I sat, staring at the code. I had a vague plan in mind. Making use of Javascript's internal "Strings as keys in an array" functionality, this shouldn't be too hard of a task. I headed to the Keywords area, and added an internal "Let" command. The plan isn't to make you write the word Let, but instead to have it automagically pop a Let into the script, wherever a Let is needed. The Let command is merely a "suggestion" to the script engine, and is placed in front of any variables that are themselves in front of a single equals sign. So, I added that, and then added a rather simple "If this isn't a keyword, assume it's more than likely a variable" thing at the end of the script. I added setting and reading of the variable, made use of the Let to tell it when it should be setting or reading, and the functionality that was already in for "n" numbers was used to plonk the values back into memory.. and .. then.. um.. Yeah, that works.
You can try out the above script, in JSE, here. Within just a couple of hours, I had Variables working as expected, and I was quite surprised that they worked as well as they do. (*hopefully!!) I also added simple Mouse control, too, because.. Why not!?! It's all coming together much easier than I intended. Which is usually the point at which things break in ways I could never have foreseen!! The next step is either to tackle Arrays or For/Next loops. Or maybe If's... Not sure which. Who knows!! Views 214, Upvotes 15
Daily Blog
,
Jse
New games every week!
|