Repair Turret

by Klonan

Adds Repair Turrets

Content
11 months ago
0.17 - 2.0
131K
Combat Logistic network

g The turret does not work with high-quality repair kits

11 months ago

Hi! Thanks for the lovely mod!
Can i ask if I'm doing something wrong, but my turrets only work with regular repair kits. They don't work with high-quality ones.

7 months ago

I've seen it sometimes using them. I thought it never used them but then I caught it using them so I'm not sure what's up.

25 days ago

I fixed this bug in the mod. If anyone's interested, I replaced the functions(get_repair_pickup_point, get_repair_stack_and_entity) in the repair_turret.lua file.

(OLD)
RepairTurret.get_repair_pickup_point = function(self)
local select_pickup_point = self.entity.logistic_network.select_pickup_point
for name, item in pairs(get_repair_items()) do
local pickup_point = select_pickup_point {name = name, position = self.position, include_buffers = true}
if pickup_point then
return pickup_point.owner, name
end
end
end

(NEW)
RepairTurret.get_repair_pickup_point = function(self)
local select_pickup_point = self.entity.logistic_network.select_pickup_point
for name, item in pairs(get_repair_items()) do
local pickup_point = select_pickup_point {name = name, position = self.position, include_buffers = true}
if pickup_point then
return pickup_point.owner, name
end
local pickup_point1 = select_pickup_point {name = {name = name, quality = "uncommon"}, position = self.position, include_buffers = true}
if pickup_point1 then
return pickup_point1.owner, name
end
local pickup_point2 = select_pickup_point {name = {name = name, quality = "rare"}, position = self.position, include_buffers = true}
if pickup_point2 then
return pickup_point2.owner, name
end
local pickup_point3 = select_pickup_point {name = {name = name, quality = "epic"}, position = self.position, include_buffers = true}
if pickup_point3 then
return pickup_point3.owner, name
end
local pickup_point4 = select_pickup_point {name = {name = name, quality = "legendary"}, position = self.position, include_buffers = true}
if pickup_point4 then
return pickup_point4.owner, name
end
end

end

(OLD)
RepairTurret.get_repair_stack_and_entity = function(self)

local inventory = self.inventory
if not inventory.is_empty() then
return self.entity, inventory[1]
end

local owner, repair_item = self:get_repair_pickup_point()
if not owner then return end

local owner_inventory = get_owner_inventory(owner)

local stack = owner_inventory and owner_inventory.find_item_stack(repair_item)

if not (stack and stack.valid and stack.valid_for_read) then return end

return owner, stack

end

(NEW)
RepairTurret.get_repair_stack_and_entity = function(self)

local inventory = self.inventory
if not inventory.is_empty() then
return self.entity, inventory[1]
end

local owner, repair_item = self:get_repair_pickup_point()

if not owner then
return
end

local owner_inventory = get_owner_inventory(owner)

local stack = owner_inventory and owner_inventory.find_item_stack(repair_item)
if (stack and stack.valid and stack.valid_for_read) then
return owner, stack
end

local stack1 = owner_inventory and owner_inventory.find_item_stack({name = repair_item, quality = "uncommon"})
if (stack1 and stack1.valid and stack1.valid_for_read) then
return owner, stack1
end

local stack2 = owner_inventory and owner_inventory.find_item_stack({name = repair_item, quality = "rare"})
if (stack2 and stack2.valid and stack2.valid_for_read) then
return owner, stack2
end

local stack3 = owner_inventory and owner_inventory.find_item_stack({name = repair_item, quality = "epic"})
if (stack3 and stack3.valid and stack3.valid_for_read) then
return owner, stack3
end

local stack4 = owner_inventory and owner_inventory.find_item_stack({name = repair_item, quality = "legendary"})
if (stack4 and stack4.valid and stack4.valid_for_read) then
return owner, stack4
end

end

New response