1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-10 00:43:27 +02:00
ComfyFactorio/maps/wave_of_death/intro.lua

98 lines
2.9 KiB
Lua
Raw Normal View History

2021-03-24 21:14:55 +02:00
--luacheck: ignore
2019-05-05 16:17:33 +02:00
local event = require 'utils.event'
2021-03-24 17:46:00 +02:00
local info =
[[
2019-05-05 16:17:33 +02:00
Hello Players,
on this map you battle with your team against up to 3 other teams.
Each team can call its own wave of biters and spitters at any time and they get stronger with each wave.
Each wave, when defeated, sends a percentage of their enemys to all other teams.
2019-05-06 22:09:15 +02:00
To call a wave, you have to rotate the loader.
2019-05-05 16:17:33 +02:00
But remember that you must also be able to defeat the enemy.
2019-05-06 22:09:15 +02:00
Your task is to defend your loader. If it is destroyed, you have lost!
2019-05-05 16:17:33 +02:00
2019-05-06 22:09:15 +02:00
A round is over when only one team has it's loader left.
2019-05-05 16:17:33 +02:00
Credits:
Map made by MewMew and Kyte
]]
local function create_map_intro_button(player)
2021-03-24 17:46:00 +02:00
if player.gui.top['map_intro_button'] then
return
end
local b = player.gui.top.add({type = 'sprite-button', caption = '?', name = 'map_intro_button', tooltip = 'Map Info'})
b.style.font_color = {r = 0.1, g = 0.8, b = 0.1}
b.style.font = 'heading-1'
b.style.minimal_height = 38
b.style.minimal_width = 38
b.style.top_padding = 2
b.style.left_padding = 4
b.style.right_padding = 4
b.style.bottom_padding = 2
2019-05-05 16:17:33 +02:00
end
local function create_map_intro(player)
2021-03-24 17:46:00 +02:00
if player.gui.left['map_intro_frame'] then
player.gui.left['map_intro_frame'].destroy()
end
local frame = player.gui.left.add {type = 'frame', name = 'map_intro_frame', direction = 'vertical'}
2019-05-05 16:17:33 +02:00
2021-03-24 17:46:00 +02:00
local t = frame.add {type = 'table', column_count = 1}
2019-05-05 16:17:33 +02:00
2021-03-24 17:46:00 +02:00
local b = frame.add {type = 'button', caption = 'Close', name = 'close_map_intro_frame', align = 'right'}
b.style.font = 'default'
b.style.minimal_height = 30
b.style.minimal_width = 30
b.style.top_padding = 2
b.style.left_padding = 4
b.style.right_padding = 4
b.style.bottom_padding = 2
2019-05-05 16:17:33 +02:00
2021-03-24 17:46:00 +02:00
local frame = t.add {type = 'frame'}
local l = frame.add {type = 'label', caption = info}
l.style.single_line = false
l.style.font = 'heading-2'
l.style.font_color = {r = 0.60, g = 0.8, b = 0.60}
2019-05-05 16:17:33 +02:00
end
local function on_player_joined_game(event)
2021-03-24 17:46:00 +02:00
local player = game.players[event.player_index]
create_map_intro_button(player)
if player.online_time == 0 then
create_map_intro(player)
end
2019-05-05 16:17:33 +02:00
end
local function on_gui_click(event)
2021-03-24 17:46:00 +02:00
if not event then
return
end
if not event.element then
return
end
if not event.element.valid then
return
end
local player = game.players[event.element.player_index]
if event.element.name == 'close_map_intro_frame' then
player.gui.left['map_intro_frame'].destroy()
return
end
if event.element.name == 'map_intro_button' then
if player.gui.left['map_intro_frame'] then
player.gui.left['map_intro_frame'].destroy()
else
create_map_intro(player)
end
return
end
2019-05-05 16:17:33 +02:00
end
event.add(defines.events.on_player_joined_game, on_player_joined_game)
event.add(defines.events.on_gui_click, on_gui_click)