WestonSmith wrote:(1) I've set up the variable to count down to zero. It's set so that it counts down by (1 / 60). However, SMBX shows the decimal places when doing this. Is there a way to set how many decimal places appear when printing variables to SMBX?
So, you're converting a floating point number to a string, and you don't want decimal places? Two ways come to mind: 1) Use the lua function "
math.floor" or "
math.ceil" to convert the number to an integer before you concatenate with your string, or 2) Use the "
string.format" function which gives you good control over exactly how many decimal places (if any) among other handy things
Btw, you may want 1/65 rather than 1/60, because SMBX uses a strange 65 FPS.
WestonSmith wrote:(2) Getting the timer to stop at zero should be a simple matter of only running the Countdown function if the variable is above zero. Once it reaches zero, the countdown should cease. However, when I run code as such, the entire script stops working. Do I have to define an 'else' statement to do this?
It's hard to know why it stops working without being able to know exactly how you tried to accomplish it (i.e. what change in the code did you make precisely? Post the code?). Shouldn't require an 'else' generally.
WestonSmith wrote:(3) I don't understand how to make a layer appear via Lua. Is it run as a seperate function ala OnLoop, or is it run as an if statement within a function? The wiki doesn't seem to spend much time on how to work with layers.
As of the most recent official release (LunaDLL 6.1.1) there's no way to directly make a layer visible, instead you have to create a SMBX event in the level to control layer visibility and then use the triggerEvent function in Lua. In the next version of LunaDLL (0.7) there will be ways to directly control layer visibility though.
WestonSmith wrote:(4) Can Lua stop an OnLoop function (the timer counting down) via an OnEvent function?
Nothing can ever stop the onLoop function, but you can put an if statement in your onLoop so that the relevant code doesn't run after some variable gets set by your onEvent function.