1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
------------------------------------------------------------------------------
-- lm_desc.lua:
-- Portal descriptor markers.
------------------------------------------------------------------------------
crawl_require('dlua/util.lua')
util.defclass("PortalDescriptor")
function PortalDescriptor:new(properties)
local pd = util.newinstance(self)
pd.props = properties
return pd
end
function PortalDescriptor:write(marker, th)
lmark.marshall_table(th, self.props)
end
function PortalDescriptor:read(marker, th)
self.props = lmark.unmarshall_table(th)
setmetatable(self, PortalDescriptor)
return self
end
function PortalDescriptor:unmangle(x)
if x and util.callable(x) then
return x(self)
else
return x
end
end
function PortalDescriptor:property(marker, pname)
if pname == 'feature_description' then
return self:unmangle(self.props.desc)
end
return self:unmangle(self.props and self.props[pname] or '')
end
function portal_desc(props)
return PortalDescriptor:new(props)
end
|