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.
master
Jat15 2017-08-28 07:41:14 +02:00 committed by JP Guerrero
parent 5718a0bc82
commit 271d5b1147
16 changed files with 262 additions and 165 deletions

View 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

View 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

View File

@ -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))

11
settingtypes.txt Normal file
View File

@ -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

1
src/alias.lua Normal file
View File

@ -0,0 +1 @@
minetest.register_alias("xdecor:crafting_guide", "craftguide:book")

View 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"}
}
})

View 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"}
}
})

View File

@ -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")

View 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"}
}
})

View 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"}
}
})

View 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"}
}
})

View 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"}
}
})

View 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"}
}
})

View 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 = {

View File

@ -55,3 +55,14 @@ xdecor.register("rope", {
end
end
})
-- Recipes
minetest.register_craft({
output = "xdecor:rope",
recipe = {
{"farming:string"},
{"farming:string"},
{"farming:string"}
}
})

View 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"}
}
})