allow passing arguments through drawfunctions

This commit is contained in:
Jill 2022-10-17 13:42:27 +03:00
parent 9681b0538e
commit 99f8ab7f8b
1 changed files with 24 additions and 5 deletions

View File

@ -248,6 +248,7 @@
GAMESTATE:ApplyModifiers('clearall')
local drawfunctionArguments = {}
local specialActorFrames = {} -- ones defined specifically; here for drawfunction jank
function setDrawFunction(frame, func)
@ -261,7 +262,12 @@
a:Draw()
end
end
func()
local args = drawfunctionArguments[frame]
if args then
func(unpack(args))
else
func()
end
end)
end
@ -406,6 +412,13 @@
end
end
local actorMethodOverrides = {
Draw = function(self, ...)
drawfunctionArguments[self] = arg
self.__raw:Draw()
end
}
local function createProxyActor(name)
local queue = {}
local initCommands = {}
@ -418,11 +431,15 @@
return lockedActor
end
if lockedActor then
local val = lockedActor[key]
if type(val) == 'function' then
return patchFunction(val, lockedActor)
if actorMethodOverrides[key] then
return actorMethodOverrides[key]
else
local val = lockedActor[key]
if type(val) == 'function' then
return patchFunction(val, lockedActor)
end
return val
end
return val
end
if key == '__queue' then
return queueRepresentation
@ -732,6 +749,8 @@
uranium:call('ready')
end
drawfunctionArguments = {}
for _, q in ipairs(globalQueue) do
local actor = q[1]
local v = q[2]