2017-01-26 17:34:15 +01:00
|
|
|
-- define global
|
2017-01-22 23:54:42 +01:00
|
|
|
hopper = {}
|
2017-01-26 17:34:15 +01:00
|
|
|
|
2017-02-03 04:14:10 +01:00
|
|
|
-- internationalization boilerplate
|
2017-02-03 04:03:24 +01:00
|
|
|
local MP = minetest.get_modpath(minetest.get_current_modname())
|
2020-02-19 00:47:23 +01:00
|
|
|
local S = minetest.get_translator("hopper")
|
2017-02-03 04:03:24 +01:00
|
|
|
|
2022-07-10 20:25:00 +02:00
|
|
|
hopper.translator_escaped = function(...)
|
|
|
|
return minetest.formspec_escape(S(...))
|
|
|
|
end
|
|
|
|
|
2017-02-25 15:12:21 +01:00
|
|
|
if minetest.get_modpath("default") then
|
2017-03-31 08:58:28 +02:00
|
|
|
hopper.formspec_bg = default.gui_bg .. default.gui_bg_img .. default.gui_slots
|
2017-01-22 23:54:42 +01:00
|
|
|
else
|
2017-03-31 08:58:28 +02:00
|
|
|
hopper.formspec_bg = "bgcolor[#080808BB;true]" .. "listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]"
|
2017-02-05 05:29:23 +01:00
|
|
|
end
|
|
|
|
|
2017-03-31 08:58:28 +02:00
|
|
|
dofile(MP.."/config.lua")
|
|
|
|
dofile(MP.."/api.lua")
|
|
|
|
dofile(MP.."/utility.lua")
|
|
|
|
dofile(MP.."/doc.lua")
|
|
|
|
dofile(MP.."/nodes/hoppers.lua")
|
|
|
|
dofile(MP.."/nodes/chute.lua")
|
|
|
|
dofile(MP.."/nodes/sorter.lua")
|
|
|
|
dofile(MP.."/crafts.lua")
|
|
|
|
dofile(MP.."/abms.lua")
|
2017-02-05 05:29:23 +01:00
|
|
|
|
|
|
|
|
2017-02-24 04:36:40 +01:00
|
|
|
-------------------------------------------------------------------------------------------
|
|
|
|
-- Formspec handling
|
|
|
|
|
|
|
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
2024-08-16 22:28:33 +02:00
|
|
|
if string.sub(formname, 1, 16) ~= "hopper_formspec:" then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local pos = minetest.string_to_pos(string.sub(formname, 17, -1))
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
if fields.eject then
|
2017-02-24 04:36:40 +01:00
|
|
|
local eject_setting = meta:get_string("eject") == "true"
|
2024-08-16 22:28:33 +02:00
|
|
|
-- "" deletes the key
|
|
|
|
meta:set_string("eject", eject_setting and "" or "true")
|
|
|
|
end
|
|
|
|
if fields.filter_all then
|
2017-04-01 17:48:54 +02:00
|
|
|
local filter_all_setting = meta:get_string("filter_all") == "true"
|
2024-08-16 22:28:33 +02:00
|
|
|
meta:set_string("filter_all", filter_all_setting and "" or "true")
|
2017-02-24 04:36:40 +01:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
2016-11-12 12:00:09 +01:00
|
|
|
|
2017-01-22 23:54:42 +01:00
|
|
|
-- add lucky blocks
|
2016-11-12 12:00:09 +01:00
|
|
|
if minetest.get_modpath("lucky_block") then
|
|
|
|
lucky_block:add_blocks({
|
|
|
|
{"dro", {"hopper:hopper"}, 3},
|
|
|
|
{"nod", "default:lava_source", 1},
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2022-07-10 20:25:16 +02:00
|
|
|
-- Utility function for inventory movement logs
|
|
|
|
function hopper.log_inventory(...)
|
|
|
|
minetest.log(hopper.config.inv_log_level, ...)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2020-03-03 04:31:29 +01:00
|
|
|
minetest.log("action", "[hopper] Hopper mod loaded")
|