Make 1x1, 1x2 and 2x2 drawers disableable

The new settings for the minetest.conf are:
`drawers_disable_1x1`
`drawers_disable_1x2`
`drawers_disable_2x2`
This commit is contained in:
LNJ 2017-04-09 22:31:31 +02:00
parent 76d5e3ba9f
commit 40230857ad
No known key found for this signature in database
GPG Key ID: 69268DBD835B6B0B
2 changed files with 68 additions and 52 deletions

@ -43,6 +43,10 @@ else
end end
drawers.enable_1x1 = not core.setting_getbool("drawers_disable_1x1")
drawers.enable_1x2 = not core.setting_getbool("drawers_disable_1x2")
drawers.enable_2x2 = not core.setting_getbool("drawers_disable_2x2")
-- --
-- Load files -- Load files
-- --

@ -157,6 +157,7 @@ function drawers.register_drawer(name, def)
def.after_dig_node = pipeworks.after_dig def.after_dig_node = pipeworks.after_dig
end end
if drawers.enable_1x1 then
-- normal drawer 1x1 = 1 -- normal drawer 1x1 = 1
def1 = table.copy(def) def1 = table.copy(def)
def1.description = def.description .. " Drawer" def1.description = def.description .. " Drawer"
@ -167,7 +168,9 @@ function drawers.register_drawer(name, def)
def1.groups.drawer = 1 def1.groups.drawer = 1
core.register_node(name .. "1", def1) core.register_node(name .. "1", def1)
core.register_alias(name, name .. "1") -- 1x1 drawer is the default one core.register_alias(name, name .. "1") -- 1x1 drawer is the default one
end
if drawers.enable_1x2 then
-- 1x2 = 2 -- 1x2 = 2
def2 = table.copy(def) def2 = table.copy(def)
def2.description = def.description .. " Drawers (1x2)" def2.description = def.description .. " Drawers (1x2)"
@ -177,7 +180,9 @@ function drawers.register_drawer(name, def)
def2.tiles4 = nil def2.tiles4 = nil
def2.groups.drawer = 2 def2.groups.drawer = 2
core.register_node(name .. "2", def2) core.register_node(name .. "2", def2)
end
if drawers.enable_2x2 then
-- 2x2 = 4 -- 2x2 = 4
def4 = table.copy(def) def4 = table.copy(def)
def4.description = def.description .. " Drawers (2x2)" def4.description = def.description .. " Drawers (2x2)"
@ -187,8 +192,10 @@ function drawers.register_drawer(name, def)
def4.tiles4 = nil def4.tiles4 = nil
def4.groups.drawer = 4 def4.groups.drawer = 4
core.register_node(name .. "4", def4) core.register_node(name .. "4", def4)
end
if (not def.no_craft) and def.material then if (not def.no_craft) and def.material then
if drawers.enable_1x1 then
core.register_craft({ core.register_craft({
output = name .. "1", output = name .. "1",
recipe = { recipe = {
@ -197,6 +204,8 @@ function drawers.register_drawer(name, def)
{def.material, def.material, def.material} {def.material, def.material, def.material}
} }
}) })
end
if drawers.enable_1x2 then
core.register_craft({ core.register_craft({
output = name .. "2 2", output = name .. "2 2",
recipe = { recipe = {
@ -205,6 +214,8 @@ function drawers.register_drawer(name, def)
{def.material, drawers.CHEST_ITEMSTRING, def.material} {def.material, drawers.CHEST_ITEMSTRING, def.material}
} }
}) })
end
if drawers.enable_2x2 then
core.register_craft({ core.register_craft({
output = name .. "4 4", output = name .. "4 4",
recipe = { recipe = {
@ -214,4 +225,5 @@ function drawers.register_drawer(name, def)
} }
}) })
end end
end
end end