Mostly just trying to write down primitives that I figure out so I can reference them later / share them with others.


Actor is the basic unit of a stepmania script.

You can only return one per Lua file, so you will usually put a bunch of Actors in an “ActorFrame”.

Everytime you change the .ssc, you need to reload cache. Lua scripts are read when you play the simfile, so you only need to start the song in the SM5 editor to see changes.


Folder structure:

Afaict, you must have:
simfilename.ssc must contain a line such as:
#FGCHANGES:0.000=default.lua=1.000=0=0=1=====;

and this file layout
simfile/
`- default.lua

And I like to structure things like this:
`- lua/
   `- any_additional_files
  • Enable lua error reporting via holding F3, tapping F6 (theme menu), tapping 8.
  • SM( some_string ) will pretty print tables and possibly pretty much anything to screen.
# From conversation with Dan Guzek:
When working with anything loaded as an FGCHANGE, something needs to be
actively tweening at all times or else the entire file is assumed to be
"done" by the engine and cleared from memory.

The workaround most people use is have a dummy Def.Actor or the parent
ActorFrame sleep for 99999 (or something), which counts as a tween.
# From conversation with Daikyi:
InitCommand will happen during the loading of the specific screen the actor
is on. Guaranteed to run (in no guaranteed order) before any oncommand is
executed.

OffCommand runs when there is a screen transition.
some screens when transitioning from one to the other however have no
transition time

OnCommand: executed on load of screen, after init commands have run and
assets are loaded.
# There's a few different ways to do OnCommand etc.
# Here is the approach that is not preferred: cmd(LuaFunctionName). 
# I believe the OnCommand, InitCommand are keys in a table. It's a little
# odd to me that we can concatenate to a LoadActor — I believe that .. has
# been overwritten (metatables).
LoadActor("./assets/Ukidig/model.txt")..{
	OnCommand=cmd(Center)
},

# Another.
FlipCommand=cmd(sleep,1;zoom,last_zoom;addrotationz(180);addrotationy(180);queuecommand,"Flip");

# "I want things to happen at a certain time base on a time value in a
# table.
LoopCommand=function(self)
	local time = GAMESTATE:GetSongBeat() / bpm *60 + offset

	-- exit once we've exceeded the last one
	if time > time_table[#time_table] then
		self:linear(1.5):diffusealpha(0)
		return
	end

	if time > time_table[i] then
		self:diffusealpha(1) -- show
	end

	self:sleep(1/60);
	self:queuecommand("Loop");

end,

Disabling lines in SM5’s editor

courtesy José Varela

The editor adds lines to indicate where beats lie. It is possible to disable them by adding #TIMESIGNATURES:1000.000=4=4; to your simfile — this makes the beat bar start at measure 1000, effectively hiding it from view.