mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2024-12-30 23:17:53 +02:00
chatbot - add ability to switch to classic print
This commit is contained in:
parent
f4ac35a5eb
commit
c68a49fa6c
@ -1,9 +1,22 @@
|
||||
local Event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
local Color = require 'utils.color_presets'
|
||||
local Global = require 'utils.global'
|
||||
|
||||
local font_color = Color.warning
|
||||
local font = 'heading-1'
|
||||
local this = {
|
||||
settings = {
|
||||
enable_classic_print = false
|
||||
}
|
||||
}
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(tbl)
|
||||
this = tbl
|
||||
end
|
||||
)
|
||||
|
||||
local Public = {}
|
||||
|
||||
local brain = {
|
||||
[1] = {'Our Discord server is at: https://getcomfy.eu/discord'},
|
||||
@ -51,13 +64,15 @@ local links = {
|
||||
|
||||
local function on_player_created(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
player.print(
|
||||
'[font=' ..
|
||||
font ..
|
||||
']' ..
|
||||
'[color=#E99696]J[/color][color=#E9A296]o[/color][color=#E9AF96]i[/color][color=#E9BB96]n[/color] [color=#E9C896]t[/color][color=#E9D496]h[/color][color=#E9E096]e[/color] ☕[color=#E5E996]c[/color][color=#D8E996]o[/color][color=#CCE996]m[/color][color=#BFE996]f[/color][color=#B3E996]y[/color] [color=#A6E996]d[/color][color=#9AE996]i[/color][color=#96E99E]s[/color][color=#96E9AB]c[/color][color=#96E9B7]o[/color][color=#96E9C3]r[/color][color=#96E9D0]d[/color] [color=#96E9DC]>[/color][color=#96E9E9]>[/color] [color=#96DCE9]g[/color][color=#96D0E9]e[/color][color=#96C3E9]t[/color][color=#96B7E9]c[/color][color=#96ABE9]o[/color][color=#969EE9]m[/color][color=#9A96E9]f[/color][color=#A696E9]y[/color][color=#B396E9].[/color][color=#BF96E9]e[/color][color=#CC96E9]u[/color][color=#D896E9]/[/color][color=#E596E9]d[/color][color=#E996E0]i[/color][color=#E996D4]s[/color][color=#E996C8]c[/color][color=#E996BB]o[/color][color=#E996AF]r[/color][color=#E996A2]d[/color]' ..
|
||||
'[/font]'
|
||||
)
|
||||
if this.settings.enable_classic_print then
|
||||
player.print('[font=default-game]' .. 'Join the comfy discord >> getcomfy.eu/discord <<' .. '[/font]', {r = 150, g = 100, b = 255, a = 255})
|
||||
else
|
||||
player.print(
|
||||
'[font=heading-1]' ..
|
||||
'[color=#E99696]J[/color][color=#E9A296]o[/color][color=#E9AF96]i[/color][color=#E9BB96]n[/color] [color=#E9C896]t[/color][color=#E9D496]h[/color][color=#E9E096]e[/color] ☕[color=#E5E996]c[/color][color=#D8E996]o[/color][color=#CCE996]m[/color][color=#BFE996]f[/color][color=#B3E996]y[/color] [color=#A6E996]d[/color][color=#9AE996]i[/color][color=#96E99E]s[/color][color=#96E9AB]c[/color][color=#96E9B7]o[/color][color=#96E9C3]r[/color][color=#96E9D0]d[/color] [color=#96E9DC]>[/color][color=#96E9E9]>[/color] [color=#96DCE9]g[/color][color=#96D0E9]e[/color][color=#96C3E9]t[/color][color=#96B7E9]c[/color][color=#96ABE9]o[/color][color=#969EE9]m[/color][color=#9A96E9]f[/color][color=#A696E9]y[/color][color=#B396E9].[/color][color=#BF96E9]e[/color][color=#CC96E9]u[/color][color=#D896E9]/[/color][color=#E596E9]d[/color][color=#E996E0]i[/color][color=#E996D4]s[/color][color=#E996C8]c[/color][color=#E996BB]o[/color][color=#E996AF]r[/color][color=#E996A2]d[/color]' ..
|
||||
'[/font]'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_bot_answers(event)
|
||||
@ -70,7 +85,7 @@ local function process_bot_answers(event)
|
||||
for word in string.gmatch(message, '%g+') do
|
||||
if links[word] then
|
||||
for _, bot_answer in pairs(links[word]) do
|
||||
player.print('[font=' .. font .. ']' .. bot_answer .. '[/font]', font_color)
|
||||
player.print('[font=heading-1]' .. bot_answer .. '[/font]', Color.warning)
|
||||
end
|
||||
return
|
||||
end
|
||||
@ -88,5 +103,13 @@ local function on_console_chat(event)
|
||||
process_bot_answers(event)
|
||||
end
|
||||
|
||||
--- Enables the classic print when a player is created.
|
||||
---@param boolean any
|
||||
function Public.enable_classic_print(boolean)
|
||||
this.settings.enable_classic_print = boolean or false
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_player_created, on_player_created)
|
||||
Event.add(defines.events.on_console_chat, on_console_chat)
|
||||
|
||||
return Public
|
||||
|
Loading…
Reference in New Issue
Block a user