-- A Forge release is standalone (FORGE.md). -- -- Building it is half the test; the half that matters is that the result runs somewhere Forge has -- never been. The runtime a compiled game loads is Singe/Author.singe, which whatever Singe the -- player has will have extracted -- but a game should not change behaviour because the engine under -- it moved on, so a release carries its own copy and loads that instead. FORGE_LIBRARY = true dofile("Forge/Forge.singe") local font = fontLoad("Singe/FreeSansBold.ttf", 15) local out = singeGetDataPath() local work = out .. "release.game" local dest = out .. "Released" fontSelect(font) fontQuality(FONT_QUALITY_BLENDED) overlaySetResolution(720, 480) local source = assert(io.open("testScripts/author/platformer.game", "r")) local copy = assert(io.open(work, "w")) copy:write(source:read("a")) source:close() copy:close() if not forgeBegin(work) then debugPrint("RELEASE FAIL could not open " .. work) singeQuit() end local frames = 0 local stage = 0 local function step() if stage == 1 then local folder = forgeExport(dest, "Platformer") debugPrint("RELEASE built into " .. tostring(folder)) elseif stage == 2 then -- Everything a standalone game needs has to be there. for _, name in ipairs({ "Platformer.singe", "Author.singe", "games.dat", "Platformer.game" }) do local f = io.open(dest .. "/" .. name, "r") if f == nil then debugPrint("RELEASE FAIL missing " .. name) else f:close() end end debugPrint("RELEASE all four files present") elseif stage == 3 then -- And it must load its own runtime, not the engine's. local text = assert(io.open(dest .. "/Platformer.singe", "r")):read("a") if text:find('dofile%(here %.%. "Author%.singe"%)') and text:find('debug%.getinfo') then debugPrint("RELEASE the game finds its own directory and loads the runtime there") elseif text:find('Singe/Author%.singe') then debugPrint("RELEASE FAIL the game still loads the engine's runtime, which no longer ships") else debugPrint("RELEASE FAIL the game does not load a runtime at all") end elseif stage == 4 then -- Whether it truly stands alone cannot be answered from in here: DIR is the directory of -- the script the engine was *launched* with, so a game reached by dofile would look for the -- runtime beside this scene instead of beside itself. A released game is the main script, -- which is a different run of the engine. harness/verify.sh launches it with -- Singe/Author.singe moved aside and checks it still runs. debugPrint("RELEASE RESULT done") end end function onOverlayUpdate() frames = frames + 1 if frames % 14 == 0 and stage < 5 then stage = stage + 1 step() end if frames == 20 or frames == 70 then singeScreenshot() end if frames > 90 then singeQuit() end return OVERLAY_UPDATED end