]> git.lizzy.rs Git - mcl_enchanting.git/blobdiff - bookshelf_particles.lua
Rewrite for MineClone2
[mcl_enchanting.git] / bookshelf_particles.lua
diff --git a/bookshelf_particles.lua b/bookshelf_particles.lua
new file mode 100644 (file)
index 0000000..3920efa
--- /dev/null
@@ -0,0 +1,28 @@
+local bookshelf_positions = {{x = 1}, {x = -1}, {z = 1}, {z = -1}}
+
+for _, p in pairs(bookshelf_positions) do
+       for _, d in pairs({"x", "y", "z"}) do
+               p[d] = p[d] or 0
+       end
+end
+
+minetest.register_abm({
+       name = "Enchanting table bookshelf particles",
+       interval = 0.1,
+       chance = 1,
+       nodenames = "mcl_books:bookshelf",
+       action = function(pos)
+               for _, relative_pos in pairs(bookshelf_positions) do
+                       if minetest.get_node(vector.add(pos, vector.multiply(relative_pos, 2))).name == "mcl_enchanting:table" and minetest.get_node(vector.add(pos, relative_pos, 2)).name == "air" then
+                               minetest.add_particle({
+                                       pos = pos,
+                                       velocity = vector.subtract(relative_pos, vector.new(0, -2, 0)),
+                                       acceleration = {x = 0, y = -2, z = 0},
+                                       expirationtime = 2,
+                                       size = 2,
+                                       texture = "mcl_enchanting_glyph_" .. math.random(18) .. ".png"
+                               })
+                       end
+               end
+       end
+})