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

75 lines
2.4 KiB
Lua
Raw Normal View History

2021-03-24 21:14:55 +02:00
local Event = require 'utils.event'
2018-09-24 06:43:15 +02:00
2021-03-24 17:46:00 +02:00
local main_caption = ' --Cave Miner-- '
local sub_caption = ' *diggy diggy hole* '
local info =
[[
2018-09-24 06:43:15 +02:00
Delve deep for greater treasures, but also face increased dangers.
Mining productivity research, will overhaul your mining equipment,
reinforcing your pickaxe as well as increasing the size of your backpack.
Breaking rocks is exhausting and might make you hungry.
So don´t forget to eat some fish once in a while to stay well fed.
But be careful, eating too much might have it´s consequences too.
Darkness is a hazard in the mines, stay near your lamps..
]]
2021-03-24 17:46:00 +02:00
local function create_map_intro(player)
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-frame'
l.style.font_color = {r = 0.6, g = 0.3, b = 0.99}
l.style.top_padding = 6
l.style.bottom_padding = 6
2021-03-24 21:14:55 +02:00
l = tt.add {type = 'label', caption = sub_caption}
2021-03-24 17:46:00 +02:00
l.style.font = 'default'
l.style.font_color = {r = 0.99, g = 0.99, b = 0.2}
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
2021-03-24 21:14:55 +02:00
t.add {type = 'table', column_count = 1}
frame = t.add {type = 'frame'}
l = frame.add {type = 'label', caption = info}
2021-03-24 17:46:00 +02:00
l.style.single_line = false
l.style.font_color = {r = 0.95, g = 0.95, b = 0.95}
2018-09-24 06:43:15 +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-09-24 06:43:15 +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-09-24 06:43:15 +02:00
end
2021-03-24 21:14:55 +02:00
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
Event.add(defines.events.on_gui_click, on_gui_click)