1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-06 00:23:49 +02:00
ComfyFactorio/maps/wave_defense.lua

56 lines
1.6 KiB
Lua
Raw Normal View History

2019-10-20 06:07:07 +02:00
--vanilla with wave_defense
2021-03-24 17:46:00 +02:00
local WD = require 'modules.wave_defense.main'
local Map = require 'modules.map_info'
2019-10-20 06:07:07 +02:00
2021-03-24 17:46:00 +02:00
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['iron-plate'] = 16, ['iron-gear-wheel'] = 8, ['raw-fish'] = 3}
2019-10-20 06:07:07 +02:00
local function set_difficulty()
2021-03-24 17:46:00 +02:00
local wave_defense_table = WD.get_table()
--20 Players for maximum difficulty
wave_defense_table.wave_interval = 7200 - #game.connected_players * 270
if wave_defense_table.wave_interval < 1800 then
wave_defense_table.wave_interval = 1800
end
2019-10-20 06:07:07 +02:00
end
2021-03-24 17:46:00 +02:00
local function on_player_joined_game(event)
set_difficulty()
local player = game.players[event.player_index]
if player.online_time == 0 then
for item, amount in pairs(starting_items) do
player.insert({name = item, count = amount})
end
end
2019-10-20 06:07:07 +02:00
end
2021-03-24 21:14:55 +02:00
local function on_player_left_game()
2021-03-24 17:46:00 +02:00
set_difficulty()
2019-10-20 06:07:07 +02:00
end
2019-10-28 18:38:36 +02:00
local function on_init()
2021-03-24 17:46:00 +02:00
local T = Map.Pop_info()
T.main_caption = 'Wave Defense'
T.sub_caption = '~~~~~~'
T.text =
table.concat(
{
'Survive\n',
'as\n',
'long\n',
'as\n',
'possible.\n'
}
)
T.main_caption_color = {r = 150, g = 0, b = 150}
T.sub_caption_color = {r = 100, g = 150, b = 0}
game.surfaces[1].request_to_generate_chunks({0, 0}, 16)
game.surfaces[1].force_generate_chunk_requests()
2019-10-20 06:07:07 +02:00
end
local event = require 'utils.event'
event.on_init(on_init)
event.add(defines.events.on_player_left_game, on_player_left_game)
2021-03-24 17:46:00 +02:00
event.add(defines.events.on_player_joined_game, on_player_joined_game)