mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-29 04:06:39 +09:00
Fixed Existing Lua Check Errors
This commit is contained in:
@@ -10,7 +10,7 @@ local entities = config.entities
|
||||
local belts = config.afk_belts.locations
|
||||
local turrets = config.infinite_ammo_turrets.locations
|
||||
|
||||
Global.register(turrets,function(tbl)
|
||||
Global.register(turrets, function(tbl)
|
||||
turrets = tbl
|
||||
end)
|
||||
|
||||
@@ -19,13 +19,13 @@ local function get_spawn_force()
|
||||
local force = game.forces['Spawn']
|
||||
if force and force.valid then return force end
|
||||
force = game.create_force('Spawn')
|
||||
force.set_cease_fire('player',true)
|
||||
game.forces['player'].set_cease_fire('Spawn',true)
|
||||
force.set_cease_fire('player', true)
|
||||
game.forces['player'].set_cease_fire('Spawn', true)
|
||||
return force
|
||||
end
|
||||
|
||||
-- protects and entity so players cant do anything to it
|
||||
local function protect_entity(entity,set_force)
|
||||
local function protect_entity(entity, set_force)
|
||||
if entity and entity.valid then
|
||||
entity.destructible = false
|
||||
entity.minable = false
|
||||
@@ -39,40 +39,40 @@ end
|
||||
-- handles the infinite ammo turrets
|
||||
local function spawn_turrets()
|
||||
if config.infinite_ammo_turrets.enabled then
|
||||
for _,turret_pos in pairs(turrets) do
|
||||
for _, turret_pos in pairs(turrets) do
|
||||
local surface = game.surfaces[turret_pos.surface]
|
||||
local pos = turret_pos.position
|
||||
local turret = surface.find_entity('gun-turret',pos)
|
||||
local turret = surface.find_entity('gun-turret', pos)
|
||||
-- Makes a new turret if it is not found
|
||||
if not turret or not turret.valid then
|
||||
turret = surface.create_entity{name='gun-turret',position=pos,force='Spawn'}
|
||||
protect_entity(turret,true)
|
||||
turret = surface.create_entity{name='gun-turret', position=pos, force='Spawn'}
|
||||
protect_entity(turret, true)
|
||||
end
|
||||
-- adds ammo to the turret
|
||||
local inv = turret.get_inventory(defines.inventory.turret_ammo)
|
||||
if inv.can_insert{name=config.infinite_ammo_turrets.ammo_type,count=10} then
|
||||
inv.insert{name=config.infinite_ammo_turrets.ammo_type,count=10}
|
||||
if inv.can_insert{name=config.infinite_ammo_turrets.ammo_type, count=10} then
|
||||
inv.insert{name=config.infinite_ammo_turrets.ammo_type, count=10}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- makes a 2x2 afk belt where set in config
|
||||
local function spawn_belts(surface,position)
|
||||
local belt_details = {{-0.5,-0.5,2},{0.5,-0.5,4},{-0.5,0.5,0},{0.5,0.5,6}} -- x,y,dir
|
||||
for _,belt_set in pairs(belts) do
|
||||
local function spawn_belts(surface, position)
|
||||
local belt_details = {{-0.5, -0.5, 2}, {0.5, -0.5, 4}, {-0.5, 0.5, 0}, {0.5, 0.5, 6}} -- x, y,dir
|
||||
for _, belt_set in pairs(belts) do
|
||||
local o = position
|
||||
local p = belt_set
|
||||
for _,belt in pairs(belt_details) do
|
||||
local pos = {x=o.x+p.x+belt[1],y=o.y+p.y+belt[2]}
|
||||
local belt_entity = surface.create_entity{name='transport-belt',position=pos,force='neutral',direction=belt[3]}
|
||||
for _, belt in pairs(belt_details) do
|
||||
local pos = {x=o.x+p.x+belt[1], y=o.y+p.y+belt[2]}
|
||||
local belt_entity = surface.create_entity{name='transport-belt', position=pos, force='neutral', direction=belt[3]}
|
||||
protect_entity(belt_entity)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- generates an area with no water and removes entities in the decon area
|
||||
local function spawn_base(surface,position)
|
||||
local function spawn_base(surface, position)
|
||||
local dr = config.corrections.deconstruction_radius
|
||||
local dr2 = dr^2
|
||||
local dtile = config.corrections.deconstruction_tile
|
||||
@@ -86,17 +86,17 @@ local function spawn_base(surface,position)
|
||||
for y = -pr, pr do -- loop over y
|
||||
local y2 = y^2
|
||||
local prod = x2+y2
|
||||
local p = {x=position.x+x,y=position.y+y}
|
||||
local p = {x=position.x+x, y=position.y+y}
|
||||
if prod < dr2 then
|
||||
-- if it is inside the decon radius
|
||||
table.insert(tiles_to_make,{name=dtile,position=p})
|
||||
local entities_to_remove = surface.find_entities_filtered{area={{p.x-1,p.y-1},{p.x,p.y}}}
|
||||
for _,entity in pairs(entities_to_remove) do
|
||||
table.insert(tiles_to_make, {name=dtile, position=p})
|
||||
local entities_to_remove = surface.find_entities_filtered{area={{p.x-1, p.y-1}, {p.x, p.y}}}
|
||||
for _, entity in pairs(entities_to_remove) do
|
||||
if entity.name ~= 'character' then entity.destroy() end
|
||||
end
|
||||
elseif prod < pr2 then
|
||||
-- if it is inside the pattern radius
|
||||
table.insert(tiles_to_make,{name=ptile,position=p})
|
||||
table.insert(tiles_to_make, {name=ptile, position=p})
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -104,30 +104,30 @@ local function spawn_base(surface,position)
|
||||
end
|
||||
|
||||
-- generates the pattern that is in the config
|
||||
local function spawn_pattern(surface,position)
|
||||
local function spawn_pattern(surface, position)
|
||||
local tiles_to_make = {}
|
||||
local ptile = config.corrections.pattern_tile
|
||||
local o = config.corrections.offset
|
||||
local p = {x=position.x+o.x,y=position.y+o.y}
|
||||
for _,tile in pairs(tiles) do
|
||||
table.insert(tiles_to_make,{name=ptile,position={tile[1]+p.x,tile[2]+p.y}})
|
||||
local p = {x=position.x+o.x, y=position.y+o.y}
|
||||
for _, tile in pairs(tiles) do
|
||||
table.insert(tiles_to_make, {name=ptile, position={tile[1]+p.x, tile[2]+p.y}})
|
||||
end
|
||||
surface.set_tiles(tiles_to_make)
|
||||
end
|
||||
|
||||
-- generates the entities that are in the config
|
||||
local function spawn_entities(surface,position)
|
||||
local function spawn_entities(surface, position)
|
||||
local o = config.corrections.offset
|
||||
local p = {x=position.x+o.x,y=position.y+o.y}
|
||||
for _,entity in pairs(entities) do
|
||||
entity = surface.create_entity{name=entity[1],position={entity[2]+p.x,entity[3]+p.y},force='neutral'}
|
||||
local p = {x=position.x+o.x, y=position.y+o.y}
|
||||
for _, entity in pairs(entities) do
|
||||
entity = surface.create_entity{name=entity[1], position={entity[2]+p.x, entity[3]+p.y}, force='neutral'}
|
||||
protect_entity(entity)
|
||||
entity.operable = true
|
||||
end
|
||||
end
|
||||
|
||||
local refill_time = 60*60*5 -- 5 minutes
|
||||
Event.on_nth_tick(refill_time,function()
|
||||
Event.on_nth_tick(refill_time, function()
|
||||
if game.tick < 10 then return end
|
||||
spawn_turrets()
|
||||
end)
|
||||
@@ -135,15 +135,15 @@ end)
|
||||
Event.add(defines.events.on_player_created, function(event)
|
||||
if event.player_index ~= 1 then return end
|
||||
local player = Game.get_player_by_index(event.player_index)
|
||||
local p = {x=0,y=0}
|
||||
local p = {x=0, y=0}
|
||||
local s = player.surface
|
||||
spawn_base(s,p)
|
||||
spawn_pattern(s,p)
|
||||
spawn_base(s, p)
|
||||
spawn_pattern(s, p)
|
||||
get_spawn_force()
|
||||
spawn_entities(s,p)
|
||||
spawn_belts(s,p)
|
||||
spawn_entities(s, p)
|
||||
spawn_belts(s, p)
|
||||
spawn_turrets()
|
||||
player.teleport(p,s)
|
||||
player.teleport(p, s)
|
||||
end)
|
||||
|
||||
-- Way to access global table
|
||||
|
||||
Reference in New Issue
Block a user