56 lines
2 KiB
Text
56 lines
2 KiB
Text
-- Forge's editor makes a waves track by keys: W adds it, K a wave at the cursor, and the wave's
|
|
-- fields are typed like any other. The built game carries the track.
|
|
TUTORIAL = { number = 0, name = "00-waves", tag = "WAVESED" }
|
|
dofile("testScripts/tutorialDrive.singe")
|
|
tutorialBegin(nil)
|
|
|
|
local frames = 0
|
|
|
|
function onOverlayUpdate()
|
|
frames = frames + 1
|
|
if frames == 6 then
|
|
panel("tracks")
|
|
key(SCANCODE.W)
|
|
key(SCANCODE.K)
|
|
form("type", "hero")
|
|
form("count", 3)
|
|
form("every", 0.2)
|
|
form("from", "hero")
|
|
local track = forgeRoom().tracks[1]
|
|
local wave = track and track.spawns and track.spawns[1]
|
|
|
|
if wave and (wave.type == "hero") and (wave.count == 3) and (wave.every == 0.2) and (wave.from == "hero") and (wave.at == 0) then
|
|
debugPrint("WAVESED the keys made a wave: at " .. wave.at .. ", " .. wave.count .. " x " .. wave.type .. " from " .. wave.from .. " every " .. wave.every)
|
|
else
|
|
debugPrint("WAVESED FAIL the wave is " .. tostring(wave and (tostring(wave.at) .. " " .. tostring(wave.type) .. " " .. tostring(wave.count) .. " " .. tostring(wave.every) .. " " .. tostring(wave.from))))
|
|
end
|
|
-- Keyed by a stop instead: the wave's at becomes a name.
|
|
key(SCANCODE.UP)
|
|
form("key", "stop")
|
|
key(SCANCODE.DOWN)
|
|
form("at", "hall")
|
|
if (track.key == "stop") and (wave.at == "hall") then
|
|
debugPrint("WAVESED keyed by stops: the wave waits for " .. wave.at)
|
|
else
|
|
debugPrint("WAVESED FAIL keying by stops gave key " .. tostring(track.key) .. ", at " .. tostring(wave.at))
|
|
end
|
|
singeScreenshot("wavesTrack")
|
|
elseif frames == 8 then
|
|
forgeSave()
|
|
local built = forgeBuild(TUTORIAL_OUT .. "waves.singe")
|
|
local file = built and io.open(TUTORIAL_OUT .. "waves.singe", "r")
|
|
local text = file and file:read("a") or ""
|
|
|
|
if file then
|
|
file:close()
|
|
end
|
|
if text:find("spawns", 1, true) and text:find("hall", 1, true) then
|
|
debugPrint("WAVESED the built game carries the waves track")
|
|
else
|
|
debugPrint("WAVESED FAIL the built game has no waves track")
|
|
end
|
|
singeQuit()
|
|
end
|
|
forgeDraw(nil, nil)
|
|
return OVERLAY_UPDATED
|
|
end
|