User talk:Shakesoda
From SMTheming Wiki
I'm working on this tutorial. Please leave this page alone.
Introduction
StepMania 4 forces allows you to use a much more powerful language for theming (called Lua), at first it may look like nonsense but once you know what is going on it is quite straightforward in most cases.
Prerequisites
Before you begin, you will need a few things.
1) The ability to think creatively. This will do you no good if you can't do this.
2) You cannot expect to have mastered this instantly. Learning things like this take time, don't give up if you can't get it right the first time.
3) StepMania 4. This is geared towards recent SM4 builds, however some things (such as functions, not covered here) could be done back in 3.95.
4) A decent text editor. Notepad/Textedit may get the job done, but you will be much better off using a programming text editor such as Notepad++ (Windows) or Smultron (Mac).
Let's begin
Let's start with this:
local t;
That declares to StepMania that you are going to be using the variable t for something, and that it is going to stay within the current script or command (as opposed to a global which would be accessible anywhere). Since it has no value set, it will do nothing.
That probably means nothing to you right now, but it is a very basic and important concept to know when working with Lua (and many other languages).
Now let's set up a blank theme to work with. First, create a folder in your SM Themes folder (you may call it anything you like). Second, create another folder called "BGAnimations" (without quotes), that is where you will be saving everything in this tutorial. BGAnimations are named according to when they are run and how they are placed on the screen, eg - "ScreenTitleMenu overlay" would be drawn on top of anything else, and "ScreenTitleMenu out" would begin when you press start to go to the next screen (it is also drawn above the overlay, so there are not problems with draworder being incorrect.
Make another folder called "ScreenTitleMenu overlay" (again, without quotes), this is where we are going to be saving things during this.
Now I'm just going to toss this out here:
local t = Def.ActorFrame {};
What I've just done is given t a value. Now with an ActorFrame I can load Graphics, Fonts, and draw Quads. In other words 90%+ of what you can do with SM visually is based on this. Of course, since no value is being returned still, it is useless.
Let's make it work, how about loading a font and setting it to write "Hello, World!" There are a few ways to go about this.
First method, this is a bit trickier to learn but some prefer it as it allows some interesting things to be done with if statements and for loops.
local t = Def.ActorFrame {}; t[#t+1] = LoadFont( "Common normal" )..{ Text="Hello, World!"; InitCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y); }; return t;
This creates an ActorFrame, Loads the font "Common normal," writes "Hello, World!", sets the x and y values to the center of the screen, and finally return's everything to the screen. Positioning things this way is particularly useful when working to accommodate widescreen displays.

