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

38 lines
994 B
Lua
Raw Normal View History

2019-05-07 23:38:14 +02:00
local event = require 'utils.event'
local function on_console_chat(event)
if not event.message then return end
if not event.player_index then return end
local player = game.players[event.player_index]
if not player.character then return end
if global.player_floaty_chat[player.index] then
rendering.destroy(global.player_floaty_chat[player.index])
global.player_floaty_chat[player.index] = nil
end
global.player_floaty_chat[player.index] = rendering.draw_text{
text = event.message,
surface = player.surface,
target = player.character,
2019-05-08 01:02:00 +02:00
target_offset = {-0.05, -4},
2019-05-07 23:38:14 +02:00
color = {
r = player.color.r * 0.6 + 0.25,
g = player.color.g * 0.6 + 0.25,
b = player.color.b * 0.6 + 0.25,
a = 1
},
time_to_live = 600,
2019-05-08 01:02:00 +02:00
scale = 1.50,
2019-05-07 23:38:14 +02:00
font = "default-game",
alignment = "center",
2019-05-08 01:02:00 +02:00
scale_with_zoom = false
2019-05-07 23:38:14 +02:00
}
end
local function on_init(event)
global.player_floaty_chat = {}
end
event.on_init(on_init)
event.add(defines.events.on_console_chat, on_console_chat)