1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-14 10:13:13 +02:00
RedMew/info.lua

84 lines
2.7 KiB
Lua
Raw Normal View History

2017-06-13 13:16:07 +02:00
local function create_info_button(event)
local player = game.players[event.player_index]
2017-06-30 17:10:19 +02:00
if player.gui.top.info_button == nil then
local button = player.gui.top.add({ type = "sprite-button", name = "info_button", sprite = "item/raw-fish" })
2017-06-13 13:16:07 +02:00
button.style.minimal_height = 38
button.style.minimal_width = 38
button.style.top_padding = 2
button.style.left_padding = 4
button.style.right_padding = 4
button.style.bottom_padding = 2
end
end
local function info_show(player)
local infotext = [===[
Hi stranger, I'm a fish..
And this is what you ought to know:
- Please be nice and don't grief. Or else.. ;)
2017-08-05 01:01:49 +02:00
- Admins: Don't abuse. Don't fight other Admins.
- Don't argue with other players for silly things.
2017-06-13 13:16:07 +02:00
- No political, racist, or misogynistic content.
- If you suspect you desync, restart the game.
2017-08-10 23:15:47 +02:00
- Join our growing community on discord.me/redmew
- Post server pics (or didn't happen): redmew.reddit.com
2017-08-05 01:01:49 +02:00
- Contribute to our Hookers & Blow Fund with:
Bitcoin: 18PferSFbkwsYai8sLnWKzrr8YXQ1bBqNg
Paypal: paypal.me/jsuesse
2017-06-13 13:16:07 +02:00
]===]
local frame = player.gui.left.add { type = "frame", name = "info_panel"}
frame.style.top_padding = 20
frame.style.left_padding = 20
frame.style.right_padding = 20
frame.style.bottom_padding = 20
2017-12-15 18:52:26 +02:00
local info_table = frame.add { type = "table", column_count = 1, name = "info_table" }
2017-06-13 13:16:07 +02:00
local headline_label = info_table.add { type = "label", name = "headline_label", caption = "redmew fishy info" }
headline_label.style.font_color = { r=0.98, g=0.66, b=0.22}
2017-06-13 13:16:07 +02:00
local text_box = info_table.add { type = "text-box", text = infotext, name = "text_box" }
text_box.read_only = true
text_box.selectable = true
text_box.word_wrap = false
text_box.style.right_padding = 5
text_box.style.top_padding = 5
text_box.style.left_padding = 5
text_box.style.bottom_padding = 5
2017-12-15 18:52:26 +02:00
local info_table_2 = info_table.add { type = "table", column_count = 2, name = "info_table" }
2017-06-13 13:16:07 +02:00
info_table_2.add { type = "label", caption = " " }
local close_button = info_table_2.add { type = "button", caption = "CLOSE", name = "info_close_button" }
2017-06-13 13:16:07 +02:00
end
local function on_gui_click(event)
if not (event and event.element and event.element.valid) then return end
2017-06-13 13:16:07 +02:00
local player = game.players[event.element.player_index]
local name = event.element.name
local frame = player.gui.left["info_panel"]
2017-06-13 13:16:07 +02:00
if (name == "info_button") and (frame == nil) then
info_show(player)
else
if (name == "info_button") then
frame.destroy()
end
end
2017-06-13 13:16:07 +02:00
if (name == "info_close_button") then
frame.destroy()
end
2017-06-13 13:16:07 +02:00
end
Event.register(defines.events.on_gui_click, on_gui_click)
Event.register(defines.events.on_player_joined_game, create_info_button)