mirror of
https://github.com/minetest-mods/hopper.git
synced 2025-01-03 02:57:29 +01:00
merge recent tenplus1 changes
This commit is contained in:
commit
f16b51efe1
@ -19,5 +19,6 @@ Change log:
|
||||
- 1.1 - Hoppers now work with new node timer Furnaces. Reduced Abm's and tidied code.
|
||||
- 1.2 - Added simple API so that hoppers can work with other containers.
|
||||
- 1.3 - Hoppers now call on_metadata_inventory_put and on_metadata_inventory_take, triggering furnace timers via their standard callbacks. Updated side hopper rotation handling to allow it to function in any orientation. Added settings options to use 16-pixel or 32-pixel textures. Added settings option to allow explicit crafting of standard/side hoppers or to allow crafting of a single item that selects which type to use on place. Added in-game documentation via optional "doc" mod dependency
|
||||
- 1.4 - Added intllib support
|
||||
|
||||
Lucky Blocks: 2
|
||||
|
9
api.txt
9
api.txt
@ -14,8 +14,9 @@ Make sure any mods using this function has 'hopper' in the depends.txt file.
|
||||
hopper:add_container({ {"where_from", "node_name", "inventory_name"} })
|
||||
|
||||
'where_from' is a string telling the api that items are coming from either
|
||||
the 'top' node into a hopper, going into the 'bottom' node from a
|
||||
hopper or coming from a 'side' hopper into a container.
|
||||
the 'top' node into a hopper below, going into the 'bottom' node
|
||||
from the hopper above or coming from a 'side' hopper into the
|
||||
node next door.
|
||||
|
||||
'node_name" is the name of the container itself (e.g. "default:chest")
|
||||
|
||||
@ -24,8 +25,8 @@ hopper:add_container({ {"where_from", "node_name", "inventory_name"} })
|
||||
e.g.
|
||||
|
||||
hopper:add_container({
|
||||
{"top", "default:furnace", "dst"}, -- take cooked items from above into hopper
|
||||
{"bottom", "default:furnace", "src"}, -- insert items below to be cooked from hopper
|
||||
{"top", "default:furnace", "dst"}, -- take cooked items from above into hopper below
|
||||
{"bottom", "default:furnace", "src"}, -- insert items below to be cooked from hopper above
|
||||
{"side", "default:furnace", "fuel"}, -- replenish furnace fuel from hopper at side
|
||||
})
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
default
|
||||
lucky_block?
|
||||
doc?
|
||||
intllib?
|
||||
|
59
init.lua
59
init.lua
@ -42,6 +42,19 @@ function hopper:add_container(list)
|
||||
end
|
||||
end
|
||||
|
||||
local S
|
||||
|
||||
if minetest.get_modpath("intllib") then
|
||||
S = intllib.Getter()
|
||||
else
|
||||
S = function(s, a, ...) a = {a, ...}
|
||||
return s:gsub("@(%d+)", function(n)
|
||||
return a[tonumber(n)]
|
||||
end)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- default containers ( from position [into hopper], from node, into node inventory )
|
||||
hopper:add_container({
|
||||
{"top", "hopper:hopper", "main"},
|
||||
@ -76,7 +89,6 @@ if minetest.get_modpath("protector") then
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
-- wine mod support
|
||||
if minetest.get_modpath("wine") then
|
||||
|
||||
@ -87,7 +99,6 @@ if minetest.get_modpath("wine") then
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
-- formspec
|
||||
local function get_hopper_formspec(pos)
|
||||
|
||||
@ -144,10 +155,10 @@ end
|
||||
-- hopper
|
||||
minetest.register_node("hopper:hopper", {
|
||||
drop = "hopper:hopper",
|
||||
description = "Hopper",
|
||||
description = S("Hopper"),
|
||||
_doc_items_longdesc = hopper_long_desc,
|
||||
_doc_items_usagehelp = hopper_usage,
|
||||
groups = {cracky=3},
|
||||
groups = {cracky = 3},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
tiles = {"hopper_top_" .. texture_resolution .. ".png", "hopper_top_" .. texture_resolution .. ".png", "hopper_front_" .. texture_resolution .. ".png"},
|
||||
@ -200,21 +211,18 @@ minetest.register_node("hopper:hopper", {
|
||||
end,
|
||||
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
minetest.log("action", player:get_player_name()
|
||||
.." moves stuff in hopper at "
|
||||
..minetest.pos_to_string(pos))
|
||||
minetest.log("action", S("@1 moves stuff in hopper at @2",
|
||||
player:get_player_name(), minetest.pos_to_string(pos)))
|
||||
end,
|
||||
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()
|
||||
.." moves stuff to hopper at "
|
||||
..minetest.pos_to_string(pos))
|
||||
minetest.log("action", S("@1 moves stuff to hopper at @2",
|
||||
player:get_player_name(), minetest.pos_to_string(pos)))
|
||||
end,
|
||||
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()
|
||||
.." takes stuff from hopper at "
|
||||
..minetest.pos_to_string(pos))
|
||||
minetest.log("action", S("@1 moves stuff from hopper at @2",
|
||||
player:get_player_name(), minetest.pos_to_string(pos)))
|
||||
end,
|
||||
})
|
||||
|
||||
@ -229,7 +237,7 @@ else
|
||||
end
|
||||
|
||||
minetest.register_node("hopper:hopper_side", {
|
||||
description = "Side Hopper",
|
||||
description = S("Side Hopper"),
|
||||
_doc_items_longdesc = hopper_long_desc,
|
||||
_doc_items_usagehelp = hopper_usage,
|
||||
drop = hopper_side_drop,
|
||||
@ -291,21 +299,18 @@ minetest.register_node("hopper:hopper_side", {
|
||||
end,
|
||||
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
minetest.log("action", player:get_player_name()
|
||||
.." moves stuff in hopper at "
|
||||
..minetest.pos_to_string(pos))
|
||||
minetest.log("action", S("@1 moves stuff in hopper at @2",
|
||||
player:get_player_name(), minetest.pos_to_string(pos)))
|
||||
end,
|
||||
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()
|
||||
.." moves stuff to hopper at "
|
||||
..minetest.pos_to_string(pos))
|
||||
minetest.log("action", S("@1 moves stuff to hopper at @2",
|
||||
player:get_player_name(), minetest.pos_to_string(pos)))
|
||||
end,
|
||||
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()
|
||||
.." takes stuff from hopper at "
|
||||
..minetest.pos_to_string(pos))
|
||||
minetest.log("action", S("@1 moves stuff from hopper at @2",
|
||||
player:get_player_name(), minetest.pos_to_string(pos)))
|
||||
end,
|
||||
})
|
||||
|
||||
@ -452,12 +457,14 @@ local directions = {
|
||||
|
||||
-- hopper workings
|
||||
minetest.register_abm({
|
||||
label = "Hopper suction and transfer",
|
||||
nodenames = {"hopper:hopper", "hopper:hopper_side"},
|
||||
neighbors = neighbors,
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
catch_up = false,
|
||||
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local source_pos, destination_pos
|
||||
if node.name == "hopper:hopper_side" then
|
||||
source_pos = vector.add(pos, directions[node.param2].src)
|
||||
@ -526,7 +533,6 @@ if not single_craftable_item then
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
-- add lucky blocks
|
||||
if minetest.get_modpath("lucky_block") then
|
||||
lucky_block:add_blocks({
|
||||
@ -535,5 +541,4 @@ if minetest.get_modpath("lucky_block") then
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
print ("[MOD] Hopper loaded")
|
||||
print (S("[MOD] Hopper loaded"))
|
||||
|
11
locale/de.txt
Normal file
11
locale/de.txt
Normal file
@ -0,0 +1,11 @@
|
||||
# Template for translations of hopper mod
|
||||
# German translation by Xanthin
|
||||
# last update: 1st February 2017
|
||||
|
||||
#init.lua
|
||||
[MOD] Hopper loaded = [MOD] Trichter geladen
|
||||
Hopper = Trichter
|
||||
Side Hopper = Seitentrichter
|
||||
@1 moves stuff in hopper at @2 = @1 bewegt Dinge in einem Trichter bei @2
|
||||
@1 moves stuff to hopper at @2 = @1 verlagert Dinge in einen Trichter bei @2
|
||||
@1 moves stuff from hopper at @2 = @1 nimmt Dinge aus einem Trichter bei @2
|
10
locale/template.txt
Normal file
10
locale/template.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# Template for translations of hopper mod
|
||||
# last update: 1st February 2017
|
||||
|
||||
#init.lua
|
||||
[MOD] Hopper loaded =
|
||||
Hopper (Place onto sides for side-hopper) =
|
||||
Side Hopper (Place into crafting to return normal Hopper) =
|
||||
@1 moves stuff in hopper at @2
|
||||
@1 moves stuff to hopper at @2
|
||||
@1 moves stuff from hopper at @2
|
BIN
textures/hopper_side_inv.png
Normal file
BIN
textures/hopper_side_inv.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 233 B |
Loading…
Reference in New Issue
Block a user