Here is an example from something I started the same day you posted your mod :) This will mark all items-on-ground for deconstruction in the construction zone of the player's roboport, with available robots
local function are_bots_ready(character)
return (character.logistic_cell and character.logistic_cell.mobile
and character.logistic_cell.stationed_construction_robot_count > 0) or false
end
local function get_build_area(pos, rad)
return {top_left={x=pos.x-rad, y=pos.y-rad}, bottom_right={x=pos.x+rad, y=pos.y+rad}}
end
local function gobble_items_on_ground(player)
local rad = player.character.logistic_cell.construction_radius
local area = get_build_area(player.position, rad)
if not player.surface.find_nearest_enemy{position=player.position ,max_distance=rad+20,force=player.force} then
for _, item in pairs(player.surface.find_entities_filtered{area=area, name="item-on-ground"}) do
if not item.to_be_deconstructed(player.force) then
item.order_deconstruction(player.force)
end
end
end
end
The on tick handler is every 2.5 seconds loop through players and executes
if are_bots_ready(player.character) then
gobble_items_on_ground(player)
end