funnel renamed to hopper
This commit is contained in:
parent
096b85ee1c
commit
3bf372164b
@ -131,6 +131,12 @@ function techage.side_to_indir(side, param2)
|
|||||||
return tubelib2.Turn180Deg[side_to_dir(side, param2)]
|
return tubelib2.Turn180Deg[side_to_dir(side, param2)]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function get_next_node(pos, out_dir)
|
||||||
|
local res, npos, node = Tube:compatible_node(pos, out_dir)
|
||||||
|
local in_dir = tubelib2.Turn180Deg[out_dir]
|
||||||
|
return res, npos, in_dir, Name2Name[node.name] or node.name
|
||||||
|
end
|
||||||
|
|
||||||
local function get_dest_node(pos, out_dir)
|
local function get_dest_node(pos, out_dir)
|
||||||
local spos, in_dir = Tube:get_connected_node_pos(pos, out_dir)
|
local spos, in_dir = Tube:get_connected_node_pos(pos, out_dir)
|
||||||
local _,node = Tube:get_node(spos)
|
local _,node = Tube:get_node(spos)
|
||||||
@ -320,17 +326,14 @@ end
|
|||||||
|
|
||||||
function techage.pull_items(pos, out_dir, num)
|
function techage.pull_items(pos, out_dir, num)
|
||||||
local npos, in_dir, name = get_dest_node(pos, out_dir)
|
local npos, in_dir, name = get_dest_node(pos, out_dir)
|
||||||
if npos == nil then return end
|
if npos and NodeDef[name] and NodeDef[name].on_pull_item then
|
||||||
if NodeDef[name] and NodeDef[name].on_pull_item then
|
|
||||||
return NodeDef[name].on_pull_item(npos, in_dir, num)
|
return NodeDef[name].on_pull_item(npos, in_dir, num)
|
||||||
end
|
end
|
||||||
return nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function techage.push_items(pos, out_dir, stack)
|
function techage.push_items(pos, out_dir, stack)
|
||||||
local npos, in_dir, name = get_dest_node(pos, out_dir)
|
local npos, in_dir, name = get_dest_node(pos, out_dir)
|
||||||
if npos == nil then return end
|
if npos and NodeDef[name] and NodeDef[name].on_push_item then
|
||||||
if NodeDef[name] and NodeDef[name].on_push_item then
|
|
||||||
return NodeDef[name].on_push_item(npos, in_dir, stack)
|
return NodeDef[name].on_push_item(npos, in_dir, stack)
|
||||||
elseif name == "air" then
|
elseif name == "air" then
|
||||||
minetest.add_item(npos, stack)
|
minetest.add_item(npos, stack)
|
||||||
@ -341,13 +344,42 @@ end
|
|||||||
|
|
||||||
function techage.unpull_items(pos, out_dir, stack)
|
function techage.unpull_items(pos, out_dir, stack)
|
||||||
local npos, in_dir, name = get_dest_node(pos, out_dir)
|
local npos, in_dir, name = get_dest_node(pos, out_dir)
|
||||||
if npos == nil then return end
|
if npos and NodeDef[name] and NodeDef[name].on_unpull_item then
|
||||||
if NodeDef[name] and NodeDef[name].on_unpull_item then
|
|
||||||
return NodeDef[name].on_unpull_item(npos, in_dir, stack)
|
return NodeDef[name].on_unpull_item(npos, in_dir, stack)
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
-- Client side Push/Pull item functions for funnel like nodes
|
||||||
|
-- (nodes with no tube support)
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
|
||||||
|
function techage.neighbour_pull_items(pos, out_dir, num)
|
||||||
|
local res, npos, in_dir, name = get_next_node(pos, out_dir)
|
||||||
|
if res and NodeDef[name] and NodeDef[name].on_pull_item then
|
||||||
|
return NodeDef[name].on_pull_item(npos, in_dir, num)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function techage.neighbour_push_items(pos, out_dir, stack)
|
||||||
|
local res, npos, in_dir, name = get_next_node(pos, out_dir)
|
||||||
|
if res and NodeDef[name] and NodeDef[name].on_push_item then
|
||||||
|
return NodeDef[name].on_push_item(npos, in_dir, stack)
|
||||||
|
elseif name == "air" then
|
||||||
|
minetest.add_item(npos, stack)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function techage.neighbour_unpull_items(pos, out_dir, stack)
|
||||||
|
local res, npos, in_dir, name = get_next_node(pos, out_dir)
|
||||||
|
if res and NodeDef[name] and NodeDef[name].on_unpull_item then
|
||||||
|
return NodeDef[name].on_unpull_item(npos, in_dir, stack)
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
-- Server side helper functions
|
-- Server side helper functions
|
||||||
|
2
init.lua
2
init.lua
@ -45,7 +45,7 @@ else
|
|||||||
-- Iron Age
|
-- Iron Age
|
||||||
dofile(MP.."/iron_age/main.lua")
|
dofile(MP.."/iron_age/main.lua")
|
||||||
dofile(MP.."/iron_age/gravelsieve.lua")
|
dofile(MP.."/iron_age/gravelsieve.lua")
|
||||||
dofile(MP.."/iron_age/funnel.lua")
|
dofile(MP.."/iron_age/hopper.lua")
|
||||||
dofile(MP.."/iron_age/hammer.lua")
|
dofile(MP.."/iron_age/hammer.lua")
|
||||||
dofile(MP.."/iron_age/lighter.lua")
|
dofile(MP.."/iron_age/lighter.lua")
|
||||||
dofile(MP.."/iron_age/charcoalpile.lua")
|
dofile(MP.."/iron_age/charcoalpile.lua")
|
||||||
|
@ -141,6 +141,7 @@ end
|
|||||||
|
|
||||||
techage.register_node("techage:sieve0", {"techage:sieve1", "techage:sieve2", "techage:sieve3"}, {
|
techage.register_node("techage:sieve0", {"techage:sieve1", "techage:sieve2", "techage:sieve3"}, {
|
||||||
on_push_item = function(pos, in_dir, stack)
|
on_push_item = function(pos, in_dir, stack)
|
||||||
|
print("on_push_item")
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
if inv:room_for_item("src", stack) then
|
if inv:room_for_item("src", stack) then
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
LGPLv2.1+
|
LGPLv2.1+
|
||||||
See LICENSE.txt for more information
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
Simple TA1 Funnel
|
Simple TA1 Hopper
|
||||||
|
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
@ -36,36 +36,53 @@ local function scan_for_objects(pos, inv)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function pull_push_item(pos, meta)
|
||||||
|
local items = techage.neighbour_pull_items(pos, 6, 1)
|
||||||
|
if items then
|
||||||
|
if techage.neighbour_push_items(pos, meta:get_int("push_dir"), items) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
-- place item back
|
||||||
|
techage.neighbour_unpull_items(pos, 6, items)
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local function push_item(pos, inv, meta)
|
local function push_item(pos, inv, meta)
|
||||||
if not inv:is_empty("main") then
|
if not inv:is_empty("main") then
|
||||||
local stack = inv:get_stack("main", 1)
|
local stack = inv:get_stack("main", 1)
|
||||||
local taken = stack:take_item(1)
|
local taken = stack:take_item(1)
|
||||||
if techage.push_items(pos, meta:get_int("push_dir"), taken) then
|
print("neighbour_push_items")
|
||||||
|
if techage.neighbour_push_items(pos, meta:get_int("push_dir"), taken) then
|
||||||
inv:set_stack("main", 1, stack)
|
inv:set_stack("main", 1, stack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function node_timer(pos, elapsed)
|
local function node_timer(pos, elapsed)
|
||||||
|
print("node_timer")
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
if inv then
|
if inv then
|
||||||
|
if not pull_push_item(pos, meta) then
|
||||||
scan_for_objects(pos, inv)
|
scan_for_objects(pos, inv)
|
||||||
push_item(pos, inv, meta)
|
push_item(pos, inv, meta)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("techage:funnel_ta1", {
|
minetest.register_node("techage:hopper_ta1", {
|
||||||
description = I("TA1 Funnel"),
|
description = I("TA1 Hopper"),
|
||||||
tiles = {
|
tiles = {
|
||||||
-- up, down, right, left, back, front
|
-- up, down, right, left, back, front
|
||||||
"default_cobble.png^techage_appl_funnel_top.png",
|
"default_cobble.png^techage_appl_hopper_top.png",
|
||||||
"default_cobble.png^techage_appl_funnel.png",
|
"default_cobble.png^techage_appl_hopper.png",
|
||||||
"default_cobble.png^techage_appl_funnel_right.png",
|
"default_cobble.png^techage_appl_hopper_right.png",
|
||||||
"default_cobble.png^techage_appl_funnel.png",
|
"default_cobble.png^techage_appl_hopper.png",
|
||||||
"default_cobble.png^techage_appl_funnel.png",
|
"default_cobble.png^techage_appl_hopper.png",
|
||||||
"default_cobble.png^techage_appl_funnel.png",
|
"default_cobble.png^techage_appl_hopper.png",
|
||||||
},
|
},
|
||||||
|
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
@ -97,7 +114,7 @@ minetest.register_node("techage:funnel_ta1", {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
techage.add_node(pos, "techage:funnel_ta1")
|
techage.add_node(pos, "techage:hopper_ta1")
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
M(pos):set_int("push_dir", techage.side_to_indir("L", node.param2))
|
M(pos):set_int("push_dir", techage.side_to_indir("L", node.param2))
|
||||||
minetest.get_node_timer(pos):start(2)
|
minetest.get_node_timer(pos):start(2)
|
||||||
@ -120,7 +137,7 @@ minetest.register_node("techage:funnel_ta1", {
|
|||||||
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "techage:funnel_ta1",
|
output = "techage:hopper_ta1",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"default:stone", "", "default:stone"},
|
{"default:stone", "", "default:stone"},
|
||||||
{"default:stone", "default:gold_ingot", "default:stone"},
|
{"default:stone", "default:gold_ingot", "default:stone"},
|
||||||
@ -128,7 +145,7 @@ minetest.register_craft({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
techage.register_node("techage:funnel_ta1", {}, {
|
techage.register_node("techage:hopper_ta1", {}, {
|
||||||
on_pull_item = nil, -- not needed
|
on_pull_item = nil, -- not needed
|
||||||
on_unpull_item = nil, -- not needed
|
on_unpull_item = nil, -- not needed
|
||||||
|
|
||||||
@ -139,7 +156,9 @@ techage.register_node("techage:funnel_ta1", {}, {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
techage.register_help_page("TA1 Funnel", [[The Funnel collects dropped items
|
techage.register_help_page("TA1 Hopper", [[The Hopper collects dropped items
|
||||||
and pushes them to the right side.
|
and pushes them to the right side.
|
||||||
Items are sucked up when they
|
Items are sucked up when they
|
||||||
are dropped on top of the funnel block.]], "techage:funnel_ta1")
|
are dropped on top of the Hopper block.
|
||||||
|
But the Hopper can also pull items out of
|
||||||
|
chests or furnace blocks, if it is placed below.]], "techage:hopper_ta1")
|
@ -120,7 +120,7 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
techage.register_recipe({
|
techage.ironage_register_recipe({
|
||||||
output = "techage:meridium_ingot",
|
output = "techage:meridium_ingot",
|
||||||
recipe = {"default:steel_ingot", "default:mese_crystal_fragment"},
|
recipe = {"default:steel_ingot", "default:mese_crystal_fragment"},
|
||||||
heat = 4,
|
heat = 4,
|
||||||
|
Before Width: | Height: | Size: 159 B After Width: | Height: | Size: 159 B |
Before Width: | Height: | Size: 169 B After Width: | Height: | Size: 169 B |
Before Width: | Height: | Size: 273 B After Width: | Height: | Size: 273 B |
Loading…
Reference in New Issue
Block a user