summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFaceDeer <derksenmobile@gmail.com>2017-01-06 21:47:06 -0700
committerFaceDeer <derksenmobile@gmail.com>2017-01-06 21:47:06 -0700
commit1789316ec540fb30f8ab10ebe406048a78bad5bf (patch)
treeba4684631a8ebfce7d610fbf04f5506ef5411a69
parent4b5eb1b865108207c7fcd04e34e249583be1b711 (diff)
Added Pipeworks compatibility
-rw-r--r--node_storage.lua81
-rw-r--r--util.lua8
2 files changed, 86 insertions, 3 deletions
diff --git a/node_storage.lua b/node_storage.lua
index 1a9d39b..e24fa98 100644
--- a/node_storage.lua
+++ b/node_storage.lua
@@ -3,7 +3,7 @@
minetest.register_node("digtron:inventory",
{
description = "Digtron Inventory Hopper",
- groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 2},
+ groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 2, tubedevice = 1, tubedevice_receiver = 1},
drop = "digtron:inventory",
sounds = digtron.metal_sounds,
paramtype2= "facedir",
@@ -34,6 +34,27 @@ minetest.register_node("digtron:inventory",
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
+
+ -- Pipeworks compatibility
+ ----------------------------------------------------------------
+
+ tube = (function() if minetest.get_modpath("pipeworks") then return {
+ insert_object = function(pos, node, stack, direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ return inv:add_item("main", stack)
+ end,
+ can_insert = function(pos, node, stack, direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ return inv:room_for_item("main", stack)
+ end,
+ input_inventory = "main",
+ connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
+ } end end)(),
+
+ after_place_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_place end end)(),
+ after_dig_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_dig end end)()
})
-- Fuel storage. Controller node draws fuel from here.
@@ -41,7 +62,7 @@ minetest.register_node("digtron:inventory",
minetest.register_node("digtron:fuelstore",
{
description = "Digtron Fuel Hopper",
- groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 5},
+ groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 5, tubedevice = 1, tubedevice_receiver = 1},
drop = "digtron:fuelstore",
sounds = digtron.metal_sounds,
paramtype2= "facedir",
@@ -87,13 +108,40 @@ minetest.register_node("digtron:fuelstore",
local inv = meta:get_inventory()
return inv:is_empty("fuel")
end,
+
+ -- Pipeworks compatibility
+ ----------------------------------------------------------------
+
+ tube = (function() if minetest.get_modpath("pipeworks") then return {
+ insert_object = function(pos, node, stack, direction)
+ if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ return inv:add_item("fuel", stack)
+ end
+ return stack
+ end,
+ can_insert = function(pos, node, stack, direction)
+ if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ return inv:room_for_item("fuel", stack)
+ end
+ return false
+ end,
+ input_inventory = "fuel",
+ connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
+ } end end)(),
+
+ after_place_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_place end end)(),
+ after_dig_node = (function() if minetest.get_modpath("pipeworks")then return pipeworks.after_dig end end)()
})
-- Combined storage. Group 6 has both an inventory and a fuel store
minetest.register_node("digtron:combined_storage",
{
description = "Digtron Combined Storage",
- groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 6},
+ groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 6, tubedevice = 1, tubedevice_receiver = 1},
drop = "digtron:combined_storage",
sounds = digtron.metal_sounds,
paramtype2= "facedir",
@@ -156,4 +204,31 @@ minetest.register_node("digtron:combined_storage",
local inv = meta:get_inventory()
return inv:is_empty("fuel") and inv:is_empty("main")
end,
+
+ -- Pipeworks compatibility
+ ----------------------------------------------------------------
+ tube = (function() if minetest.get_modpath("pipeworks") then return {
+ insert_object = function(pos, node, stack, direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 and direction.y == 1 then
+ return inv:add_item("fuel", stack)
+ end
+ return inv:add_item("main", stack)
+ end,
+ can_insert = function(pos, node, stack, direction)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 and direction.y == 1 then
+ return inv:room_for_item("fuel", stack)
+ end
+ return inv:room_for_item("main", stack)
+ end,
+ input_inventory = "main",
+ connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
+ } end end)(),
+
+ after_place_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_place end end)(),
+ after_dig_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_dig end end)()
+
})
diff --git a/util.lua b/util.lua
index 6709614..df2adf7 100644
--- a/util.lua
+++ b/util.lua
@@ -98,9 +98,13 @@ end
digtron.move_node = function(pos, newpos, player_name)
-- Moves nodes, preserving digtron metadata and inventory
local node = minetest.get_node(pos)
+ local node_def = minetest.registered_nodes[node.name]
local oldnode = minetest.get_node(newpos)
minetest.log("action", string.format("%s moves %s from (%d, %d, %d) to (%d, %d, %d), displacing %s", player_name, node.name, pos.x, pos.y, pos.z, newpos.x, newpos.y, newpos.z, oldnode.name))
minetest.add_node(newpos, { name=node.name, param1=node.param1, param2=node.param2 })
+ if node_def.after_place_node then
+ node_def.after_place_node(newpos)
+ end
local oldmeta = minetest.get_meta(pos)
local oldinv = oldmeta:get_inventory()
@@ -122,12 +126,16 @@ digtron.move_node = function(pos, newpos, player_name)
newmeta:set_float("fuel_burning", oldmeta:get_float("fuel_burning"))
newmeta:set_string("infotext", oldmeta:get_string("infotext"))
+ -- Move the little floaty entity inside the builders
if minetest.get_item_group(node.name, "digtron") == 4 then
digtron.update_builder_item(newpos)
end
-- remove node from old position
minetest.remove_node(pos)
+ if node_def.after_dig_node then
+ node_def.after_dig_node(pos)
+ end
end
digtron.get_all_digtron_neighbours = function(pos, player)