]> git.lizzy.rs Git - mcl_enchanting.git/blob - bookshelf_particles.lua
Add crafting recipe
[mcl_enchanting.git] / bookshelf_particles.lua
1 local bookshelf_positions = {{x = 1}, {x = -1}, {z = 1}, {z = -1}}
2
3 for _, p in pairs(bookshelf_positions) do
4         for _, d in pairs({"x", "y", "z"}) do
5                 p[d] = p[d] or 0
6         end
7 end
8
9 minetest.register_abm({
10         name = "Enchanting table bookshelf particles",
11         interval = 0.1,
12         chance = 1,
13         nodenames = "mcl_books:bookshelf",
14         action = function(pos)
15                 for _, relative_pos in pairs(bookshelf_positions) do
16                         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
17                                 minetest.add_particle({
18                                         pos = pos,
19                                         velocity = vector.subtract(relative_pos, vector.new(0, -2, 0)),
20                                         acceleration = {x = 0, y = -2, z = 0},
21                                         expirationtime = 2,
22                                         size = 2,
23                                         texture = "mcl_enchanting_glyph_" .. math.random(18) .. ".png"
24                                 })
25                         end
26                 end
27         end
28 })