1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-09-28 23:40:34 +02:00

[pipeworks] Update and fix for #426

This commit is contained in:
LeMagnesium 2016-04-06 17:50:08 +02:00
parent f25082ad5f
commit edaa902d3f
9 changed files with 27 additions and 20 deletions

View File

@ -223,7 +223,7 @@ local function upgrade_autocrafter(pos, meta)
if not recipe then return end
for idx, stack in ipairs(recipe) do
if not stack:is_empty() then
minetest.item_drop(stack, "", pos)
minetest.add_item(pos, stack)
stack:set_count(1)
stack:set_wear(0)
inv:set_stack("recipe", idx, stack)

View File

@ -15,6 +15,10 @@ minetest.override_item("default:furnace", {
insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local timer = minetest.get_node_timer(pos)
if not timer:is_started() then
timer:start(1.0)
end
if direction.y == 1 then
return inv:add_item("fuel",stack)
else
@ -60,6 +64,10 @@ minetest.override_item("default:furnace_active", {
insert_object = function(pos,node,stack,direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local timer = minetest.get_node_timer(pos)
if not timer:is_started() then
timer:start(1.0)
end
if direction.y == 1 then
return inv:add_item("fuel", stack)
else

View File

@ -0,0 +1 @@
This mod uses nodeboxes to supply a complete set of 3D pipes and tubes, along devices that work with them.

View File

@ -28,7 +28,7 @@ end
-- todo SOON: this function has *way too many* parameters
local function grabAndFire(data,slotseq_mode,filtmeta,frominv,frominvname,frompos,fromnode,filterfor,fromtube,fromdef,dir,fakePlayer,all)
local sposes = {}
for spos,stack in ipairs(frominv:get_list(frominvname)) do
for spos,stack in ipairs(frominv:get_list(frominvname) or {}) do -- Modification made for https://github.com/MinetestForFun/server-minetestforfun/issues/426 (Mg|06/04/2016)
local matches
if filterfor == "" then
matches = stack:get_name() ~= ""

View File

@ -249,7 +249,10 @@ luaentity.register_entity("pipeworks:tubed_item", {
if not found_next then
drop_pos = minetest.find_node_near(vector.add(self.start_pos, velocity), 1, "air")
if drop_pos then
minetest.item_drop(stack, "", drop_pos)
-- Using add_item instead of item_drop since this makes pipeworks backward
-- compatible with Minetest 0.4.13.
-- Using item_drop here makes Minetest 0.4.13 crash.
minetest.add_item(drop_pos, stack)
self:remove()
return
end

1
mods/pipeworks/mod.conf Normal file
View File

@ -0,0 +1 @@
name = pipeworks

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

View File

@ -6,7 +6,7 @@ if pipeworks.enable_mese_tube then
local inv = meta:get_inventory()
for i = 1, 6 do
for _, stack in ipairs(inv:get_list("line"..i)) do
minetest.item_drop(stack, "", pos)
minetest.add_item(pos, stack)
end
end
end

View File

@ -87,27 +87,21 @@ local tube_inject_item = pipeworks.tube_inject_item
local get_objects_inside_radius = minetest.get_objects_inside_radius
local function vacuum(pos, radius)
radius = radius + 0.5
local max_items = 0
for _, object in pairs(get_objects_inside_radius(pos, sqrt_3 * radius)) do
local lua_entity = object:get_luaentity()
if not object:is_player() and lua_entity and lua_entity.name == "__builtin:item" then
max_items = max_items + 1
if max_items > 50 then
object:remove()
else
local obj_pos = object:getpos()
local x1, y1, z1 = pos.x, pos.y, pos.z
local x2, y2, z2 = obj_pos.x, obj_pos.y, obj_pos.z
local obj_pos = object:getpos()
local x1, y1, z1 = pos.x, pos.y, pos.z
local x2, y2, z2 = obj_pos.x, obj_pos.y, obj_pos.z
if x1 - radius <= x2 and x2 <= x1 + radius
and y1 - radius <= y2 and y2 <= y1 + radius
and z1 - radius <= z2 and z2 <= z1 + radius then
if lua_entity.itemstring ~= "" then
tube_inject_item(pos, pos, vector.new(0, 0, 0), lua_entity.itemstring)
lua_entity.itemstring = ""
end
object:remove()
if x1 - radius <= x2 and x2 <= x1 + radius
and y1 - radius <= y2 and y2 <= y1 + radius
and z1 - radius <= z2 and z2 <= z1 + radius then
if lua_entity.itemstring ~= "" then
tube_inject_item(pos, pos, vector.new(0, 0, 0), lua_entity.itemstring)
lua_entity.itemstring = ""
end
object:remove()
end
end
end