-- The Forge port of an ActionMax game, driven by the same inputs as the original and tracing -- the same things, in the original's terms: its state numbers stand for the port's rooms. local library = os.getenv("SINGE_LIBRARY") or (os.getenv("HOME") .. "/claude/singetest/ported") local game = os.getenv("PORT_GAME") or "38AmbushAlley" local STATES = { startup = 0, title = 2, menu = 3, intro = 4, playing = 5, gameOver = 6 } dofile("Forge/AuthorCompile.singe") -- The inputs sit beside this script, wherever the engine was started from. local here = ((debug.getinfo(1, "S").source:gsub("^@", "")):match("^(.*[/\\])") or "") dofile(here .. "actionMaxInputs.singe") dofile(authorBuild(library .. "/ActionMax/" .. game .. ".forge", singeGetDataPath() .. game .. ".singe")) local realUpdate = onOverlayUpdate local frames = 0 local lastRoom = nil local function counts() return string.format("shots %d good %d bad %d", AUTHOR_VARS.shots, AUTHOR_VARS.good, AUTHOR_VARS.bad) end function onOverlayUpdate() frames = frames + 1 local input = portInputAt(frames) if input then authorSetPointer(1, input.x, input.y, true) authorSwitchDown(SWITCH_BUTTON3) authorSwitchUp(SWITCH_BUTTON3) debugPrint(string.format("TRACE input %d at %d,%d: state %d frame %d %s", frames, input.x, input.y, STATES[AUTHOR_ROOM.name] or -1, discGetFrame(), counts())) end local r = realUpdate() if os.getenv("PORT_SENSOR_TRACE") and (frames >= tonumber(os.getenv("PORT_SENSOR_TRACE"))) and (frames < tonumber(os.getenv("PORT_SENSOR_TRACE")) + 12) then local sensor = authorEntity("sensor") local gx, gy = authorPointer(1) debugPrint(string.format("SENSOR frame %d disc %d pulled %d spot %s gun %s now %s/%s pointer %d,%d", frames, discGetFrame(), sensor.pulled, tostring(sensor.spotWas), tostring(sensor.gunWas), authorPixelState(312, 205, 127, 20), authorPixelState(gx, gy, 127, 20), gx, gy)) end if AUTHOR_ROOM.name ~= lastRoom then lastRoom = AUTHOR_ROOM.name debugPrint(string.format("TRACE state %d from frame %d: disc %d %s", STATES[AUTHOR_ROOM.name] or -1, frames, discGetFrame(), counts())) end if frames >= PORT_LAST then debugPrint(string.format("TRACE end: state %d disc %d %s", STATES[AUTHOR_ROOM.name] or -1, discGetFrame(), counts())) singeQuit() end return r end