]> git.lizzy.rs Git - xdecor.git/commitdiff
Add settings and compatibility with moreblocks and stairs
authorJat15 <jinan15@hotmail.com>
Mon, 28 Aug 2017 05:41:14 +0000 (07:41 +0200)
committerJP Guerrero <jeanpatrick.guerrero@gmail.com>
Thu, 8 Mar 2018 19:51:46 +0000 (20:51 +0100)
If workbench disabling.
And setting for disabling:
- Chess
- Cooking
- Enchanting
- Hive
- Itemframe
- Mailbox
- Mechanisms
- Rope
- Workbench
By default all active.

16 files changed:
handlers/helpers.lua
handlers/registration.lua
init.lua
settingtypes.txt [new file with mode: 0644]
src/alias.lua [new file with mode: 0644]
src/chess.lua
src/cooking.lua
src/craftitems.lua [deleted file]
src/enchanting.lua
src/hive.lua
src/itemframe.lua
src/mailbox.lua
src/mechanisms.lua
src/recipes.lua
src/rope.lua
src/workbench.lua

index 13d3ed70a8866a04a9b5db35081983ccf87f9b26..e6ad8b98267f993a2e322ac5a75c4ee5aeba4184 100644 (file)
@@ -29,3 +29,22 @@ function xdecor.tablecopy(T)
        return new
 end
 
+-- Return true if a def is accepting for stair
+function xdecor.stairs_valid_def(def)
+       return (def.drawtype == "normal" or def.drawtype:sub(1,5) == "glass") and
+               (def.groups.cracky or def.groups.choppy) and
+               not def.on_construct and
+               not def.after_place_node and
+               not def.on_rightclick and
+               not def.on_blast and
+               not def.allow_metadata_inventory_take and
+               not (def.groups.not_in_creative_inventory == 1) and
+               not (def.groups.not_cuttable == 1) and
+               not def.groups.wool and
+               (def.tiles and type(def.tiles[1]) == "string" and not
+               def.tiles[1]:find("default_mineral")) and
+               not def.mesecons and
+               def.description and
+               def.description ~= "" and
+       def.light_source == 0
+end
index fc6409e5ebcea2c967c9c2a8450525a75f467470..0b7f2d62e5ec042b6e0eca3ec5a34ed774a3535f 100644 (file)
@@ -43,6 +43,40 @@ local default_can_dig = function(pos)
 end
 
 function xdecor.register(name, def)
+       local function xdecor_stairs_alternative(nodename, def)
+               local mod, name = nodename:match("(.*):(.*)")
+               for groupname, value in pairs(def.groups) do
+                       if      groupname ~= "cracky" and
+                               groupname ~= "choppy" and
+                               groupname ~= "flammable" and
+                               groupname ~= "crumbly" and
+                               groupname ~= "snappy" 
+                       then
+                               def.groups.groupname = nil
+                       end
+               end     
+               if minetest.get_modpath("moreblocks") then
+                       stairsplus:register_all(
+                               mod,
+                               name,
+                               nodename,
+                               {
+                                       description = def.description,
+                                       tiles = def.tiles,
+                                       groups = def.groups,
+                                       sounds = def.sounds,
+                               }
+                       )
+               elseif minetest.get_modpath("stairs") then      
+                       stairs.register_stair_and_slab(name,nodename,
+                               def.groups,
+                               def.tiles,
+                               ("%s Stair"):format(def.description),
+                               ("%s Slab"):format(def.description),
+                               def.sounds
+                       )       
+               end     
+       end
        def.drawtype = def.drawtype or (def.mesh and "mesh") or (def.node_box and "nodebox")
        def.sounds = def.sounds or default.node_sound_defaults()
 
@@ -88,4 +122,11 @@ function xdecor.register(name, def)
        end
 
        minetest.register_node("xdecor:"..name, def)
+       
+       if minetest.settings:get_bool("disable_xdecor_workbench") and 
+       (minetest.get_modpath("moreblocks") or minetest.get_modpath("stairs")) then
+               if xdecor.stairs_valid_def(def) then
+                       xdecor_stairs_alternative("xdecor:"..name, def)
+               end
+       end
 end
index 629daee3e4d58c7dabc480cc2ab6f9dd7e8c1c35..bab6806c67b06b72559ab85fc7958187b15f0212 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -8,17 +8,30 @@ dofile(modpath.."/handlers/helpers.lua")
 dofile(modpath.."/handlers/nodeboxes.lua")
 dofile(modpath.."/handlers/registration.lua")
 
--- Item files.
-dofile(modpath.."/src/chess.lua")
-dofile(modpath.."/src/cooking.lua")
-dofile(modpath.."/src/craftitems.lua")
-dofile(modpath.."/src/enchanting.lua")
-dofile(modpath.."/src/hive.lua")
-dofile(modpath.."/src/itemframe.lua")
-dofile(modpath.."/src/mailbox.lua")
-dofile(modpath.."/src/mechanisms.lua")
+-- Node and others
+dofile(modpath.."/src/alias.lua")
 dofile(modpath.."/src/nodes.lua")
 dofile(modpath.."/src/recipes.lua")
-dofile(modpath.."/src/rope.lua")
-dofile(modpath.."/src/workbench.lua")
+
+-- Elements
+local submod = {
+       "chess",
+       "cooking",
+       "enchanting",
+       "hive",
+       "itemframe",
+       "mailbox",
+       "mechanisms",
+       "rope",
+       "workbench"
+}
+
+for _, name in ipairs(submod) do
+       local enable = not(minetest.settings:get_bool("disable_xdecor_"..name))
+       if enable then
+               dofile(modpath.."/src/"..name..".lua")
+       end
+end
+
+
 --print(string.format("[xdecor] loaded in %.2f ms", (os.clock()-t)*1000))
diff --git a/settingtypes.txt b/settingtypes.txt
new file mode 100644 (file)
index 0000000..a477bcc
--- /dev/null
@@ -0,0 +1,11 @@
+#For disabling a element in xdecor.
+
+disable_xdecor_chess           (Disable element Chess)                 bool false
+disable_xdecor_cooking         (Disable element Cooking)               bool false
+disable_xdecor_enchanting      (Disable element Enchanting)    bool false
+disable_xdecor_hive            (Disable element Hive)                  bool false
+disable_xdecor_itemframe       (Disable element Itemframe)     bool false
+disable_xdecor_mailbox                 (Disable element Mailbox)               bool false
+disable_xdecor_mechanisms      (Disable element Mechanisms)    bool false
+disable_xdecor_rope            (Disable element Rope)                  bool false
+disable_xdecor_workbench       (Disable element Workbench)     bool false
\ No newline at end of file
diff --git a/src/alias.lua b/src/alias.lua
new file mode 100644 (file)
index 0000000..dc95741
--- /dev/null
@@ -0,0 +1 @@
+minetest.register_alias("xdecor:crafting_guide", "craftguide:book")
index 017b1b1a4211bc77b01265678ec2d6db84fbcad9..7d436222a5265bfefb72e0eab3a2164272f8657c 100644 (file)
@@ -626,3 +626,12 @@ register_piece("bishop", 2)
 register_piece("queen")
 register_piece("king")
 
+-- Recipes
+
+minetest.register_craft({
+       output = "realchess:chessboard",
+       recipe = {
+               {"dye:black", "dye:white", "dye:black"},
+               {"stairs:slab_wood", "stairs:slab_wood", "stairs:slab_wood"}
+       }
+})
index aaeae79c2fd6e73ef05079b1eea7d4f6af17c07f..7d9d05920389fdf38c4d3133aa2131bba3d6524f 100644 (file)
@@ -198,3 +198,38 @@ xdecor.register("cauldron_soup", {
        end
 })
 
+-- Craft items
+
+minetest.register_craftitem("xdecor:bowl", {
+       description = "Bowl",
+       inventory_image = "xdecor_bowl.png",
+       wield_image = "xdecor_bowl.png"
+})
+
+minetest.register_craftitem("xdecor:bowl_soup", {
+       description = "Bowl of soup",
+       inventory_image = "xdecor_bowl_soup.png",
+       wield_image = "xdecor_bowl_soup.png",
+       groups = {not_in_creative_inventory=1},
+       stack_max = 1,
+       on_use = minetest.item_eat(30, "xdecor:bowl")
+})
+
+-- Recipes
+
+minetest.register_craft({
+       output = "xdecor:bowl 3",
+       recipe = {
+               {"group:wood", "", "group:wood"},
+               {"", "group:wood", ""}
+       }
+})
+
+minetest.register_craft({
+       output = "xdecor:cauldron_empty",
+       recipe = {
+               {"default:iron_lump", "", "default:iron_lump"},
+               {"default:iron_lump", "", "default:iron_lump"},
+               {"default:iron_lump", "default:iron_lump", "default:iron_lump"}
+       }
+})
\ No newline at end of file
diff --git a/src/craftitems.lua b/src/craftitems.lua
deleted file mode 100644 (file)
index 6203dd2..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-minetest.register_craftitem("xdecor:bowl", {
-       description = "Bowl",
-       inventory_image = "xdecor_bowl.png",
-       wield_image = "xdecor_bowl.png"
-})
-
-minetest.register_craftitem("xdecor:bowl_soup", {
-       description = "Bowl of soup",
-       inventory_image = "xdecor_bowl_soup.png",
-       wield_image = "xdecor_bowl_soup.png",
-       groups = {not_in_creative_inventory=1},
-       stack_max = 1,
-       on_use = minetest.item_eat(30, "xdecor:bowl")
-})
-
-minetest.register_tool("xdecor:hammer", {
-       description = "Hammer",
-       inventory_image = "xdecor_hammer.png",
-       wield_image = "xdecor_hammer.png",
-       on_use = function() do return end end
-})
-
-minetest.register_craftitem("xdecor:honey", {
-       description = "Honey",
-       inventory_image = "xdecor_honey.png",
-       wield_image = "xdecor_honey.png",
-       groups = {not_in_creative_inventory=1},
-       on_use = minetest.item_eat(2)
-})
-
-minetest.register_alias("xdecor:crafting_guide", "craftguide:book")
index ad2e7e49135a7dd04bb13c4d3471a0ca12a19534..53ee21776eaf4d4f96d28c5dccc1668c934b3000 100644 (file)
@@ -281,3 +281,24 @@ enchanting:register_tools("default", {
                sword  = {enchants = "sharp"}
        }
 })
+
+enchanting:register_tools("3d_armor", {
+       materials = "steel, bronze, gold, diamond",
+       tools = {
+               boots      = {enchants = "strong, speed"},
+               chestplate = {enchants = "strong"},
+               helmet     = {enchants = "strong"},
+               leggings   = {enchants = "strong"}
+       }
+})
+
+-- Recipes
+
+minetest.register_craft({
+       output = "xdecor:enchantment_table",
+       recipe = {
+               {"", "default:book", ""},
+               {"default:diamond", "default:obsidian", "default:diamond"},
+               {"default:obsidian", "default:obsidian", "default:obsidian"}
+       }
+})
\ No newline at end of file
index 604313512f3811ded7cbc48e7b1c339ed8d1553b..d7baf490c54b1f85c7b470669efe89ee87e54724 100644 (file)
@@ -67,3 +67,23 @@ xdecor.register("hive", {
        end
 })
 
+-- Craft items
+
+minetest.register_craftitem("xdecor:honey", {
+       description = "Honey",
+       inventory_image = "xdecor_honey.png",
+       wield_image = "xdecor_honey.png",
+       groups = {not_in_creative_inventory=1},
+       on_use = minetest.item_eat(2)
+})
+
+-- Recipes
+
+minetest.register_craft({
+       output = "xdecor:hive",
+       recipe = {
+               {"group:stick", "group:stick", "group:stick"},
+               {"default:paper", "default:paper", "default:paper"},
+               {"group:stick", "group:stick", "group:stick"}
+       }
+})
\ No newline at end of file
index 02d83d6fe7992a4bf104ce933f4bf5ec6871939b..5b890bed2b454ac776d495edf7e7b85bcc655924 100644 (file)
@@ -154,3 +154,13 @@ minetest.register_entity("xdecor:f_item", {
        end
 })
 
+-- Recipes
+
+minetest.register_craft({
+       output = "xdecor:itemframe",
+       recipe = {
+               {"group:stick", "group:stick", "group:stick"},
+               {"group:stick", "default:paper", "group:stick"},
+               {"group:stick", "group:stick", "group:stick"}
+       }
+})
\ No newline at end of file
index 7f27af0d28c51c4ce75597dbc46e4bc608e2455a..5c2dcd291df015ab50c0f28f3fbda65ec4ae148d 100644 (file)
@@ -161,3 +161,14 @@ xdecor.register("mailbox", {
        allow_metadata_inventory_put = mailbox.put,
        after_place_node = mailbox.after_place_node
 })
+
+-- Recipes
+
+minetest.register_craft({
+       output = "xdecor:mailbox",
+       recipe = {
+               {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
+               {"dye:red", "default:paper", "dye:red"},
+               {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
+       }
+})
\ No newline at end of file
index 8e1072dee080eb891f5ccb7c1f59bf0355532e54..ada0afed52a46f772d48d3d5db126740297c8433 100644 (file)
@@ -115,3 +115,24 @@ xdecor.register("lever_on", {
        drop = "xdecor:lever_off"
 })
 
+-- Recipes
+
+minetest.register_craft({
+       output = "xdecor:pressure_stone_off",
+       type = "shapeless",
+       recipe = {"group:stone", "group:stone"}
+})
+
+minetest.register_craft({
+       output = "xdecor:pressure_wood_off",
+       type = "shapeless",
+       recipe = {"group:wood", "group:wood"}
+})
+
+minetest.register_craft({
+       output = "xdecor:lever_off",
+       recipe = {
+               {"group:stick"},
+               {"group:stone"}
+       }
+})
\ No newline at end of file
index 9e0b169ef1924e5449421593fa6eac547e338add..cb7ad1927ca77a6c30ca5d6b97ae5117a325fc9f 100644 (file)
@@ -16,14 +16,6 @@ minetest.register_craft({
        }
 })
 
-minetest.register_craft({
-       output = "xdecor:bowl 3",
-       recipe = {
-               {"group:wood", "", "group:wood"},
-               {"", "group:wood", ""}
-       }
-})
-
 minetest.register_craft({
        output = "xdecor:candle",
        recipe = {
@@ -54,23 +46,6 @@ minetest.register_craft({
        }
 })
 
-minetest.register_craft({
-       output = "xdecor:cauldron_empty",
-       recipe = {
-               {"default:iron_lump", "", "default:iron_lump"},
-               {"default:iron_lump", "", "default:iron_lump"},
-               {"default:iron_lump", "default:iron_lump", "default:iron_lump"}
-       }
-})
-
-minetest.register_craft({
-       output = "realchess:chessboard",
-       recipe = {
-               {"dye:black", "dye:white", "dye:black"},
-               {"stairs:slab_wood", "stairs:slab_wood", "stairs:slab_wood"}
-       }
-})
-
 minetest.register_craft({
        output = "xdecor:chair",
        recipe = {
@@ -138,32 +113,6 @@ 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:itemframe",
-       recipe = {
-               {"group:stick", "group:stick", "group:stick"},
-               {"group:stick", "default:paper", "group:stick"},
-               {"group:stick", "group:stick", "group:stick"}
-       }
-})
-
-minetest.register_craft({
-       output = "xdecor:hammer",
-       recipe = {
-               {"default:steel_ingot", "group:stick", "default:steel_ingot"},
-               {"", "group:stick", ""}
-       }
-})
-
 minetest.register_craft({
        output = "xdecor:hard_clay",
        recipe = {
@@ -172,15 +121,6 @@ minetest.register_craft({
        }
 })
 
-minetest.register_craft({
-       output = "xdecor:hive",
-       recipe = {
-               {"group:stick", "group:stick", "group:stick"},
-               {"default:paper", "default:paper", "default:paper"},
-               {"group:stick", "group:stick", "group:stick"}
-       }
-})
-
 minetest.register_craft({
        output = "xdecor:iron_lightbox",
        recipe = {
@@ -207,23 +147,6 @@ minetest.register_craft({
        }
 })
 
-minetest.register_craft({
-       output = "xdecor:lever_off",
-       recipe = {
-               {"group:stick"},
-               {"group:stone"}
-       }
-})
-
-minetest.register_craft({
-       output = "xdecor:mailbox",
-       recipe = {
-               {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
-               {"dye:red", "default:paper", "dye:red"},
-               {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
-       }
-})
-
 minetest.register_craft({
        output = "xdecor:moonbrick",
        recipe = {
@@ -255,27 +178,6 @@ minetest.register_craft({
        }
 })
 
-minetest.register_craft({
-       output = "xdecor:pressure_stone_off",
-       type = "shapeless",
-       recipe = {"group:stone", "group:stone"}
-})
-
-minetest.register_craft({
-       output = "xdecor:pressure_wood_off",
-       type = "shapeless",
-       recipe = {"group:wood", "group:wood"}
-})
-
-minetest.register_craft({
-       output = "xdecor:rope",
-       recipe = {
-               {"farming:string"},
-               {"farming:string"},
-               {"farming:string"}
-       }
-})
-
 minetest.register_craft({
        output = "xdecor:stone_tile 2",
        recipe = {
@@ -336,14 +238,6 @@ minetest.register_craft({
        }
 })
 
-minetest.register_craft({
-       output = "xdecor:workbench",
-       recipe = {
-               {"group:wood", "group:wood"},
-               {"group:wood", "group:wood"}
-       }
-})
-
 minetest.register_craft({
        output = "xdecor:woodframed_glass",
        recipe = {
index 1627fd8133982522421a36460bb1f758b00b645c..b6d945291e66dd59087e82658ce048a272c5f2e8 100644 (file)
@@ -55,3 +55,14 @@ xdecor.register("rope", {
                end
        end
 })
+
+-- Recipes
+
+minetest.register_craft({
+       output = "xdecor:rope",
+       recipe = {
+               {"farming:string"},
+               {"farming:string"},
+               {"farming:string"}
+       }
+})
\ No newline at end of file
index 80a4c5e52c1bd364f87a413bbd96dbe7e4f16224..740ba5c80cdc46eef15179c328cea43bdb8f8583 100644 (file)
@@ -8,23 +8,7 @@ local registered_nodes = minetest.registered_nodes
 -- Only the regular, solid blocks without metas or explosivity can be cut
 local nodes = {}
 for node, def in pairs(registered_nodes) do
-       if (def.drawtype == "normal" or def.drawtype:sub(1,5) == "glass") and
-          (def.groups.cracky or def.groups.choppy) and
-          not def.on_construct and
-          not def.after_place_node and
-          not def.on_rightclick and
-          not def.on_blast and
-          not def.allow_metadata_inventory_take and
-          not (def.groups.not_in_creative_inventory == 1) and
-          not (def.groups.not_cuttable == 1) and
-          not def.groups.wool and
-          (def.tiles and type(def.tiles[1]) == "string" and not
-               def.tiles[1]:find("default_mineral")) and
-          not def.mesecons and
-          def.description and
-          def.description ~= "" and
-          def.light_source == 0
-       then
+       if xdecor.stairs_valid_def(def) then
                nodes[#nodes+1] = node
        end
 end
@@ -303,3 +287,30 @@ for i=1, #nodes do
        end
 end
 end
+
+-- Craft items
+
+minetest.register_tool("xdecor:hammer", {
+       description = "Hammer",
+       inventory_image = "xdecor_hammer.png",
+       wield_image = "xdecor_hammer.png",
+       on_use = function() do return end end
+})
+
+-- Recipes
+
+minetest.register_craft({
+       output = "xdecor:hammer",
+       recipe = {
+               {"default:steel_ingot", "group:stick", "default:steel_ingot"},
+               {"", "group:stick", ""}
+       }
+})
+
+minetest.register_craft({
+       output = "xdecor:workbench",
+       recipe = {
+               {"group:wood", "group:wood"},
+               {"group:wood", "group:wood"}
+       }
+})