24 lines
438 B
Lua
24 lines
438 B
Lua
local Prop = {}
|
|
Prop.__index = Prop
|
|
|
|
function Prop:getState(element)
|
|
return element[self]
|
|
end
|
|
|
|
function Prop:setState(element, state)
|
|
element[self] = state
|
|
end
|
|
|
|
function Prop.attach(elementType, prop, defaultState)
|
|
prop:setState(elementType, defaultState or prop.defaultState)
|
|
return prop:with(elementType)
|
|
end
|
|
|
|
function Prop:new(o)
|
|
local obj = o or {}
|
|
setmetatable(obj, Prop)
|
|
obj.__index = obj
|
|
return obj
|
|
end
|
|
|
|
return Prop |