diff options
author | Alexander Weber <web.alexander@web.de> | 2017-06-16 23:00:36 +0200 |
---|---|---|
committer | Alexander Weber <web.alexander@web.de> | 2017-06-16 23:00:36 +0200 |
commit | 28d28390ce5d67f47db184cbbbc4ecd74be77eb2 (patch) | |
tree | 2dde0e088559a878d6006fa3f3779b5ac3adb1b0 /skin_meta_api.lua | |
parent | b267cf26579623565f5a85bee9e8584a5467a85f (diff) |
started work on skin_meta_api
Diffstat (limited to 'skin_meta_api.lua')
-rw-r--r-- | skin_meta_api.lua | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/skin_meta_api.lua b/skin_meta_api.lua new file mode 100644 index 0000000..9e681c0 --- /dev/null +++ b/skin_meta_api.lua @@ -0,0 +1,56 @@ +skins.meta = {} + +local skin_class = {} +skin_class.__index = skin_class +----------------------- +-- Class methods +----------------------- +-- constructor +function skins.new(key, object) + assert(key, 'Unique skins key required, like "character_1"') + local self = object or {} + setmetatable(self, skin_class) + self.__index = skin_class + + self._key, key) + self._sort_id = 0 + skins.meta[key] + return self +end + +-- getter +function skins.get(key) + return skins.meta[key] +end + +-- Skin methods +-- In this implementation it is just access to attrubutes wrapped +-- but this way allow to redefine the functionality for more complex skins provider +function skin_class:set_meta(key, value) + self[key] = value +end + +function skin_class:get_meta(key) + return self[key] +end + +function skin_class:get_meta_string(key) + return tostring(self[key] or "") +end + + +function skin_class:set_texture(value) + self._texture = value +end + +function skin_class:get_texture() + return self._texture +end + +function skin_class:set_preview(value) + self._preview = value +end + +function skin_class:get_preview() + return self._preview or "player.png" +end |