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

78 lines
2.4 KiB
Lua
Raw Normal View History

2021-03-24 21:14:55 +02:00
--luacheck: ignore
2018-12-31 16:39:09 +02:00
local event = require 'utils.event'
2021-03-24 17:46:00 +02:00
local main_caption = ' --Nightfall-- '
local sub_caption = '*can you make it through*'
local info =
[[
2019-02-16 18:36:12 +02:00
They come out at night, trying to nom your rocket silo.
2021-03-24 17:46:00 +02:00
2018-12-31 16:39:09 +02:00
Fend them off as long as possible!
2021-03-24 17:46:00 +02:00
2019-02-16 18:36:12 +02:00
There seem to be shipwrecks of unfortunate explorers all over this place.
2018-12-31 16:39:09 +02:00
It might be worth scavenging a few.
2021-03-24 17:46:00 +02:00
Wreck loot quality increases with distance.
2018-12-31 16:39:09 +02:00
]]
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'}
local t = frame.add {type = 'table', column_count = 1}
local tt = t.add {type = 'table', column_count = 3}
local l = tt.add {type = 'label', caption = main_caption}
l.style.font = 'default-listbox'
l.style.font_color = {r = 0.85, g = 0.0, b = 0.25}
l.style.top_padding = 6
l.style.bottom_padding = 6
local l = tt.add {type = 'label', caption = sub_caption}
l.style.font = 'default'
l.style.font_color = {r = 0.1, g = 0.65, b = 0.1}
l.style.minimal_width = 280
local b = tt.add {type = 'button', caption = 'X', 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
local tt = t.add {type = 'table', column_count = 1}
local frame = t.add {type = 'frame'}
local l = frame.add {type = 'label', caption = info}
l.style.single_line = false
l.style.font_color = {r = 0.95, g = 0.95, b = 0.95}
2018-12-31 16:39:09 +02:00
end
2021-03-24 17:46:00 +02:00
local function on_player_joined_game(event)
local player = game.players[event.player_index]
if player.online_time < 36000 then
create_map_intro(player)
end
2018-12-31 16:39:09 +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()
end
2018-12-31 16:39:09 +02:00
end
event.add(defines.events.on_player_joined_game, on_player_joined_game)
2021-03-24 17:46:00 +02:00
event.add(defines.events.on_gui_click, on_gui_click)