diff options
Diffstat (limited to 'crawl-ref/source/dat/clua/lm_props.lua')
-rw-r--r-- | crawl-ref/source/dat/clua/lm_props.lua | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/crawl-ref/source/dat/clua/lm_props.lua b/crawl-ref/source/dat/clua/lm_props.lua new file mode 100644 index 0000000000..03c746eb32 --- /dev/null +++ b/crawl-ref/source/dat/clua/lm_props.lua @@ -0,0 +1,32 @@ +------------------------------------------------------------------------------ +-- lm_props.lua: +-- Property markers. +------------------------------------------------------------------------------ + +PropertiesDescriptor = { } +PropertiesDescriptor.__index = PropertiesDescriptor + +function PropertiesDescriptor:new(properties) + local pd = { } + setmetatable(pd, self) + pd.props = properties + return pd +end + +function PropertiesDescriptor:write(marker, th) + lmark.marshall_table(th, self.props) +end + +function PropertiesDescriptor:read(marker, th) + self.props = lmark.unmarshall_table(th) + setmetatable(self, PropertiesDescriptor) + return self +end + +function PropertiesDescriptor:property(marker, pname) + return self.props and self.props[pname] or '' +end + +function props_marker(props) + return PropertiesDescriptor:new(props) +end |