a little formatting and comment cleanup

This commit is contained in:
FaceDeer 2017-02-02 20:14:10 -07:00
parent 191c242816
commit a1a9900b6c

@ -1,9 +1,11 @@
-- define global -- define global
hopper = {} hopper = {}
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname()) local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua") local S, NS = dofile(MP.."/intllib.lua")
-- settings
local texture_resolution = minetest.setting_get("hopper_texture_size") local texture_resolution = minetest.setting_get("hopper_texture_size")
if texture_resolution == nil then if texture_resolution == nil then
texture_resolution = "16" texture_resolution = "16"
@ -14,6 +16,7 @@ if single_craftable_item == nil then
single_craftable_item = true single_craftable_item = true
end end
-- Documentation
local hopper_long_desc = S("Hopper to transfer items between neighboring blocks' inventories") local hopper_long_desc = S("Hopper to transfer items between neighboring blocks' inventories")
local hopper_usage = S("Items are transfered from the block at the wide end of the hopper to the block at the narrow end of the hopper at a rate of one per second. Items can also be placed directly into the hopper's inventory, or they can be dropped into the space above a hopper and will be sucked into the hopper's inventory automatically.\n\n") local hopper_usage = S("Items are transfered from the block at the wide end of the hopper to the block at the narrow end of the hopper at a rate of one per second. Items can also be placed directly into the hopper's inventory, or they can be dropped into the space above a hopper and will be sucked into the hopper's inventory automatically.\n\n")
if single_craftable_item then if single_craftable_item then
@ -71,7 +74,6 @@ hopper:add_container({
-- 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({
{"top", "protector:chest", "main"}, {"top", "protector:chest", "main"},
{"bottom", "protector:chest", "main"}, {"bottom", "protector:chest", "main"},
@ -81,7 +83,6 @@ end
-- wine mod support -- wine mod support
if minetest.get_modpath("wine") then if minetest.get_modpath("wine") then
hopper:add_container({ hopper:add_container({
{"top", "wine:wine_barrel", "dst"}, {"top", "wine:wine_barrel", "dst"},
{"bottom", "wine:wine_barrel", "src"}, {"bottom", "wine:wine_barrel", "src"},
@ -91,7 +92,6 @@ end
-- formspec -- formspec
local function get_hopper_formspec(pos) local function get_hopper_formspec(pos)
local spos = pos.x .. "," .. pos.y .. "," ..pos.z local spos = pos.x .. "," .. pos.y .. "," ..pos.z
local formspec = local formspec =
"size[8,9]" "size[8,9]"
@ -103,7 +103,6 @@ local function get_hopper_formspec(pos)
.. "list[current_player;main;0,6.08;8,3;8]" .. "list[current_player;main;0,6.08;8,3;8]"
.. "listring[nodemeta:" .. spos .. ";main]" .. "listring[nodemeta:" .. spos .. ";main]"
.. "listring[current_player;main]" .. "listring[current_player;main]"
return formspec return formspec
end end
@ -151,7 +150,11 @@ minetest.register_node("hopper:hopper", {
groups = {cracky = 3}, groups = {cracky = 3},
drawtype = "nodebox", drawtype = "nodebox",
paramtype = "light", paramtype = "light",
tiles = {"hopper_top_" .. texture_resolution .. ".png", "hopper_top_" .. texture_resolution .. ".png", "hopper_front_" .. texture_resolution .. ".png"}, tiles = {
"hopper_top_" .. texture_resolution .. ".png",
"hopper_top_" .. texture_resolution .. ".png",
"hopper_front_" .. texture_resolution .. ".png"
},
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
@ -236,8 +239,12 @@ minetest.register_node("hopper:hopper_side", {
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
tiles = { tiles = {
"hopper_top_" .. texture_resolution .. ".png", "hopper_bottom_" .. texture_resolution .. ".png", "hopper_back_" .. texture_resolution .. ".png", "hopper_top_" .. texture_resolution .. ".png",
"hopper_side_" .. texture_resolution .. ".png", "hopper_back_" .. texture_resolution .. ".png", "hopper_back_" .. texture_resolution .. ".png" "hopper_bottom_" .. texture_resolution .. ".png",
"hopper_back_" .. texture_resolution .. ".png",
"hopper_side_" .. texture_resolution .. ".png",
"hopper_back_" .. texture_resolution .. ".png",
"hopper_back_" .. texture_resolution .. ".png"
}, },
drop = hopper_side_drop, drop = hopper_side_drop,
node_box = { node_box = {
@ -339,6 +346,7 @@ minetest.register_abm({
end, end,
}) })
-- Used to remove items from the target block and put it into the hopper's inventory
local function take_item_from(hopper_pos, target_pos, target_node, target_inventory_name) local function take_item_from(hopper_pos, target_pos, target_node, target_inventory_name)
if target_inventory_name == nil then if target_inventory_name == nil then
return return
@ -377,6 +385,7 @@ local function take_item_from(hopper_pos, target_pos, target_node, target_invent
end end
end end
-- Used to put items from the hopper inventory into the target block
local function send_item_to(hopper_pos, target_pos, target_node, target_inventory_name) local function send_item_to(hopper_pos, target_pos, target_node, target_inventory_name)
if target_inventory_name == nil then if target_inventory_name == nil then
return return
@ -405,7 +414,7 @@ local function send_item_to(hopper_pos, target_pos, target_node, target_inventor
or placer == nil -- backwards compatibility, older versions of this mod didn't record who placed the hopper or placer == nil -- backwards compatibility, older versions of this mod didn't record who placed the hopper
or target_def.allow_metadata_inventory_put(target_pos, target_inventory_name, i, stack_to_put, placer) > 0 then or target_def.allow_metadata_inventory_put(target_pos, target_inventory_name, i, stack_to_put, placer) > 0 then
hopper_inv:set_stack("main", i, stack) hopper_inv:set_stack("main", i, stack)
--add to hopper or chest --add to target node
target_inv:add_item(target_inventory_name, item) target_inv:add_item(target_inventory_name, item)
if target_def.on_metadata_inventory_put ~= nil and placer ~= nil then if target_def.on_metadata_inventory_put ~= nil and placer ~= nil then
target_def.on_metadata_inventory_put(target_pos, target_inventory_name, i, stack_to_put, placer) target_def.on_metadata_inventory_put(target_pos, target_inventory_name, i, stack_to_put, placer)
@ -417,6 +426,7 @@ local function send_item_to(hopper_pos, target_pos, target_node, target_inventor
end end
end end
-- Used to convert side hopper facing into source and destination relative coordinates
-- This was tedious to populate and test -- This was tedious to populate and test
local directions = { local directions = {
[0]={["src"]={x=0, y=1, z=0},["dst"]={x=-1, y=0, z=0}}, [0]={["src"]={x=0, y=1, z=0},["dst"]={x=-1, y=0, z=0}},
@ -492,7 +502,6 @@ minetest.register_abm({
end, end,
}) })
minetest.register_craft({ minetest.register_craft({
output = "hopper:hopper", output = "hopper:hopper",
recipe = { recipe = {