]> git.lizzy.rs Git - xdecor.git/commitdiff
Fix ndef error and prepare enchanting table
authorjp <jeanpatrick.guerrero@gmail.com>
Sun, 2 Aug 2015 00:00:29 +0000 (02:00 +0200)
committerjp <jeanpatrick.guerrero@gmail.com>
Sun, 2 Aug 2015 00:00:29 +0000 (02:00 +0200)
crafts.lua
enchanting.lua [new file with mode: 0644]
init.lua
textures/bg.png [new file with mode: 0644]
worktable.lua

index c584885982d4b9c3fce5c052c6ad4507c9f22aaf..9e26ac6bfc43dbbfc6f9486ae838b9ed5ae7ef1b 100644 (file)
@@ -131,6 +131,15 @@ minetest.register_craft({
        }
 })
 
+minetest.register_craft({
+       output = "xdecor:enchantment_table",
+       recipe = {
+               {"", "default:book", ""},
+               {"default:diamond", "default:obsidian", "default:diamond"},
+               {"default:obsidian", "default:obsidian", "default:obsidian"}
+       }
+})
+
 minetest.register_craft({
        output = "xdecor:fence_wrought_iron 2",
        recipe = {
diff --git a/enchanting.lua b/enchanting.lua
new file mode 100644 (file)
index 0000000..119c02f
--- /dev/null
@@ -0,0 +1,65 @@
+local function enchconstruct(pos)
+       local meta = minetest.get_meta(pos)
+       meta:set_string("formspec", "size[8,7;]"..xdecor.fancy_gui..
+               "label[0.65,-0.15;Enchant]"..
+               "image[0.4,0.2;2,2;default_book.png]"..
+               "list[current_name;tool;0.3,2;1,1;]"..
+               "list[current_name;mese;1.3,2;1,1;]"..
+               "image_button[2.5,0;5.3,1.1;bg.png;durable;Durable]"..
+               "image_button[2.5,1;5.3,1.1;bg.png;fast;Fast]"..
+               "image_button[2.5,2;5.3,1.1;bg.png;luck;Luck]"..
+               "list[current_player;main;0,3.3;8,4;]")
+       meta:set_string("infotext", "Enchantment Table")
+
+       local inv = meta:get_inventory()
+       inv:set_size("tool", 1)
+       inv:set_size("mese", 1)
+end
+
+local function enchdig(pos, player)
+       local meta = minetest.get_meta(pos)
+       local inv = meta:get_inventory()
+
+       if not inv:is_empty("tool") or not inv:is_empty("mese") then
+               return false
+       end
+       return true
+end
+
+local function enchput(pos, listname, index, stack, player)
+       local meta = minetest.get_meta(pos)
+       local inv = meta:get_inventory()
+
+       if listname == "mese" then
+               if stack:get_name() == "default:mese_crystal" then
+                       return stack:get_count()
+               else
+                       return 0
+               end
+       end
+       if listname == "tool" then
+               local tname = stack:get_name()
+               local tdef = minetest.registered_tools[tname]
+
+               if tdef then return 1 else return 0 end
+       end
+
+       return stack:get_count()
+end
+
+xdecor.register("enchantment_table", {
+       description = "Enchantment Table",
+       tiles = {
+               "xdecor_enchantment_top.png",
+               "xdecor_enchantment_bottom.png",
+               "xdecor_enchantment_side.png",
+               "xdecor_enchantment_side.png",
+               "xdecor_enchantment_side.png",
+               "xdecor_enchantment_side.png",
+       },
+       groups = {cracky=1},
+       sounds = xdecor.stone,
+       on_construct = enchconstruct,
+       can_dig = enchdig,
+       allow_metadata_inventory_put = enchput
+})
index 95b37b25cea5975c24dc1e598c742293dd81e5da..0dbbf052780be22fb1c2875c3712eaf7f1eeda48 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -4,6 +4,7 @@ modpath = minetest.get_modpath("xdecor")
 dofile(modpath.."/handlers/nodeboxes.lua")
 dofile(modpath.."/handlers/registration.lua")
 dofile(modpath.."/crafts.lua")
+--dofile(modpath.."/enchanting.lua") -- In development.
 dofile(modpath.."/hive.lua")
 dofile(modpath.."/itemframe.lua")
 dofile(modpath.."/mailbox.lua")
diff --git a/textures/bg.png b/textures/bg.png
new file mode 100644 (file)
index 0000000..d025195
Binary files /dev/null and b/textures/bg.png differ
index 1b96a46646d6e092213f44c656fbc9339577fd1c..062b2a15761c590fec1fd812bb62154db4b24851 100644 (file)
@@ -1,7 +1,7 @@
 local material = {
        "cloud", -- Only used for the formspec display.
-       "wood", "junglewood", "pinewood",
-       "tree", "jungletree", "pinetree",
+       "wood", "junglewood", "pinewood", "acacia_wood",
+       "tree", "jungletree", "pinetree", "acacia_tree",
        "cobble", "mossycobble", "desert_cobble",
        "stone", "sandstone", "desert_stone", "obsidian",
        "stonebrick", "sandstonebrick", "desert_stonebrick", "obsidianbrick",
@@ -135,20 +135,22 @@ for m=1, #material do
                local w = def[n]
                local nodename = "default:"..v
                local ndef = minetest.registered_nodes[nodename]
-
-               xdecor.register(w[1].."_"..v, {
-                       description = string.sub(string.upper(w[1]), 0, 1)..
-                                       string.sub(w[1], 2),
-                       light_source = ndef.light_source,
-                       sounds = ndef.sounds,
-                       tiles = ndef.tiles,
-                       groups = {snappy=3, not_in_creative_inventory=1},
-                       node_box = {
-                               type = "fixed",
-                               fixed = w[3]
-                       },
-                       on_place = minetest.rotate_node
-               })
+               
+               if ndef then
+                       xdecor.register(w[1].."_"..v, {
+                               description = string.sub(string.upper(w[1]), 0, 1)..
+                                               string.sub(w[1], 2),
+                               light_source = ndef.light_source,
+                               sounds = ndef.sounds,
+                               tiles = ndef.tiles,
+                               groups = {snappy=3, not_in_creative_inventory=1},
+                               node_box = {
+                                       type = "fixed",
+                                       fixed = w[3]
+                               },
+                               on_place = minetest.rotate_node
+                       })
+               end
        end
 end