]> git.lizzy.rs Git - dragonblocks3d-lua.git/blobdiff - modules/BlockSystem/src/init.lua
Refactoring
[dragonblocks3d-lua.git] / modules / BlockSystem / src / init.lua
diff --git a/modules/BlockSystem/src/init.lua b/modules/BlockSystem/src/init.lua
new file mode 100644 (file)
index 0000000..0dcd48d
--- /dev/null
@@ -0,0 +1,18 @@
+BlockSystem.blocks = {}
+
+function BlockSystem:register_block(def)
+       local id = table.insert(self.blocks, def)
+       def.id = id
+       self.blocks[def.name] = def
+end
+
+function BlockSystem:get_def(key)
+       return self.blocks[key]
+end
+
+function BlockSystem:init_textures()
+       RenderEngine:init_texture_args()
+       for _, def in ipairs(self.blocks) do
+               def.texture = RenderEngine:create_texture(def.texture_path)
+       end
+end