Files
2026-06-07 22:53:58 +08:00

36 lines
886 B
Lua
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
local state = runtime.import("state")
local ui = runtime.import("ui")
---@type RuntimeCommands
local commands = runtime.import("runtime_commands")
function smoke_test(ctx)
return ctx ~= nil
and ctx.runtimeApiVersion ~= nil
and ui.create_nodes ~= nil
and commands.toast ~= nil
end
function init(ctx)
state.status = "Template ready: " .. tostring(ctx.gameId or "template")
return {
render = { creates = ui.create_nodes() },
ui = {},
commands = {}
}
end
function on_event(event)
if event.handler == "template_start" then
state.started = true
state.clicks = state.clicks + 1
state.status = "收到 tap 事件Lua 已返回 Diff 和 toast command。"
return {
ui = { updates = ui.state_updates() },
commands = {
commands.toast("Template event handled in Lua", { duration = 1.2 })
}
}
end
return {}
end