Update all code styles

This commit is contained in:
Cooldude2606
2024-09-28 01:56:54 +01:00
parent 5e2a62ab27
commit 292c1a1b68
194 changed files with 9817 additions and 9703 deletions

View File

@@ -12,9 +12,8 @@ miner_data.queue = {}
local function drop_target(entity)
if entity.drop_target then
return entity.drop_target
else
local entities = entity.surface.find_entities_filtered{position=entity.drop_position}
local entities = entity.surface.find_entities_filtered{ position = entity.drop_position }
if #entities > 0 then
return entities[1]
@@ -43,7 +42,7 @@ local function check_entity(entity)
return true
end
if entity.has_flag('not-deconstructable') then
if entity.has_flag("not-deconstructable") then
-- if it can deconstruct
return true
end
@@ -58,13 +57,13 @@ local function chest_check(entity)
return
end
if target.type ~= 'logistic-container' and target.type ~= 'container' then
if target.type ~= "logistic-container" and target.type ~= "container" then
-- not a chest
return
end
local radius = 2
local entities = target.surface.find_entities_filtered{area={{target.position.x - radius, target.position.y - radius}, {target.position.x + radius, target.position.y + radius}}, type={'mining-drill', 'inserter'}}
local entities = target.surface.find_entities_filtered{ area = { { target.position.x - radius, target.position.y - radius }, { target.position.x + radius, target.position.y + radius } }, type = { "mining-drill", "inserter" } }
for _, e in pairs(entities) do
if drop_target(e) == target then
@@ -75,7 +74,7 @@ local function chest_check(entity)
end
if check_entity(target) then
table.insert(miner_data.queue, {t=game.tick + 10, e=target})
table.insert(miner_data.queue, { t = game.tick + 10, e = target })
end
end
@@ -85,7 +84,7 @@ local function miner_check(entity)
local ef = entity.force
local er = entity.prototype.mining_drill_radius
for _, r in pairs(entity.surface.find_entities_filtered{area={{x=ep.x - er, y=ep.y - er}, {x=ep.x + er, y=ep.y + er}}, type='resource'}) do
for _, r in pairs(entity.surface.find_entities_filtered{ area = { { x = ep.x - er, y = ep.y - er }, { x = ep.x + er, y = ep.y + er } }, type = "resource" }) do
if r.amount > 0 then
return
end
@@ -103,35 +102,32 @@ local function miner_check(entity)
if config.fluid and entity.fluidbox and #entity.fluidbox > 0 then
-- if require fluid to mine
table.insert(pipe_build, {x=0, y=0})
table.insert(pipe_build, { x = 0, y = 0 })
local half = math.floor(entity.get_radius())
local r = 1 + er
local entities = es.find_entities_filtered{area={{ep.x - r, ep.y - r}, {ep.x + r, ep.y + r}}, type={'mining-drill', 'pipe', 'pipe-to-ground'}}
local entities_t = es.find_entities_filtered{area={{ep.x - r, ep.y - r}, {ep.x + r, ep.y + r}}, ghost_type={'pipe', 'pipe-to-ground'}}
local entities = es.find_entities_filtered{ area = { { ep.x - r, ep.y - r }, { ep.x + r, ep.y + r } }, type = { "mining-drill", "pipe", "pipe-to-ground" } }
local entities_t = es.find_entities_filtered{ area = { { ep.x - r, ep.y - r }, { ep.x + r, ep.y + r } }, ghost_type = { "pipe", "pipe-to-ground" } }
table.array_insert(entities, entities_t)
for _, e in pairs(entities) do
if (e.position.x > ep.x) and (e.position.y == ep.y) then
for h=1, half do
table.insert(pipe_build, {x=h, y=0})
for h = 1, half do
table.insert(pipe_build, { x = h, y = 0 })
end
elseif (e.position.x < ep.x) and (e.position.y == ep.y) then
for h=1, half do
table.insert(pipe_build, {x=-h, y=0})
for h = 1, half do
table.insert(pipe_build, { x = -h, y = 0 })
end
elseif (e.position.x == ep.x) and (e.position.y > ep.y) then
for h=1, half do
table.insert(pipe_build, {x=0, y=h})
for h = 1, half do
table.insert(pipe_build, { x = 0, y = h })
end
elseif (e.position.x == ep.x) and (e.position.y < ep.y) then
for h=1, half do
table.insert(pipe_build, {x=0, y=-h})
for h = 1, half do
table.insert(pipe_build, { x = 0, y = -h })
end
end
end
@@ -141,10 +137,10 @@ local function miner_check(entity)
chest_check(entity)
end
table.insert(miner_data.queue, {t=game.tick + 5, e=entity})
table.insert(miner_data.queue, { t = game.tick + 5, e = entity })
for _, pos in ipairs(pipe_build) do
es.create_entity{name='entity-ghost', position={x=ep.x + pos.x, y=ep.y + pos.y}, force=ef, inner_name='pipe', raise_built=true}
es.create_entity{ name = "entity-ghost", position = { x = ep.x + pos.x, y = ep.y + pos.y }, force = ef, inner_name = "pipe", raise_built = true }
end
end
@@ -153,7 +149,7 @@ Event.add(defines.events.on_resource_depleted, function(event)
return
end
local entities = event.entity.surface.find_entities_filtered{area={{event.entity.position.x - 1, event.entity.position.y - 1}, {event.entity.position.x + 1, event.entity.position.y + 1}}, type='mining-drill'}
local entities = event.entity.surface.find_entities_filtered{ area = { { event.entity.position.x - 1, event.entity.position.y - 1 }, { event.entity.position.x + 1, event.entity.position.y + 1 } }, type = "mining-drill" }
if #entities == 0 then
return
@@ -171,7 +167,6 @@ Event.on_nth_tick(10, function(event)
if not q.e or not q.e.valid then
table.remove(miner_data.queue, k)
break
elseif event.tick >= q.t then
q.e.order_deconstruction(q.e.force)
table.remove(miner_data.queue, k)