make default dependency optional

This commit is contained in:
FaceDeer 2017-02-25 07:12:21 -07:00
parent cf4608a412
commit 7f255423f7
2 changed files with 59 additions and 51 deletions

@ -1,4 +1,4 @@
default default?
lucky_block? lucky_block?
doc? doc?
intllib? intllib?

108
init.lua

@ -93,24 +93,28 @@ hopper:add_container({
{"bottom", "hopper:chute", "main"}, {"bottom", "hopper:chute", "main"},
{"side", "hopper:chute", "main"}, {"side", "hopper:chute", "main"},
{"top", "default:chest", "main"},
{"bottom", "default:chest", "main"},
{"side", "default:chest", "main"},
{"top", "default:furnace", "dst"},
{"bottom", "default:furnace", "src"},
{"side", "default:furnace", "fuel"},
{"top", "default:furnace_active", "dst"},
{"bottom", "default:furnace_active", "src"},
{"side", "default:furnace_active", "fuel"},
{"top", "default:chest_locked", "main"},
{"bottom", "default:chest_locked", "main"},
{"side", "default:chest_locked", "main"},
}) })
if minetest.get_modpath("default") then
hopper:add_container({
{"top", "default:chest", "main"},
{"bottom", "default:chest", "main"},
{"side", "default:chest", "main"},
{"top", "default:furnace", "dst"},
{"bottom", "default:furnace", "src"},
{"side", "default:furnace", "fuel"},
{"top", "default:furnace_active", "dst"},
{"bottom", "default:furnace_active", "src"},
{"side", "default:furnace_active", "fuel"},
{"top", "default:chest_locked", "main"},
{"bottom", "default:chest_locked", "main"},
{"side", "default:chest_locked", "main"},
})
end
-- protector redo mod support -- protector redo mod support
if minetest.get_modpath("protector") then if minetest.get_modpath("protector") then
hopper:add_container({ hopper:add_container({
@ -264,7 +268,6 @@ end
------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------
-- Nodes -- Nodes
local function get_eject_button_texts(pos) local function get_eject_button_texts(pos)
if minetest.get_meta(pos):get_string("eject") == "true" then if minetest.get_meta(pos):get_string("eject") == "true" then
return S("Don't\nEject"), S("This hopper is currently set to eject items from its output\neven if there isn't a compatible block positioned to receive it.\nClick this button to disable this feature.") return S("Don't\nEject"), S("This hopper is currently set to eject items from its output\neven if there isn't a compatible block positioned to receive it.\nClick this button to disable this feature.")
@ -277,15 +280,20 @@ local function get_string_pos(pos)
return pos.x .. "," .. pos.y .. "," ..pos.z return pos.x .. "," .. pos.y .. "," ..pos.z
end end
local formspec_bg
if minetest.get_modpath("default") then
formspec_bg = default.gui_bg .. default.gui_bg_img .. default.gui_slots
else
formspec_bg = "bgcolor[#080808BB;true]" .. "listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]"
end
-- formspec -- formspec
local function get_hopper_formspec(pos) local function get_hopper_formspec(pos)
local eject_button_text, eject_button_tooltip = get_eject_button_texts(pos) local eject_button_text, eject_button_tooltip = get_eject_button_texts(pos)
local spos = get_string_pos(pos) local spos = get_string_pos(pos)
local formspec = local formspec =
"size[8,9]" "size[8,9]"
.. default.gui_bg .. formspec_bg
.. default.gui_bg_img
.. default.gui_slots
.. "list[nodemeta:" .. spos .. ";main;2,0.3;4,4;]" .. "list[nodemeta:" .. spos .. ";main;2,0.3;4,4;]"
.. "button_exit[7,2;1,1;eject;"..eject_button_text.."]" .. "button_exit[7,2;1,1;eject;"..eject_button_text.."]"
.. "tooltip[eject;"..eject_button_tooltip.."]" .. "tooltip[eject;"..eject_button_tooltip.."]"
@ -508,9 +516,7 @@ local function get_chute_formspec(pos)
local spos = pos.x .. "," .. pos.y .. "," ..pos.z local spos = pos.x .. "," .. pos.y .. "," ..pos.z
local formspec = local formspec =
"size[8,7]" "size[8,7]"
.. default.gui_bg .. formspec_bg
.. default.gui_bg_img
.. default.gui_slots
.. "list[nodemeta:" .. spos .. ";main;3,0.3;2,2;]" .. "list[nodemeta:" .. spos .. ";main;3,0.3;2,2;]"
.. "button_exit[7,1;1,1;eject;"..eject_button_text.."]" .. "button_exit[7,1;1,1;eject;"..eject_button_text.."]"
.. "tooltip[eject;"..eject_button_tooltip.."]" .. "tooltip[eject;"..eject_button_tooltip.."]"
@ -771,41 +777,43 @@ minetest.register_abm({
------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------
-- Crafts -- Crafts
minetest.register_craft({ if minetest.get_modpath("default") then
output = "hopper:hopper",
recipe = {
{"default:steel_ingot","default:chest","default:steel_ingot"},
{"","default:steel_ingot",""},
}
})
minetest.register_craft({
output = "hopper:chute",
recipe = {
{"default:steel_ingot","default:chest","default:steel_ingot"},
}
})
if not single_craftable_item then
minetest.register_craft({ minetest.register_craft({
output = "hopper:hopper_side", output = "hopper:hopper",
recipe = { recipe = {
{"default:steel_ingot","default:chest","default:steel_ingot"}, {"default:steel_ingot","default:chest","default:steel_ingot"},
{"","","default:steel_ingot"}, {"","default:steel_ingot",""},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "hopper:hopper_side", output = "hopper:chute",
type="shapeless", recipe = {
recipe = {"hopper:hopper"}, {"default:steel_ingot","default:chest","default:steel_ingot"},
}) }
minetest.register_craft({
output = "hopper:hopper",
type="shapeless",
recipe = {"hopper:hopper_side"},
}) })
if not single_craftable_item then
minetest.register_craft({
output = "hopper:hopper_side",
recipe = {
{"default:steel_ingot","default:chest","default:steel_ingot"},
{"","","default:steel_ingot"},
}
})
minetest.register_craft({
output = "hopper:hopper_side",
type="shapeless",
recipe = {"hopper:hopper"},
})
minetest.register_craft({
output = "hopper:hopper",
type="shapeless",
recipe = {"hopper:hopper_side"},
})
end
end end
-- add lucky blocks -- add lucky blocks