From f6638b8f3e95dcd829aac67fedd2ccc8fcab4aac Mon Sep 17 00:00:00 2001 From: "Jill \"oatmealine\" Monoids" Date: Fri, 23 Sep 2022 19:22:23 +0300 Subject: [PATCH] GHAHAHAAAAAAAAAA IT WORKS --- actors.xml | 44 ++++++++++++++++++++---- actorsTest.xml | 6 ++-- main.xml | 93 ++++++++++++++++++++++++++++++++++++-------------- 3 files changed, 107 insertions(+), 36 deletions(-) diff --git a/actors.xml b/actors.xml index 7cf954c..6eadda9 100644 --- a/actors.xml +++ b/actors.xml @@ -1,7 +1,37 @@ - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/actorsTest.xml b/actorsTest.xml index ce7fb36..5ae04ee 100644 --- a/actorsTest.xml +++ b/actorsTest.xml @@ -1,6 +1,6 @@ - + - - + + \ No newline at end of file diff --git a/main.xml b/main.xml index e396c77..b2b0d33 100644 --- a/main.xml +++ b/main.xml @@ -166,6 +166,9 @@ if hasExited then return end hasExited = true uranium:call('exit') + -- good templates clean up after themselves + _G.oat = nil + _main:hidden(1) end local actorsInitialized = false -- if true, no new actors can be created @@ -240,16 +243,20 @@ local errored = false local firstrun = true + local playersLoaded = false self:addcommand('Update', function() - if not P1 and not P2 then -- sora exit hack - exit() - end - if errored then return 0 end errored = true + if P1 and P2 then + playersLoaded = true + end + if playersLoaded and not P1 and not P2 then -- sora exit hack + exit() + end + t = os.clock() b = GAMESTATE:GetSongBeat() local dt = t - lastt @@ -313,17 +320,41 @@ oat._actor = {} - function oat._actor.next() - local actor = actorQueue[1] - if actor then - table.remove(actorQueue, 1) - currentActor = actor + local function nextActor() + local new, idx = findFirstActor(currentPath) + if not new then + print('no actor!') + currentActor = nil + else + print('adding new actor') + currentActor = new + table.remove(currentPath, idx) + end + end + + function oat._actor.recurse() + local newFrame, idx = findFirstActorFrame(currentPath) + if newFrame then + table.insert(pastPaths, currentPath) + currentPath = currentPath[idx] + table.remove(pastPaths[#pastPaths], idx) + print('recursing: ' .. #pastPaths) + return true + elseif currentActor then + table.insert(pastPaths, currentPath) + print('recursing (actor): ' .. #pastPaths) return true else + print('no actor or actorframe!') return false end end + function oat._actor.endRecurse() + print('heading back: ' .. #pastPaths) + currentPath = table.remove(pastPaths, #pastPaths) + end + function oat._actor.cond() return currentActor ~= nil end @@ -333,6 +364,7 @@ end function oat._actor.noShader() + nextActor() return oat._actor.cond() and not oat._actor.hasShader() end @@ -358,18 +390,27 @@ function oat._actor.init(self) currentActor.init(self) - currentActor = nil -- shouldn't be needed from now on + self:removecommand('Init') + currentActor = nil -- to prevent any weirdness end function oat._actor.initFrame(self) - print('initiating an actorframe') - --local nextChild = self(2) + print('initializing an actorframe') + self:removecommand('Init') self:SetDrawFunction(function() - --if nextChild then - -- nextChild:Draw() - --end - -- TODO + for i = 1, self:GetNumChildren() do + local a = self(i) + if a.fov then -- actorframe + a:Draw() + end + end end) + + if currentPath.init then + print('found init function, calling') + currentPath.init(self) + currentPath.init = nil + end end local function createProxyActor(name) @@ -597,7 +638,7 @@ function addChild(frame, actor) actorAssociationQueue[actor.__queue] = frame.__queue end - + local function transformQueueToTree() local tree = {} local paths = {} @@ -633,18 +674,19 @@ end local success, result = pcall(function() - --require('main') - --require('stdlib.util') + require('main') + require('stdlib.util') end) if success then luaobj = result - --local queue = actorQueue - --actorQueue = deepcopy(actorQueue) - --transformQueueToTree() - --Trace(fullDump(actorTree)) - --currentPath = actorTree + print('---') + + transformQueueToTree() + Trace(fullDump(actorTree)) + currentPath = actorTree + nextActor() self:addcommand('On', onCommand) self:addcommand('Ready', screen_ready_command) @@ -668,7 +710,6 @@ -- By removing the command after it's done, it can only ever run once self:removecommand('Init') end"> - - + \ No newline at end of file