You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Screens need to be defined in a theme's metrics file to be available.
At a minimum you must define a screen's name, class, next and previous screen.
Different screen classes need different things to work, here is a basic
ScreenAttract:
; Screen name[ScreenExample]; The screen Class used by the Engine, which defines the basic behavior of it.Class="ScreenAttract"; Fallback from which the game should fill in missing rulesFallback="ScreenAttract"; When the user goes back, go herePrevScreen="ScreenTitleMenu"; When the screen cycles to next, go hereNextScreen="ScreenTitleMenu"; When the user presses Start, go hereStartScreen="ScreenTitleMenu"; Force a silent 5 second timerForceTimer=true
TimerSeconds=5
TimerMetricsGroup="MenuTimerNoSound"TimerOnCommand=visible,false
; Do not play musicPlayMusic=false
Many more options are available, and you can follow the Fallback rules to see
what all is defined in fallback and default to find most of them.
Note that metrics can also be requested by Lua scripts, so not everything you
encounter is part of the engine.
BGAnimation layers and where to put the files
Every theme has a BGAnimation folder which provides all the scripted visuals.
There are various layers available for different purposes, most commonly you
will use background and decorations.
The following layers are children of the Screen and are different only in
drawing order:
background - the bottom most layer
underlay - above background, but below decorations
As they are children of the screen, input will be locked until the initial
commands are finished.
The decorations layer is special in that it is not a direct child of the
screen. Due to this, the screen will not lock input from its animations not does
it receive screen messages (e.g. Code messages).
The following are used during transitions:
in - When a screen first loads
out - Before a screen exits to the next screen
cancel - When the user presses back.
For example, the background for ScreenTitleMenu would be
ScreenTitleMenu background and could either be a folder or a Lua file. If you
use a folder, you should place the code in a file called default.lua i.e.
ScreenTitleMenu background/default.lua. Different BGAnimation layers do not
all need to be the same type of file, it is perfectly fine to mix folders and
Lua files. If you would like to refer to an existing BGAnimation, you can use a
.redir file.
When loading files from Lua script, they will always be loaded from the folder
which contains the script. You may access files from Graphics, Sounds or any
other theme-level folder using THEME:GetPathG, THEME:GetPathS, etc.
For example, LoadActor(THEME:GetPathG("", "platinum")) would look for a
file named platinum in Graphics/, which can be a Sprite, Lua file or any
other file type SM understands.
Writing the code
Method 1: Lua style
This is the "right" way to do it, which most anyone who can read Lua should
understand with little explanation.
This should only be used when converting old code, as it relies on the "cmd" macro
which expands things into functions automatically. This is baffling to most Lua
programmers, which is why its use is discouraged.