PM: use actual objects as key instead of string
I should have been doing this from the start
This commit is contained in:
parent
fa11b3a3f6
commit
4700991a2c
@ -395,7 +395,7 @@ do
|
|||||||
|
|
||||||
--- ensure part is initialized
|
--- ensure part is initialized
|
||||||
local function initPart(part)
|
local function initPart(part)
|
||||||
local part_key=tostring(part)
|
local part_key=part
|
||||||
if pm[part_key] == nil then
|
if pm[part_key] == nil then
|
||||||
pm[part_key]={}
|
pm[part_key]={}
|
||||||
end
|
end
|
||||||
@ -413,7 +413,7 @@ do
|
|||||||
--- @param init? boolean Default value for chain. Should only be set once, subsequent uses overwrite the entire chain's initial value.
|
--- @param init? boolean Default value for chain. Should only be set once, subsequent uses overwrite the entire chain's initial value.
|
||||||
function PartsManager.addPartFunction(part, func, init)
|
function PartsManager.addPartFunction(part, func, init)
|
||||||
initPart(part)
|
initPart(part)
|
||||||
local part_key=tostring(part)
|
local part_key=part
|
||||||
if init ~= nil then
|
if init ~= nil then
|
||||||
pm[part_key].init=init
|
pm[part_key].init=init
|
||||||
end
|
end
|
||||||
@ -426,7 +426,7 @@ do
|
|||||||
function PartsManager.setInitialValue(part, init)
|
function PartsManager.setInitialValue(part, init)
|
||||||
assert(init~=nil)
|
assert(init~=nil)
|
||||||
initPart(part)
|
initPart(part)
|
||||||
local part_key=tostring(part)
|
local part_key=part
|
||||||
pm[part_key].init=init
|
pm[part_key].init=init
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -443,7 +443,7 @@ do
|
|||||||
--- Evaluate a part's chain to determine if it should be visible.
|
--- Evaluate a part's chain to determine if it should be visible.
|
||||||
--- @param part table An object managed by PartsManager.
|
--- @param part table An object managed by PartsManager.
|
||||||
function PartsManager.evaluatePart(part)
|
function PartsManager.evaluatePart(part)
|
||||||
local part_key=tostring(part)
|
local part_key=part
|
||||||
assert(pm[part_key] ~= nil)
|
assert(pm[part_key] ~= nil)
|
||||||
|
|
||||||
local evalFunc=function(x, y) return y(x) end
|
local evalFunc=function(x, y) return y(x) end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user