Just deleted about 400 bot accounts and a bunch of spam. To mitigate this in the future, we've enabled reCaptcha on signup. Let me know if someone got caught in the crossfire.

Commit 21031b6b authored by Rob Nelson's avatar Rob Nelson
Browse files

Quick and dirty fixes for Item Collectors.

parent 55e4aa20
local radius = 25
local chestInventoryIndex = defines.inventory.chest
function ticker()
if global.itemCollectors ~= nil then
if global.ticks == 0 or global.ticks == nil then
global.ticks = 59
processCollectors()
else
global.ticks = global.ticks - 1
end
else
script.on_event(defines.events.on_tick, nil)
end
end
script.on_load(function()
if global.itemCollectors ~= nil then
script.on_event(defines.events.on_tick, ticker)
end
end)
function builtEntity(event)
local newCollector
if event.created_entity.name == "item-collector-area" then
local surface = event.created_entity.surface
local force = event.created_entity.force
newCollector = surface.create_entity({name = "item-collector", position = event.created_entity.position, force = force})
event.created_entity.destroy()
if global.itemCollectors == nil then
global.itemCollectors = {}
script.on_event(defines.events.on_tick, ticker)
end
table.insert(global.itemCollectors, newCollector)
end
end
script.on_event(defines.events.on_built_entity, builtEntity)
script.on_event(defines.events.on_robot_built_entity, builtEntity)
function processCollectors()
local items
local inventory
local belt
for k,collector in pairs(global.itemCollectors) do
if collector.valid then
items = collector.surface.find_entities_filtered({area = {{x = collector.position.x - radius, y = collector.position.y - radius}, {x = collector.position.x + radius, y = collector.position.y + radius}}, name = "item-on-ground"})
if #items > 0 then
inventory = collector.get_inventory(chestInventoryIndex)
for _,item in pairs(items) do
local stack = item.stack
if inventory.can_insert(stack) then
inventory.insert(stack)
item.destroy()
break
end
end
end
else
table.remove(global.itemCollectors, k)
if #global.itemCollectors == 0 then
global.itemCollectors = nil
end
end
end
end
\ No newline at end of file
require("prototypes.entities")
require("prototypes.items")
require("prototypes.recipes")
{
"name": "Item Collectors",
"version": "1.1.9",
"title": "Item Collectors",
"author": "Rseding91, N3X15",
"homepage": "",
"dependencies": ["base >= 0.15"],
"description": "A chest that picks up items on the ground.",
"factorio_version": "0.15"
}
[item-description]
item-collector-area = Collects items in a 50x50 area around the chest.
item-collector = Collects items in a 50x50 area around the chest.
[item-name]
item-collector-area = Item Collector
item-collector = Item Collector
[entity-name]
item-collector-area = Item Collector
item-collector = Item Collector
[entity-description]
item-collector-area = Collects items in a 50x50 area around the chest.
item-collector = Collects items in a 50x50 area around the chest.
[recipe-name]
item-collector-area = Item Collector
[recipe-description]
item-collector-area = Collects items in a 50x50 area around the chest.
data:extend(
{
{
type = "container",
name = "item-collector",
icon = "__base__/graphics/icons/steel-chest.png",
flags = {"placeable-neutral", "player-creation"},
open_sound = { filename = "__base__/sound/metallic-chest-open.ogg", volume=0.65 },
close_sound = { filename = "__base__/sound/metallic-chest-close.ogg", volume = 0.7 },
minable = {mining_time = 0.5, result = "item-collector-area"},
max_health = 150,
corpse = "small-remnants",
resistances =
{
{
type = "fire",
percent = 70
}
},
collision_box = {{-0.35, -0.35}, {0.35, 0.35}},
selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
order = "i[items]-i[item-collector]",
subgroup = "storage",
fast_replaceable_group = "container",
inventory_size = 48,
picture =
{
filename = "__Item Collectors__/graphics/smart-chest.png",
priority = "extra-high",
width = 62,
height = 41,
shift = {0.4, -0.13}
}
},
{
type = "container",
name = "item-collector-area",
icon = "__base__/graphics/icons/steel-chest.png",
flags = {"placeable-neutral", "player-creation"},
open_sound = { filename = "__base__/sound/metallic-chest-open.ogg", volume=0.65 },
close_sound = { filename = "__base__/sound/metallic-chest-close.ogg", volume = 0.7 },
minable = {mining_time = 0.5, result = "item-collector-area"},
max_health = 150,
corpse = "small-remnants",
resistances =
{
{
type = "fire",
percent = 70
}
},
collision_box = {{-0.35, -0.35}, {0.35, 0.35}},
selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
order = "i[items]-i[item-collector]",
subgroup = "storage",
fast_replaceable_group = "container",
inventory_size = 48,
picture =
{
filename = "__Item Collectors__/graphics/smart-chest-area.png",
priority = "extra-high",
width = 1600,
height = 1600,
shift = {0.4, -0.13}
}
}
}
)
data:extend(
{
{
type = "item",
name = "item-collector-area",
icon = "__base__/graphics/icons/steel-chest.png",
flags = {"goes-to-quickbar"},
subgroup = "storage",
order = "i[item-collector]",
place_result = "item-collector-area",
stack_size = 50
}
}
)
data:extend(
{
{
type = "recipe",
name = "item-collector",
enabled = "true",
ingredients =
{
{"steel-chest", 1},
{"processing-unit", 20},
{"solar-panel", 1},
{"battery", 5}
},
result = "item-collector-area"
}
}
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment