Quickstart
Save, run, and inspect a first Lua script in the Sharp Scripts tab.
Sharp creates Atreia/Scripts in your Windows Documents folder. The Scripts tab shows the resolved folder in its tooltip. Use Refresh after adding a file if it has not appeared yet.
1. Create an instant script
Save instant/hello.lua under the resolved Scripts folder:
local name, err = game.local_name()
if not name then
log.warn(err)
return
end
log.info("Hello, " .. name)Select it in the Scripts tab and press Run. Instant scripts execute their top level and optional on_start, then close. Read the result in the tab or logs/instant_hello.log.
2. Create a persistent module
Save modules/my_overlay/main.lua:
function on_start()
log.info("My overlay loaded")
end
function on_tick(dt)
local position, err = game.local_position()
if position then
gfx.text(20, 80, string.format("X %.0f Y %.0f", position.x, position.y),
0xFFFFFFFF, 16)
end
end
function on_stop()
log.info("My overlay unloaded")
endPress Load. Edit and save the file, then Reload to use the saved version. Unload stops it. A module has its own callbacks, log, imports, and memory limit. Lifecycle explains callback timing.
3. Import a library
Use local sdk = require("sdk"), require("ui_sdk"), or another shipped library from a module. A module can also require("helpers") from its own folder. A file in lib/ is importable code, not a script to run directly. See bundled libraries.
Game functions can return a value or nil, error; check both values before using a result. See errors and limits.