Adding Animations to SM5 Simply Love: DDRIllini
Learned:
- Lua metatables (i.e. operator overloads)
- Deleting frames from gifs in preview breaks them
- Sora’s and Dan’s Stepmania docs are really nice
Oscar came up with a nice DDRIllini logo.
Animated (refresh if it stops, I messed with the gif)
Started from ScreenInit\ decorations/default.lua
, which animates the
collection of rainbow arrows when SL boots up.
From 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.
LoadActor
looks like it’s concatenating tables, which is really weird to
me. Lua has a construct called metatables
and another called
metamethods.
Basically, operator overloads for table methods. So you can
overload concatenation (..
) for tables. See this for an example.
Problem: Trying to LoadActor
within a for loop, within an ActorFrame
Failed attempt: For loop inside a Def.ActorFrame
Solution: For loop wrapping a LoadActor
and appending to the main
ActorFrame table for the given Lua file.
local ddrillini_letters = { 'd_1', 'd_2', 'r', 'i_1', 'l_1', 'l_2', 'i_2', 'n', 'i_3' }
for i=1,9 do
af[#af+1] = Def.ActorFrame {
LoadActor("ddrillini/" .. ddrillini_letters[i] .. ".png") .. {
InitCommand=function(self) self:x(2):zoom(0.7):shadowlength(0.75) end,
OffCommand=function(self) self:linear(0.5):shadowlength(0) end
}
}
end
It’s up on our GitHub.