#Introduction
In this quickstart, you make a mod that shows how many times Mario has jumped, in the top-left corner of the screen. You write its code in LumaScript, build and check it with LumaLink, test it in the game, and pack it into a .luma file that anyone can import.
#Prerequisites
- Nebula, installed with Nebula Setup.
- LumaLink. For more information, see Installing LumaLink.
#Creating the mod
Create the mod folder.
Shell lumalink new jump-counter --id jump-counter --name "Jump Counter" --summary "Counts Mario's jumps in the top left corner." --author YOUR-NAMEReplace YOUR-NAME with your name. LumaLink writes
jump-counter/luma.jsonwith the mod's name, ID and version, and creates an emptybaselayer.Add LumaKit to the mod's needs. LumaKit draws the counter.
Shell lumalink add need lumakit jump-counterOptionally, add the mod's name and summary in another language. This example adds German.
Shell lumalink add text EuGerman jump-counter --name "Sprungzähler" --summary "Zählt Marios Sprünge oben links."The game supports 14 languages. The finished mod includes all of them.
#Writing the code
Create jump-counter/source/main.lum with this code:
use kit.hud
var jumps: i64 = 0
var counter: hud.Counter? = none
on start {
counter = hud.counter(hud.Corner.TopLeft, 0)
}
hook before Mario::tryJump() {
jumps += 1
if let c = counter {
hud.set_counter(c, jumps)
}
log "jump {jumps}"
}on startruns once, when the game starts with the mod turned on. It puts a counter showing 0 in the top-left corner.hook before Mario::tryJump()runs each time the game is about to try a jump. It adds one to the count, shows the new number, and writesjump 1,jump 2and so on to the mod log.
#Building and checking the mod
Build the mod's code.
Shell lumalink build jump-counterLumaLink compiles the code in
sourceinto native code for every platform, incode/PLATFORM. If the code has a mistake, the build stops and reports the file, line and column.Check the mod.
Shell lumalink check jump-counterLumaLink reads the folder the way the game will, and prints each finding with its code. The last line of the output is
Errors: 0.
#Testing the mod
Create
jump-counter/tests/jump/test.jsonwith this test:JSON { "harness": 1, "name": "jump-counter", "about": "One jump in a galaxy shows 1 in the top left corner", "proves": ["script.build", "kit.hud"], "mods": ["../.."], "stage": { "name": "EggStarGalaxy", "scenario": 1 }, "steps": [ { "at": 20, "picture": "before" }, { "at": 30, "hold": ["A"], "frames": 8 }, { "at": 120, "picture": "after" }, { "at": 130, "end": true } ], "expect": [ { "log": "jump 1" } ] }Run the test.
Shell lumalink test jump-counter
LumaLink starts the game hidden and silent with your mod, enters Good Egg Galaxy, presses A once, and takes a picture before and after the jump. The test passes when the mod log contains jump 1. The pictures are saved in the run folder that LumaLink prints.
Note
In the current version, a LumaKit HUD element created in on start stops the game at its first screen, so this test does not pass yet. The mod builds and checks without errors.
For more information, see Testing a mod.
#Playing the mod
Pack the mod.
Shell lumalink pack jump-counterLumaLink writes a
.lumafile beside the mod folder, named after the mod's ID and version.Drag the
.lumafile onto the game's window, and turn the mod on in the Mods page.Play. Each jump adds one to the counter.