From: Jat15 Date: Mon, 28 Aug 2017 05:41:14 +0000 (+0200) Subject: Add settings and compatibility with moreblocks and stairs X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=271d5b11472b4dbd0a2e8c8c5dcdb1047e97ebb9;p=xdecor.git Add settings and compatibility with moreblocks and stairs If workbench disabling. And setting for disabling: - Chess - Cooking - Enchanting - Hive - Itemframe - Mailbox - Mechanisms - Rope - Workbench By default all active. --- diff --git a/handlers/helpers.lua b/handlers/helpers.lua index 13d3ed7..e6ad8b9 100644 --- a/handlers/helpers.lua +++ b/handlers/helpers.lua @@ -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 diff --git a/handlers/registration.lua b/handlers/registration.lua index fc6409e..0b7f2d6 100644 --- a/handlers/registration.lua +++ b/handlers/registration.lua @@ -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 diff --git a/init.lua b/init.lua index 629daee..bab6806 100644 --- 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 index 0000000..a477bcc --- /dev/null +++ b/settingtypes.txt @@ -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 index 0000000..dc95741 --- /dev/null +++ b/src/alias.lua @@ -0,0 +1 @@ +minetest.register_alias("xdecor:crafting_guide", "craftguide:book") diff --git a/src/chess.lua b/src/chess.lua index 017b1b1..7d43622 100644 --- a/src/chess.lua +++ b/src/chess.lua @@ -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"} + } +}) diff --git a/src/cooking.lua b/src/cooking.lua index aaeae79..7d9d059 100644 --- a/src/cooking.lua +++ b/src/cooking.lua @@ -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 index 6203dd2..0000000 --- a/src/craftitems.lua +++ /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") diff --git a/src/enchanting.lua b/src/enchanting.lua index ad2e7e4..53ee217 100644 --- a/src/enchanting.lua +++ b/src/enchanting.lua @@ -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 diff --git a/src/hive.lua b/src/hive.lua index 6043135..d7baf49 100644 --- a/src/hive.lua +++ b/src/hive.lua @@ -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 diff --git a/src/itemframe.lua b/src/itemframe.lua index 02d83d6..5b890be 100644 --- a/src/itemframe.lua +++ b/src/itemframe.lua @@ -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 diff --git a/src/mailbox.lua b/src/mailbox.lua index 7f27af0..5c2dcd2 100644 --- a/src/mailbox.lua +++ b/src/mailbox.lua @@ -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 diff --git a/src/mechanisms.lua b/src/mechanisms.lua index 8e1072d..ada0afe 100644 --- a/src/mechanisms.lua +++ b/src/mechanisms.lua @@ -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 diff --git a/src/recipes.lua b/src/recipes.lua index 9e0b169..cb7ad19 100644 --- a/src/recipes.lua +++ b/src/recipes.lua @@ -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 = { diff --git a/src/rope.lua b/src/rope.lua index 1627fd8..b6d9452 100644 --- a/src/rope.lua +++ b/src/rope.lua @@ -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 diff --git a/src/workbench.lua b/src/workbench.lua index 80a4c5e..740ba5c 100644 --- a/src/workbench.lua +++ b/src/workbench.lua @@ -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"} + } +})