]> git.lizzy.rs Git - mcl_enchanting.git/commitdiff
Import changes from xdecor
authorkilbith <jeanpatrick.guerrero@gmail.com>
Sat, 2 Apr 2016 16:24:00 +0000 (18:24 +0200)
committerkilbith <jeanpatrick.guerrero@gmail.com>
Sat, 2 Apr 2016 16:24:16 +0000 (18:24 +0200)
15 files changed:
init.lua
textures/glyph1.png [new file with mode: 0644]
textures/glyph10.png [new file with mode: 0644]
textures/glyph11.png [new file with mode: 0644]
textures/glyph12.png [new file with mode: 0644]
textures/glyph13.png [new file with mode: 0644]
textures/glyph14.png [new file with mode: 0644]
textures/glyph2.png [new file with mode: 0644]
textures/glyph3.png [new file with mode: 0644]
textures/glyph4.png [new file with mode: 0644]
textures/glyph5.png [new file with mode: 0644]
textures/glyph6.png [new file with mode: 0644]
textures/glyph7.png [new file with mode: 0644]
textures/glyph8.png [new file with mode: 0644]
textures/glyph9.png [new file with mode: 0644]

index 201fd72ba7d496ac601ff40c6acdb7aed46ae317..ff142ce66b4ea03c82d9a1d7c43d29be9a10d5a8 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -113,7 +113,7 @@ function enchanting.construct(pos)
 
        minetest.add_entity({x=pos.x, y=pos.y+0.85, z=pos.z}, "xdecor:book_open")
        local timer = minetest.get_node_timer(pos)
-       timer:start(15.0)
+       timer:start(5.0)
 end
 
 function enchanting.destruct(pos)
@@ -132,6 +132,27 @@ function enchanting.timer(pos)
        if num == 0 then
                minetest.add_entity({x=pos.x, y=pos.y+0.85, z=pos.z}, "xdecor:book_open")
        end
+
+       local minp = {x=pos.x-2, y=pos.y, z=pos.z-2}
+       local maxp = {x=pos.x+2, y=pos.y+1, z=pos.z+2}
+       local bookshelves = minetest.find_nodes_in_area(minp, maxp, "default:bookshelf")
+       if #bookshelves == 0 then return true end
+
+       local bookshelf_pos = bookshelves[math.random(1, #bookshelves)]
+       local x = pos.x - bookshelf_pos.x
+       local y = bookshelf_pos.y - pos.y
+       local z = pos.z - bookshelf_pos.z
+
+       if tostring(x..z):find(2) then
+               minetest.add_particle({
+                       pos = bookshelf_pos,
+                       velocity = {x=x, y=1.7-y, z=z},
+                       acceleration = {x=-0.6, y=-1.5, z=0},
+                       expirationtime = 1,
+                       size = 2,
+                       texture = "glyph"..math.random(1,14)..".png"
+               })
+       end
        return true
 end
 
@@ -161,7 +182,15 @@ minetest.register_entity(":xdecor:book_open", {
        visual_size = {x=0.75, y=0.75},
        collisionbox = {0},
        physical = false,
-       textures = {"book_open.png"}
+       textures = {"book_open.png"},
+       on_activate = function(self)
+               local pos = self.object:getpos()
+               local pos_under = {x=pos.x, y=pos.y-1, z=pos.z}
+
+               if minetest.get_node(pos_under).name ~= "xdecor:enchantment_table" then
+                       self.object:remove()
+               end
+       end
 })
 
 minetest.register_craft({
diff --git a/textures/glyph1.png b/textures/glyph1.png
new file mode 100644 (file)
index 0000000..da77892
Binary files /dev/null and b/textures/glyph1.png differ
diff --git a/textures/glyph10.png b/textures/glyph10.png
new file mode 100644 (file)
index 0000000..27c7c8d
Binary files /dev/null and b/textures/glyph10.png differ
diff --git a/textures/glyph11.png b/textures/glyph11.png
new file mode 100644 (file)
index 0000000..76493c9
Binary files /dev/null and b/textures/glyph11.png differ
diff --git a/textures/glyph12.png b/textures/glyph12.png
new file mode 100644 (file)
index 0000000..72f18fb
Binary files /dev/null and b/textures/glyph12.png differ
diff --git a/textures/glyph13.png b/textures/glyph13.png
new file mode 100644 (file)
index 0000000..70ca494
Binary files /dev/null and b/textures/glyph13.png differ
diff --git a/textures/glyph14.png b/textures/glyph14.png
new file mode 100644 (file)
index 0000000..6862387
Binary files /dev/null and b/textures/glyph14.png differ
diff --git a/textures/glyph2.png b/textures/glyph2.png
new file mode 100644 (file)
index 0000000..a6da2d1
Binary files /dev/null and b/textures/glyph2.png differ
diff --git a/textures/glyph3.png b/textures/glyph3.png
new file mode 100644 (file)
index 0000000..456e030
Binary files /dev/null and b/textures/glyph3.png differ
diff --git a/textures/glyph4.png b/textures/glyph4.png
new file mode 100644 (file)
index 0000000..e93f238
Binary files /dev/null and b/textures/glyph4.png differ
diff --git a/textures/glyph5.png b/textures/glyph5.png
new file mode 100644 (file)
index 0000000..c79537f
Binary files /dev/null and b/textures/glyph5.png differ
diff --git a/textures/glyph6.png b/textures/glyph6.png
new file mode 100644 (file)
index 0000000..f735354
Binary files /dev/null and b/textures/glyph6.png differ
diff --git a/textures/glyph7.png b/textures/glyph7.png
new file mode 100644 (file)
index 0000000..3f91a32
Binary files /dev/null and b/textures/glyph7.png differ
diff --git a/textures/glyph8.png b/textures/glyph8.png
new file mode 100644 (file)
index 0000000..6c65994
Binary files /dev/null and b/textures/glyph8.png differ
diff --git a/textures/glyph9.png b/textures/glyph9.png
new file mode 100644 (file)
index 0000000..4b3e366
Binary files /dev/null and b/textures/glyph9.png differ