1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-16 02:47:48 +02:00

Merge pull request #36 from ComfyFactory/mtn_fortress

Mtn Fortress - Make ICW interior more pretty
This commit is contained in:
Gerkiz 2021-05-04 18:57:17 +02:00 committed by GitHub
commit 6a95cb2108
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 71 additions and 0 deletions

View File

@ -6,6 +6,23 @@ local Task = require 'utils.task'
local Token = require 'utils.token'
local SpamProtection = require 'utils.spam_protection'
local random = math.random
local sqrt = math.sqrt
local fallout_width = 64
local fallout_debris = {}
for x = fallout_width * -1 - 32, fallout_width + 32, 1 do
for y = fallout_width * -1 - 32, fallout_width + 32, 1 do
local position = {x = x, y = y}
local fallout = sqrt(position.x ^ 2 + position.y ^ 2)
if fallout > fallout_width then
fallout_debris[#fallout_debris + 1] = {position.x, position.y}
end
end
end
local size_of_debris = #fallout_debris
local reconstruct_all_trains =
Token.register(
function(data)
@ -183,6 +200,57 @@ local function input_filtered(wagon_inventory, chest, chest_inventory, free_slot
end
end
function Public.hazardous_debris(icw)
local speed = icw.speed
local surface = WPT.get('loco_surface')
if not surface or not surface.valid then
return
end
local hazardous_debris = icw.hazardous_debris
if not hazardous_debris then
return
end
local create = surface.create_entity
for _ = 1, 16 * speed, 1 do
local position = fallout_debris[random(1, size_of_debris)]
local p = {x = position[1], y = position[2]}
local get_tile = surface.get_tile(p)
if get_tile.valid and get_tile.name == 'out-of-map' then
create({name = 'blue-laser', position = position, force = 'neutral', target = {position[1], position[2] + fallout_width * 2}, speed = speed})
end
end
for _ = 1, 16 * speed, 1 do
local position = fallout_debris[random(1, size_of_debris)]
local p = {x = position[1], y = position[2]}
local get_tile = surface.get_tile(p)
if get_tile.valid and get_tile.name == 'out-of-map' then
create({name = 'shotgun-pellet', position = position, force = 'neutral', target = {position[1], position[2] + fallout_width * 2}, speed = speed})
end
end
for _ = 1, 2 * speed, 1 do
local position = fallout_debris[random(1, size_of_debris)]
local p = {x = position[1], y = position[2]}
local get_tile = surface.get_tile(p)
if get_tile.valid and get_tile.name == 'out-of-map' then
create({name = 'cannon-projectile', position = position, force = 'neutral', target = {position[1], position[2] + fallout_width * 2}, speed = speed})
end
end
for _ = 1, 1 * speed, 1 do
local position = fallout_debris[random(1, size_of_debris)]
local p = {x = position[1], y = position[2]}
local get_tile = surface.get_tile(p)
if get_tile.valid and get_tile.name == 'out-of-map' then
create({name = 'uranium-cannon-projectile', position = position, force = 'neutral', target = {position[1], position[2] + fallout_width * 2}, speed = speed})
end
end
end
local function input_cargo(wagon, chest)
if not chest.request_from_buffers then
goto continue

View File

@ -96,6 +96,7 @@ local function on_tick()
local tick = game.tick
if tick % 10 == 0 then
Functions.item_transfer(icw)
Functions.hazardous_debris(icw)
end
if tick % 240 == 0 then
Functions.update_minimap(icw)

View File

@ -23,6 +23,8 @@ function Public.reset()
end
this.doors = {}
this.wagons = {}
this.speed = 0.1
this.hazardous_debris = true
this.current_wagon_index = nil
this.trains = {}
this.players = {}