mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-13 13:49:33 +02:00
Merge branch 'develop' into develop
This commit is contained in:
commit
222e99465b
240
chatbot.lua
240
chatbot.lua
@ -1,240 +0,0 @@
|
|||||||
local Event = require 'utils.event'
|
|
||||||
local session = require 'utils.datastore.session_data'
|
|
||||||
local Timestamp = require 'utils.timestamp'
|
|
||||||
local Server = require 'utils.server'
|
|
||||||
local Color = require 'utils.color_presets'
|
|
||||||
|
|
||||||
local font_color = Color.warning
|
|
||||||
local font_welcome = {r = 150, g = 100, b = 255, a = 255}
|
|
||||||
local font = 'default-game'
|
|
||||||
local format = string.format
|
|
||||||
|
|
||||||
local brain = {
|
|
||||||
[1] = {'Our Discord server is at: https://getcomfy.eu/discord'},
|
|
||||||
[2] = {
|
|
||||||
'Need an admin? Join our discord at: https://getcomfy.eu/discord,',
|
|
||||||
'and report it in #i-need-halp',
|
|
||||||
'If you have played for more than 5h in our maps then,',
|
|
||||||
'you are eligible to run the command /jail and /free'
|
|
||||||
},
|
|
||||||
[3] = {'Scenario repository for download:', 'https://github.com/M3wM3w/ComfyFactorio'},
|
|
||||||
[4] = {
|
|
||||||
'If you feel like the server is lagging, run the following command:',
|
|
||||||
'/server-ups',
|
|
||||||
'This will display the server UPS on your top right screen.'
|
|
||||||
},
|
|
||||||
[5] = {
|
|
||||||
"If you're not trusted - ask a trusted player or an admin to trust you."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
local links = {
|
|
||||||
['admin'] = brain[2],
|
|
||||||
['administrator'] = brain[2],
|
|
||||||
['discord'] = brain[1],
|
|
||||||
['download'] = brain[3],
|
|
||||||
['github'] = brain[3],
|
|
||||||
['greifer'] = brain[2],
|
|
||||||
['grief'] = brain[2],
|
|
||||||
['griefer'] = brain[2],
|
|
||||||
['griefing'] = brain[2],
|
|
||||||
['mod'] = brain[2],
|
|
||||||
['moderator'] = brain[2],
|
|
||||||
['scenario'] = brain[3],
|
|
||||||
['stealing'] = brain[2],
|
|
||||||
['stole'] = brain[2],
|
|
||||||
['troll'] = brain[2],
|
|
||||||
['lag'] = brain[4],
|
|
||||||
['lagging'] = brain[4],
|
|
||||||
['trust'] = brain[5],
|
|
||||||
['trusted'] = brain[5],
|
|
||||||
['untrusted'] = brain[5]
|
|
||||||
}
|
|
||||||
|
|
||||||
local function on_player_created(event)
|
|
||||||
local player = game.players[event.player_index]
|
|
||||||
player.print('[font=' .. font .. ']' .. 'Join the comfy discord >> getcomfy.eu/discord' .. '[/font]', font_welcome)
|
|
||||||
end
|
|
||||||
|
|
||||||
commands.add_command(
|
|
||||||
'trust',
|
|
||||||
'Promotes a player to trusted!',
|
|
||||||
function(cmd)
|
|
||||||
local trusted = session.get_trusted_table()
|
|
||||||
local player = game.player
|
|
||||||
|
|
||||||
if player and player.valid then
|
|
||||||
if not player.admin then
|
|
||||||
player.print("You're not admin!", {r = 1, g = 0.5, b = 0.1})
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if cmd.parameter == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local target_player = game.players[cmd.parameter]
|
|
||||||
if target_player then
|
|
||||||
if trusted[target_player.name] then
|
|
||||||
game.print(target_player.name .. ' is already trusted!')
|
|
||||||
return
|
|
||||||
end
|
|
||||||
trusted[target_player.name] = true
|
|
||||||
game.print(target_player.name .. ' is now a trusted player.', {r = 0.22, g = 0.99, b = 0.99})
|
|
||||||
for _, a in pairs(game.connected_players) do
|
|
||||||
if a.admin and a.name ~= player.name then
|
|
||||||
a.print('[ADMIN]: ' .. player.name .. ' trusted ' .. target_player.name, {r = 1, g = 0.5, b = 0.1})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if cmd.parameter == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local target_player = game.players[cmd.parameter]
|
|
||||||
if target_player then
|
|
||||||
if trusted[target_player.name] == true then
|
|
||||||
game.print(target_player.name .. ' is already trusted!')
|
|
||||||
return
|
|
||||||
end
|
|
||||||
trusted[target_player.name] = true
|
|
||||||
game.print(target_player.name .. ' is now a trusted player.', {r = 0.22, g = 0.99, b = 0.99})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
commands.add_command(
|
|
||||||
'untrust',
|
|
||||||
'Demotes a player from trusted!',
|
|
||||||
function(cmd)
|
|
||||||
local trusted = session.get_trusted_table()
|
|
||||||
local player = game.player
|
|
||||||
|
|
||||||
if player then
|
|
||||||
if player ~= nil then
|
|
||||||
if not player.admin then
|
|
||||||
player.print("You're not admin!", {r = 1, g = 0.5, b = 0.1})
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if cmd.parameter == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local target_player = game.players[cmd.parameter]
|
|
||||||
if target_player then
|
|
||||||
if trusted[target_player.name] == false then
|
|
||||||
game.print(target_player.name .. ' is already untrusted!')
|
|
||||||
return
|
|
||||||
end
|
|
||||||
trusted[target_player.name] = false
|
|
||||||
game.print(target_player.name .. ' is now untrusted.', {r = 0.22, g = 0.99, b = 0.99})
|
|
||||||
for _, a in pairs(game.connected_players) do
|
|
||||||
if a.admin == true and a.name ~= player.name then
|
|
||||||
a.print('[ADMIN]: ' .. player.name .. ' untrusted ' .. target_player.name, {r = 1, g = 0.5, b = 0.1})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if cmd.parameter == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local target_player = game.players[cmd.parameter]
|
|
||||||
if target_player then
|
|
||||||
if trusted[target_player.name] == false then
|
|
||||||
game.print(target_player.name .. ' is already untrusted!')
|
|
||||||
return
|
|
||||||
end
|
|
||||||
trusted[target_player.name] = false
|
|
||||||
game.print(target_player.name .. ' is now untrusted.', {r = 0.22, g = 0.99, b = 0.99})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
local function process_bot_answers(event)
|
|
||||||
local player = game.players[event.player_index]
|
|
||||||
if player.admin then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local message = event.message
|
|
||||||
message = string.lower(message)
|
|
||||||
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)
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function on_console_chat(event)
|
|
||||||
if not event.player_index then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local secs = Server.get_current_time()
|
|
||||||
if not secs then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
process_bot_answers(event)
|
|
||||||
end
|
|
||||||
|
|
||||||
--share vision of silent-commands with other admins
|
|
||||||
local function on_console_command(event)
|
|
||||||
local cmd = event.command
|
|
||||||
if not event.player_index then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local player = game.players[event.player_index]
|
|
||||||
local param = event.parameters
|
|
||||||
|
|
||||||
if not player.admin then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local server_time = Server.get_current_time()
|
|
||||||
if server_time then
|
|
||||||
server_time = format(' (Server time: %s)', Timestamp.to_string(server_time))
|
|
||||||
else
|
|
||||||
server_time = ' at tick: ' .. game.tick
|
|
||||||
end
|
|
||||||
|
|
||||||
if string.len(param) <= 0 then
|
|
||||||
param = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local commands = {
|
|
||||||
['editor'] = true,
|
|
||||||
['command'] = true,
|
|
||||||
['silent-command'] = true,
|
|
||||||
['sc'] = true,
|
|
||||||
['debug'] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if not commands[cmd] then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if player then
|
|
||||||
if param then
|
|
||||||
print('[COMMAND HANDLER] ' .. player.name .. ' ran: ' .. cmd .. ' "' .. param .. '" ' .. server_time)
|
|
||||||
return
|
|
||||||
else
|
|
||||||
print('[COMMAND HANDLER] ' .. player.name .. ' ran: ' .. cmd .. server_time)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if param then
|
|
||||||
print('[COMMAND HANDLER] ran: ' .. cmd .. ' "' .. param .. '" ' .. server_time)
|
|
||||||
return
|
|
||||||
else
|
|
||||||
print('[COMMAND HANDLER] ran: ' .. cmd .. server_time)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Event.add(defines.events.on_player_created, on_player_created)
|
|
||||||
Event.add(defines.events.on_console_chat, on_console_chat)
|
|
||||||
Event.add(defines.events.on_console_command, on_console_command)
|
|
@ -3,7 +3,7 @@
|
|||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Jailed = require 'utils.datastore.jail_data'
|
local Jailed = require 'utils.datastore.jail_data'
|
||||||
local Tabs = require 'comfy_panel.main'
|
local Tabs = require 'comfy_panel.main'
|
||||||
local AntiGrief = require 'antigrief'
|
local AntiGrief = require 'utils.antigrief'
|
||||||
local SpamProtection = require 'utils.spam_protection'
|
local SpamProtection = require 'utils.spam_protection'
|
||||||
local Token = require 'utils.token'
|
local Token = require 'utils.token'
|
||||||
|
|
||||||
@ -67,7 +67,10 @@ local function go_to_player(player, source_player)
|
|||||||
local pos = player.surface.find_non_colliding_position('character', player.position, 50, 1)
|
local pos = player.surface.find_non_colliding_position('character', player.position, 50, 1)
|
||||||
if pos then
|
if pos then
|
||||||
source_player.teleport(pos, player.surface)
|
source_player.teleport(pos, player.surface)
|
||||||
game.print(source_player.name .. ' is visiting ' .. player.name .. '. ' .. go_to_player_messages[math.random(1, #go_to_player_messages)], {r = 0.98, g = 0.66, b = 0.22})
|
game.print(
|
||||||
|
source_player.name .. ' is visiting ' .. player.name .. '. ' .. go_to_player_messages[math.random(1, #go_to_player_messages)],
|
||||||
|
{r = 0.98, g = 0.66, b = 0.22}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -333,7 +336,7 @@ local function text_changed(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local antigrief = AntiGrief.get()
|
local antigrief = AntiGrief.get()
|
||||||
local player = game.players[event.player_index]
|
local player = game.get_player(event.player_index)
|
||||||
|
|
||||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||||
if not frame then
|
if not frame then
|
||||||
@ -715,7 +718,7 @@ local function on_gui_click(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function on_gui_selection_state_changed(event)
|
local function on_gui_selection_state_changed(event)
|
||||||
local player = game.players[event.player_index]
|
local player = game.get_player(event.player_index)
|
||||||
local name = event.element.name
|
local name = event.element.name
|
||||||
|
|
||||||
if name == 'admin_history_select' then
|
if name == 'admin_history_select' then
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local Misc = require 'commands.misc'
|
local Misc = require 'utils.commands.misc'
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
local ComfyGui = require 'comfy_panel.main'
|
local ComfyGui = require 'comfy_panel.main'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local Antigrief = require 'antigrief'
|
local Antigrief = require 'utils.antigrief'
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Color = require 'utils.color_presets'
|
local Color = require 'utils.color_presets'
|
||||||
local SessionData = require 'utils.datastore.session_data'
|
local SessionData = require 'utils.datastore.session_data'
|
||||||
@ -62,7 +62,7 @@ local function spaghett_deny_building(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if event.player_index then
|
if event.player_index then
|
||||||
game.players[event.player_index].insert({name = entity.name, count = 1})
|
game.get_player(event.player_index).insert({name = entity.name, count = 1})
|
||||||
else
|
else
|
||||||
local inventory = event.robot.get_inventory(defines.inventory.robot_cargo)
|
local inventory = event.robot.get_inventory(defines.inventory.robot_cargo)
|
||||||
inventory.insert({name = entity.name, count = 1})
|
inventory.insert({name = entity.name, count = 1})
|
||||||
@ -119,9 +119,9 @@ end
|
|||||||
local functions = {
|
local functions = {
|
||||||
['comfy_panel_spectator_switch'] = function(event)
|
['comfy_panel_spectator_switch'] = function(event)
|
||||||
if event.element.switch_state == 'left' then
|
if event.element.switch_state == 'left' then
|
||||||
game.players[event.player_index].spectator = true
|
game.get_player(event.player_index).spectator = true
|
||||||
else
|
else
|
||||||
game.players[event.player_index].spectator = false
|
game.get_player(event.player_index).spectator = false
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
['comfy_panel_bottom_location'] = function(event)
|
['comfy_panel_bottom_location'] = function(event)
|
||||||
@ -754,7 +754,7 @@ end
|
|||||||
local build_config_gui_token = Token.register(build_config_gui)
|
local build_config_gui_token = Token.register(build_config_gui)
|
||||||
|
|
||||||
local function on_gui_switch_state_changed(event)
|
local function on_gui_switch_state_changed(event)
|
||||||
local player = game.players[event.player_index]
|
local player = game.get_player(event.player_index)
|
||||||
if not (player and player.valid) then
|
if not (player and player.valid) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -55,42 +55,30 @@ function Public.get(key)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Public.comfy_panel_clear_left_gui(player)
|
function Public.comfy_panel_clear_gui(player)
|
||||||
for _, child in pairs(player.gui.left.children) do
|
for _, child in pairs(player.gui.left.children) do
|
||||||
child.visible = false
|
child.destroy()
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function Public.comfy_panel_restore_left_gui(player)
|
|
||||||
for _, child in pairs(player.gui.left.children) do
|
|
||||||
child.visible = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Public.comfy_panel_clear_screen_gui(player)
|
|
||||||
for _, child in pairs(player.gui.screen.children) do
|
for _, child in pairs(player.gui.screen.children) do
|
||||||
if not screen_elements[child.name] then
|
child.destroy()
|
||||||
child.visible = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Public.comfy_panel_restore_screen_gui(player)
|
|
||||||
for _, child in pairs(player.gui.screen.children) do
|
|
||||||
if not screen_elements[child.name] then
|
|
||||||
child.visible = true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Public.comfy_panel_get_active_frame(player)
|
function Public.comfy_panel_get_active_frame(player)
|
||||||
if not player.gui.left.comfy_panel then
|
local main_frame = player.gui.left.comfy_panel
|
||||||
|
if not main_frame then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if not player.gui.left.comfy_panel.tabbed_pane.selected_tab_index then
|
|
||||||
return player.gui.left.comfy_panel.tabbed_pane.tabs[1].content
|
local panel = main_frame.tabbed_pane
|
||||||
|
if not panel then
|
||||||
|
return
|
||||||
end
|
end
|
||||||
return player.gui.left.comfy_panel.tabbed_pane.tabs[player.gui.left.comfy_panel.tabbed_pane.selected_tab_index].content
|
local index = panel.selected_tab_index
|
||||||
|
if not index then
|
||||||
|
return panel.tabs[1].content
|
||||||
|
end
|
||||||
|
return panel.tabs[index].content
|
||||||
end
|
end
|
||||||
|
|
||||||
function Public.comfy_panel_refresh_active_tab(player)
|
function Public.comfy_panel_refresh_active_tab(player)
|
||||||
@ -130,7 +118,7 @@ end
|
|||||||
|
|
||||||
local function main_frame(player)
|
local function main_frame(player)
|
||||||
local tabs = main_gui_tabs
|
local tabs = main_gui_tabs
|
||||||
Public.comfy_panel_clear_left_gui(player)
|
Public.comfy_panel_clear_gui(player)
|
||||||
|
|
||||||
local frame = player.gui.left.comfy_panel
|
local frame = player.gui.left.comfy_panel
|
||||||
if not frame or not frame.valid then
|
if not frame or not frame.valid then
|
||||||
@ -200,7 +188,8 @@ function Public.comfy_panel_call_tab(player, name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function on_player_joined_game(event)
|
local function on_player_joined_game(event)
|
||||||
top_button(game.players[event.player_index])
|
local player = game.get_player(event.player_index)
|
||||||
|
top_button(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_gui_click(event)
|
local function on_gui_click(event)
|
||||||
@ -209,7 +198,7 @@ local function on_gui_click(event)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local player = game.players[event.player_index]
|
local player = game.get_player(event.player_index)
|
||||||
|
|
||||||
local name = element.name
|
local name = element.name
|
||||||
|
|
||||||
@ -220,11 +209,8 @@ local function on_gui_click(event)
|
|||||||
end
|
end
|
||||||
if player.gui.left.comfy_panel then
|
if player.gui.left.comfy_panel then
|
||||||
player.gui.left.comfy_panel.destroy()
|
player.gui.left.comfy_panel.destroy()
|
||||||
Public.comfy_panel_restore_left_gui(player)
|
|
||||||
Public.comfy_panel_restore_screen_gui(player)
|
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
Public.comfy_panel_clear_screen_gui(player)
|
|
||||||
main_frame(player)
|
main_frame(player)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -236,7 +222,6 @@ local function on_gui_click(event)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
player.gui.left.comfy_panel.destroy()
|
player.gui.left.comfy_panel.destroy()
|
||||||
Public.comfy_panel_restore_left_gui(player)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ to your scenario control.lua.
|
|||||||
Minor changes by ~~~Gerkiz~~~
|
Minor changes by ~~~Gerkiz~~~
|
||||||
--]]
|
--]]
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Where = require 'commands.where'
|
local Where = require 'utils.commands.where'
|
||||||
local Session = require 'utils.datastore.session_data'
|
local Session = require 'utils.datastore.session_data'
|
||||||
local Jailed = require 'utils.datastore.jail_data'
|
local Jailed = require 'utils.datastore.jail_data'
|
||||||
local Supporters = require 'utils.datastore.supporters'
|
local Supporters = require 'utils.datastore.supporters'
|
||||||
|
@ -396,9 +396,8 @@ local function toggle(event)
|
|||||||
|
|
||||||
if main_frame then
|
if main_frame then
|
||||||
remove_main_frame(main_frame, left, event.player)
|
remove_main_frame(main_frame, left, event.player)
|
||||||
Tabs.comfy_panel_restore_left_gui(event.player)
|
|
||||||
else
|
else
|
||||||
Tabs.comfy_panel_clear_left_gui(event.player)
|
Tabs.comfy_panel_clear_gui(event.player)
|
||||||
draw_main_frame(left, event.player)
|
draw_main_frame(left, event.player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
require 'commands.misc'
|
|
||||||
require 'commands.where'
|
|
12
control.lua
12
control.lua
@ -5,6 +5,7 @@ _DUMP_ENV = false
|
|||||||
|
|
||||||
require 'utils.server'
|
require 'utils.server'
|
||||||
require 'utils.server_commands'
|
require 'utils.server_commands'
|
||||||
|
require 'utils.command_handler'
|
||||||
require 'utils.utils'
|
require 'utils.utils'
|
||||||
require 'utils.pause_game'
|
require 'utils.pause_game'
|
||||||
require 'utils.table'
|
require 'utils.table'
|
||||||
@ -18,14 +19,15 @@ require 'utils.datastore.quickbar_data'
|
|||||||
require 'utils.datastore.message_on_join_data'
|
require 'utils.datastore.message_on_join_data'
|
||||||
require 'utils.datastore.player_tag_data'
|
require 'utils.datastore.player_tag_data'
|
||||||
require 'utils.datastore.supporters'
|
require 'utils.datastore.supporters'
|
||||||
require 'chatbot'
|
require 'utils.chatbot'
|
||||||
require 'commands'
|
require 'utils.commands'
|
||||||
require 'antigrief'
|
require 'utils.antigrief'
|
||||||
|
require 'utils.debug.command'
|
||||||
require 'modules.corpse_markers'
|
require 'modules.corpse_markers'
|
||||||
require 'modules.floaty_chat'
|
require 'modules.floaty_chat'
|
||||||
require 'modules.show_inventory'
|
require 'modules.show_inventory'
|
||||||
require 'modules.inserter_drops_pickup'
|
require 'modules.inserter_drops_pickup'
|
||||||
require 'utils.debug.command'
|
require 'modules.autostash'
|
||||||
|
|
||||||
require 'comfy_panel.main'
|
require 'comfy_panel.main'
|
||||||
require 'comfy_panel.player_list'
|
require 'comfy_panel.player_list'
|
||||||
@ -35,8 +37,6 @@ require 'comfy_panel.poll'
|
|||||||
require 'comfy_panel.score'
|
require 'comfy_panel.score'
|
||||||
require 'comfy_panel.config'
|
require 'comfy_panel.config'
|
||||||
|
|
||||||
require 'modules.autostash'
|
|
||||||
|
|
||||||
---------------- !ENABLE MODULES HERE ----------------
|
---------------- !ENABLE MODULES HERE ----------------
|
||||||
--require 'modules.admins_operate_biters'
|
--require 'modules.admins_operate_biters'
|
||||||
--require 'modules.the_floor_is_lava'
|
--require 'modules.the_floor_is_lava'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
local Server = require 'utils.server'
|
local Server = require 'utils.server'
|
||||||
local Modifiers = require 'player_modifiers'
|
local Modifiers = require 'utils.player_modifiers'
|
||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ require 'modules.dangerous_goods'
|
|||||||
require 'modules.custom_death_messages'
|
require 'modules.custom_death_messages'
|
||||||
require 'modules.launch_fish_to_win'
|
require 'modules.launch_fish_to_win'
|
||||||
|
|
||||||
local AntiGrief = require 'antigrief'
|
local AntiGrief = require 'utils.antigrief'
|
||||||
local Terrain = require 'maps.fish_defender.terrain'
|
local Terrain = require 'maps.fish_defender.terrain'
|
||||||
local Unit_health_booster = require 'modules.biter_health_booster'
|
local Unit_health_booster = require 'modules.biter_health_booster'
|
||||||
local Session = require 'utils.datastore.session_data'
|
local Session = require 'utils.datastore.session_data'
|
||||||
|
@ -16,7 +16,7 @@ local Server = require 'utils.server'
|
|||||||
local Session = require 'utils.datastore.session_data'
|
local Session = require 'utils.datastore.session_data'
|
||||||
local Poll = require 'comfy_panel.poll'
|
local Poll = require 'comfy_panel.poll'
|
||||||
local Score = require 'comfy_panel.score'
|
local Score = require 'comfy_panel.score'
|
||||||
local AntiGrief = require 'antigrief'
|
local AntiGrief = require 'utils.antigrief'
|
||||||
local Core = require 'utils.core'
|
local Core = require 'utils.core'
|
||||||
local format_number = require 'util'.format_number
|
local format_number = require 'util'.format_number
|
||||||
local random = math.random
|
local random = math.random
|
||||||
|
@ -31,7 +31,7 @@ local Map = require 'modules.map_info'
|
|||||||
local WD = require 'modules.wave_defense.table'
|
local WD = require 'modules.wave_defense.table'
|
||||||
local Treasure = require 'maps.mountain_fortress_v2.treasure'
|
local Treasure = require 'maps.mountain_fortress_v2.treasure'
|
||||||
local Locomotive = require 'maps.mountain_fortress_v2.locomotive'
|
local Locomotive = require 'maps.mountain_fortress_v2.locomotive'
|
||||||
local Modifier = require 'player_modifiers'
|
local Modifier = require 'utils.player_modifiers'
|
||||||
|
|
||||||
local math_random = math.random
|
local math_random = math.random
|
||||||
local math_abs = math.abs
|
local math_abs = math.abs
|
||||||
|
@ -11,7 +11,7 @@ local Collapse = require 'modules.collapse'
|
|||||||
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||||
local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions'
|
local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions'
|
||||||
local math2d = require 'math2d'
|
local math2d = require 'math2d'
|
||||||
local Misc = require 'commands.misc'
|
local Misc = require 'utils.commands.misc'
|
||||||
|
|
||||||
local this = {
|
local this = {
|
||||||
power_sources = {index = 1},
|
power_sources = {index = 1},
|
||||||
|
@ -448,9 +448,8 @@ local function toggle(player, recreate)
|
|||||||
end
|
end
|
||||||
if main_frame then
|
if main_frame then
|
||||||
remove_main_frame(main_frame)
|
remove_main_frame(main_frame)
|
||||||
Tabs.comfy_panel_restore_left_gui(player)
|
|
||||||
else
|
else
|
||||||
Tabs.comfy_panel_clear_left_gui(player)
|
Tabs.comfy_panel_clear_gui(player)
|
||||||
draw_main_frame(player)
|
draw_main_frame(player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,7 +2,9 @@ local WPT = require 'maps.mountain_fortress_v3.table'
|
|||||||
local Session = require 'utils.datastore.session_data'
|
local Session = require 'utils.datastore.session_data'
|
||||||
local Jailed = require 'utils.datastore.jail_data'
|
local Jailed = require 'utils.datastore.jail_data'
|
||||||
|
|
||||||
local Antigrief = require 'antigrief'
|
local Antigrief = require 'utils.antigrief'
|
||||||
|
|
||||||
|
local required_playtime = 5184000 -- 24 hours
|
||||||
|
|
||||||
local Public = {}
|
local Public = {}
|
||||||
|
|
||||||
@ -131,7 +133,7 @@ function Public.add_player_to_permission_group(player, group, forced)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if playtime < 5184000 then -- 24 hours
|
if playtime < required_playtime then
|
||||||
local not_trusted = game.permissions.get_group('not_trusted')
|
local not_trusted = game.permissions.get_group('not_trusted')
|
||||||
if not player.admin then
|
if not player.admin then
|
||||||
not_trusted.add_player(player)
|
not_trusted.add_player(player)
|
||||||
|
@ -37,9 +37,9 @@ local Task = require 'utils.task'
|
|||||||
local Token = require 'utils.token'
|
local Token = require 'utils.token'
|
||||||
local Alert = require 'utils.alert'
|
local Alert = require 'utils.alert'
|
||||||
local BottomFrame = require 'comfy_panel.bottom_frame'
|
local BottomFrame = require 'comfy_panel.bottom_frame'
|
||||||
local AntiGrief = require 'antigrief'
|
local AntiGrief = require 'utils.antigrief'
|
||||||
local Misc = require 'commands.misc'
|
local Misc = require 'utils.commands.misc'
|
||||||
local Modifiers = require 'player_modifiers'
|
local Modifiers = require 'utils.player_modifiers'
|
||||||
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
|
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
|
||||||
local Reset = require 'functions.soft_reset'
|
local Reset = require 'functions.soft_reset'
|
||||||
local JailData = require 'utils.datastore.jail_data'
|
local JailData = require 'utils.datastore.jail_data'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
local Server = require 'utils.server'
|
local Server = require 'utils.server'
|
||||||
local Session = require 'utils.datastore.session_data'
|
local Session = require 'utils.datastore.session_data'
|
||||||
local Modifers = require 'player_modifiers'
|
local Modifers = require 'utils.player_modifiers'
|
||||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||||
|
|
||||||
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
|
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
|
||||||
|
@ -19,7 +19,7 @@ local Poll = require 'comfy_panel.poll'
|
|||||||
local boss_biter = require 'maps.pidgeotto.boss_biters'
|
local boss_biter = require 'maps.pidgeotto.boss_biters'
|
||||||
local FDT = require 'maps.pidgeotto.table'
|
local FDT = require 'maps.pidgeotto.table'
|
||||||
local Score = require 'comfy_panel.score'
|
local Score = require 'comfy_panel.score'
|
||||||
local AntiGrief = require 'antigrief'
|
local AntiGrief = require 'utils.antigrief'
|
||||||
local math_random = math.random
|
local math_random = math.random
|
||||||
local insert = table.insert
|
local insert = table.insert
|
||||||
local enable_start_grace_period = true
|
local enable_start_grace_period = true
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Modifier = require 'player_modifiers'
|
local Modifier = require 'utils.player_modifiers'
|
||||||
local Color = require 'utils.color_presets'
|
local Color = require 'utils.color_presets'
|
||||||
|
|
||||||
local function validate_player(player)
|
local function validate_player(player)
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
-- hunger module by mewmew --
|
-- hunger module by mewmew --
|
||||||
|
|
||||||
local P = require 'player_modifiers'
|
local P = require 'utils.player_modifiers'
|
||||||
|
|
||||||
local starve_messages = {' ran out of foodstamps.', ' starved.', ' should not have skipped breakfast today.'}
|
local starve_messages = {' ran out of foodstamps.', ' starved.', ' should not have skipped breakfast today.'}
|
||||||
|
|
||||||
local overfeed_messages = {' ate too much and exploded.', ' needs to work on their bad eating habbits.', ' should have skipped dinner today.', ' forgot to count them calories.'}
|
local overfeed_messages = {
|
||||||
|
' ate too much and exploded.',
|
||||||
|
' needs to work on their bad eating habbits.',
|
||||||
|
' should have skipped dinner today.',
|
||||||
|
' forgot to count them calories.'
|
||||||
|
}
|
||||||
|
|
||||||
local player_hunger_fish_food_value = 10
|
local player_hunger_fish_food_value = 10
|
||||||
local player_hunger_spawn_value = 80
|
local player_hunger_spawn_value = 80
|
||||||
|
@ -18,7 +18,7 @@ local math_sqrt = math.sqrt
|
|||||||
local math_floor = math.floor
|
local math_floor = math.floor
|
||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
local Tabs = require 'comfy_panel.main'
|
local Tabs = require 'comfy_panel.main'
|
||||||
local P = require 'player_modifiers'
|
local P = require 'utils.player_modifiers'
|
||||||
local visuals_delay = 1800
|
local visuals_delay = 1800
|
||||||
local level_up_floating_text_color = {0, 205, 0}
|
local level_up_floating_text_color = {0, 205, 0}
|
||||||
local xp_floating_text_color = {157, 157, 157}
|
local xp_floating_text_color = {157, 157, 157}
|
||||||
@ -251,7 +251,7 @@ local function draw_gui(player, forced)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Tabs.comfy_panel_clear_left_gui(player)
|
Tabs.comfy_panel_clear_gui(player)
|
||||||
|
|
||||||
if player.gui.left.rpg then
|
if player.gui.left.rpg then
|
||||||
player.gui.left.rpg.destroy()
|
player.gui.left.rpg.destroy()
|
||||||
@ -755,7 +755,12 @@ local function one_punch(character, target, damage)
|
|||||||
vector[2] = vector[2] * 1000
|
vector[2] = vector[2] * 1000
|
||||||
|
|
||||||
character.surface.create_entity(
|
character.surface.create_entity(
|
||||||
{name = 'flying-text', position = {character.position.x + base_vector[1] * 0.5, character.position.y + base_vector[2] * 0.5}, text = 'ONE PUNCH', color = {255, 0, 0}}
|
{
|
||||||
|
name = 'flying-text',
|
||||||
|
position = {character.position.x + base_vector[1] * 0.5, character.position.y + base_vector[2] * 0.5},
|
||||||
|
text = 'ONE PUNCH',
|
||||||
|
color = {255, 0, 0}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
character.surface.create_entity({name = 'blood-explosion-huge', position = target.position})
|
character.surface.create_entity({name = 'blood-explosion-huge', position = target.position})
|
||||||
character.surface.create_entity({name = 'big-artillery-explosion', position = {target.position.x + vector[1] * 0.5, target.position.y + vector[2] * 0.5}})
|
character.surface.create_entity({name = 'big-artillery-explosion', position = {target.position.x + vector[1] * 0.5, target.position.y + vector[2] * 0.5}})
|
||||||
@ -868,7 +873,9 @@ local function on_entity_damaged(event)
|
|||||||
event.cause.surface.create_entity({name = 'blood-explosion-huge', position = event.entity.position})
|
event.cause.surface.create_entity({name = 'blood-explosion-huge', position = event.entity.position})
|
||||||
else
|
else
|
||||||
damage = damage * math_random(100, 125) * 0.01
|
damage = damage * math_random(100, 125) * 0.01
|
||||||
event.cause.player.create_local_flying_text({text = math.floor(damage), position = event.entity.position, color = {150, 150, 150}, time_to_live = 90, speed = 2})
|
event.cause.player.create_local_flying_text(
|
||||||
|
{text = math.floor(damage), position = event.entity.position, color = {150, 150, 150}, time_to_live = 90, speed = 2}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
--Handle the custom health pool of the biter health booster, if it is used in the map.
|
--Handle the custom health pool of the biter health booster, if it is used in the map.
|
||||||
@ -953,7 +960,10 @@ local function on_pre_player_mined_item(event)
|
|||||||
end
|
end
|
||||||
local player = game.players[event.player_index]
|
local player = game.players[event.player_index]
|
||||||
|
|
||||||
if rpg_t[player.index].last_mined_entity_position.x == event.entity.position.x and rpg_t[player.index].last_mined_entity_position.y == event.entity.position.y then
|
if
|
||||||
|
rpg_t[player.index].last_mined_entity_position.x == event.entity.position.x and
|
||||||
|
rpg_t[player.index].last_mined_entity_position.y == event.entity.position.y
|
||||||
|
then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
rpg_t[player.index].last_mined_entity_position.x = entity.position.x
|
rpg_t[player.index].last_mined_entity_position.x = entity.position.x
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
local ComfyGui = require 'comfy_panel.main'
|
local ComfyGui = require 'comfy_panel.main'
|
||||||
local Session = require 'utils.datastore.session_data'
|
local Session = require 'utils.datastore.session_data'
|
||||||
local P = require 'player_modifiers'
|
local P = require 'utils.player_modifiers'
|
||||||
local Gui = require 'utils.gui'
|
local Gui = require 'utils.gui'
|
||||||
local Color = require 'utils.color_presets'
|
local Color = require 'utils.color_presets'
|
||||||
|
|
||||||
@ -514,9 +514,8 @@ function Public.toggle(player, recreate)
|
|||||||
end
|
end
|
||||||
if main_frame then
|
if main_frame then
|
||||||
remove_main_frame(main_frame, screen)
|
remove_main_frame(main_frame, screen)
|
||||||
ComfyGui.comfy_panel_restore_left_gui(player)
|
|
||||||
else
|
else
|
||||||
ComfyGui.comfy_panel_clear_left_gui(player)
|
ComfyGui.comfy_panel_clear_gui(player)
|
||||||
draw_main_frame(player)
|
draw_main_frame(player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -527,7 +526,6 @@ function Public.remove_frame(player)
|
|||||||
|
|
||||||
if main_frame then
|
if main_frame then
|
||||||
remove_main_frame(main_frame, screen)
|
remove_main_frame(main_frame, screen)
|
||||||
ComfyGui.comfy_panel_restore_left_gui(player)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
local Public = require 'modules.rpg.core'
|
local Public = require 'modules.rpg.core'
|
||||||
local Gui = require 'utils.gui'
|
local Gui = require 'utils.gui'
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local AntiGrief = require 'antigrief'
|
local AntiGrief = require 'utils.antigrief'
|
||||||
local Color = require 'utils.color_presets'
|
local Color = require 'utils.color_presets'
|
||||||
local SpamProtection = require 'utils.spam_protection'
|
local SpamProtection = require 'utils.spam_protection'
|
||||||
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
|
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
local Public = require 'modules.rpg.table'
|
local Public = require 'modules.rpg.table'
|
||||||
local Gui = require 'utils.gui'
|
local Gui = require 'utils.gui'
|
||||||
local P = require 'player_modifiers'
|
local P = require 'utils.player_modifiers'
|
||||||
local Session = require 'utils.datastore.session_data'
|
local Session = require 'utils.datastore.session_data'
|
||||||
|
|
||||||
local settings_frame_name = Public.settings_frame_name
|
local settings_frame_name = Public.settings_frame_name
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
--Players will have to carry water barrels or stand next to a water tile, to keep themselves hydrated!
|
--Players will have to carry water barrels or stand next to a water tile, to keep themselves hydrated!
|
||||||
|
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Player_modifiers = require 'player_modifiers'
|
local Player_modifiers = require 'utils.player_modifiers'
|
||||||
local random = math.random
|
local random = math.random
|
||||||
local tooltip = 'How thirsty your character is.\nStand next to water,\nor keep water-barrels in your inventory to take a sip.'
|
local tooltip = 'How thirsty your character is.\nStand next to water,\nor keep water-barrels in your inventory to take a sip.'
|
||||||
|
|
||||||
|
@ -15,14 +15,14 @@ M0JwPPnzLV+EcxobVOmRrEX45fZ5NCQz6S4h3qIRV18Vpu32sQNs
|
|||||||
8kwoXSdIr1kvNPjEJXfhPwM3fGG70zbN7n+hUH+/4j8HgVljp7wD
|
8kwoXSdIr1kvNPjEJXfhPwM3fGG70zbN7n+hUH+/4j8HgVljp7wD
|
||||||
VXdsJuZ76VsGvWeHyfNjW7REoyhvvvAetn9CzJb1cQ=<<<
|
VXdsJuZ76VsGvWeHyfNjW7REoyhvvvAetn9CzJb1cQ=<<<
|
||||||
]]
|
]]
|
||||||
require 'player_modifiers'
|
require 'utils.player_modifiers'
|
||||||
require 'modules.rocks_broken_paint_tiles'
|
require 'modules.rocks_broken_paint_tiles'
|
||||||
require 'modules.rocks_heal_over_time'
|
require 'modules.rocks_heal_over_time'
|
||||||
require 'modules.rocks_yield_ore_veins'
|
require 'modules.rocks_yield_ore_veins'
|
||||||
require 'modules.no_deconstruction_of_neutral_entities'
|
require 'modules.no_deconstruction_of_neutral_entities'
|
||||||
|
|
||||||
local get_noise = require 'utils.get_noise'
|
local get_noise = require 'utils.get_noise'
|
||||||
local Player_modifiers = require 'player_modifiers'
|
local Player_modifiers = require 'utils.player_modifiers'
|
||||||
local math_random = math.random
|
local math_random = math.random
|
||||||
local math_floor = math.floor
|
local math_floor = math.floor
|
||||||
local math_abs = math.abs
|
local math_abs = math.abs
|
||||||
|
@ -17,6 +17,9 @@ local capsule_bomb_threshold = 8
|
|||||||
local de = defines.events
|
local de = defines.events
|
||||||
|
|
||||||
local format = string.format
|
local format = string.format
|
||||||
|
local floor = math.floor
|
||||||
|
local random = math.random
|
||||||
|
local abs = math.abs
|
||||||
|
|
||||||
local this = {
|
local this = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
@ -126,14 +129,14 @@ local function damage_player(player, kill, print_to_all)
|
|||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
player.character.health = player.character.health - math.random(50, 100)
|
player.character.health = player.character.health - random(50, 100)
|
||||||
player.character.surface.create_entity({name = 'water-splash', position = player.position})
|
player.character.surface.create_entity({name = 'water-splash', position = player.position})
|
||||||
local messages = {
|
local messages = {
|
||||||
'Ouch.. That hurt! Better be careful now.',
|
'Ouch.. That hurt! Better be careful now.',
|
||||||
'Just a fleshwound.',
|
'Just a fleshwound.',
|
||||||
'Better keep those hands to yourself or you might loose them.'
|
'Better keep those hands to yourself or you might loose them.'
|
||||||
}
|
}
|
||||||
player.print(messages[math.random(1, #messages)], Color.yellow)
|
player.print(messages[random(1, #messages)], Color.yellow)
|
||||||
if player.character.health <= 0 then
|
if player.character.health <= 0 then
|
||||||
player.character.die('enemy')
|
player.character.die('enemy')
|
||||||
game.print(player.name .. msg, Color.yellow)
|
game.print(player.name .. msg, Color.yellow)
|
||||||
@ -185,7 +188,7 @@ local function on_marked_for_deconstruction(event)
|
|||||||
if Session.get_session_player(player.name) then
|
if Session.get_session_player(player.name) then
|
||||||
playtime = player.online_time + Session.get_session_player(player.name)
|
playtime = player.online_time + Session.get_session_player(player.name)
|
||||||
end
|
end
|
||||||
if playtime < 2592000 then
|
if playtime < this.required_playtime then
|
||||||
event.entity.cancel_deconstruction(game.get_player(event.player_index).force.name)
|
event.entity.cancel_deconstruction(game.get_player(event.player_index).force.name)
|
||||||
player.print('You have not grown accustomed to this technology yet.', {r = 0.22, g = 0.99, b = 0.99})
|
player.print('You have not grown accustomed to this technology yet.', {r = 0.22, g = 0.99, b = 0.99})
|
||||||
end
|
end
|
||||||
@ -208,7 +211,7 @@ local function on_player_ammo_inventory_changed(event)
|
|||||||
if Session.get_session_player(player.name) then
|
if Session.get_session_player(player.name) then
|
||||||
playtime = player.online_time + Session.get_session_player(player.name)
|
playtime = player.online_time + Session.get_session_player(player.name)
|
||||||
end
|
end
|
||||||
if playtime < 1296000 then
|
if playtime < this.required_playtime then
|
||||||
if this.enable_capsule_cursor_warning then
|
if this.enable_capsule_cursor_warning then
|
||||||
local nukes = player.remove_item({name = 'atomic-bomb', count = 1000})
|
local nukes = player.remove_item({name = 'atomic-bomb', count = 1000})
|
||||||
if nukes > 0 then
|
if nukes > 0 then
|
||||||
@ -254,7 +257,7 @@ local function on_player_built_tile(event)
|
|||||||
if #this.landfill_history > this.limit then
|
if #this.landfill_history > this.limit then
|
||||||
this.landfill_history = {}
|
this.landfill_history = {}
|
||||||
end
|
end
|
||||||
local t = math.abs(math.floor((game.tick) / 60))
|
local t = abs(floor((game.tick) / 60))
|
||||||
t = FancyTime.short_fancy_time(t)
|
t = FancyTime.short_fancy_time(t)
|
||||||
local str = '[' .. t .. '] '
|
local str = '[' .. t .. '] '
|
||||||
str = str .. player.name .. ' at X:'
|
str = str .. player.name .. ' at X:'
|
||||||
@ -271,11 +274,9 @@ local function on_built_entity(event)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if game.tick < 1296000 then
|
local created_entity = event.created_entity
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if event.created_entity.type == 'entity-ghost' then
|
if created_entity.type == 'entity-ghost' then
|
||||||
local player = game.get_player(event.player_index)
|
local player = game.get_player(event.player_index)
|
||||||
|
|
||||||
if player.admin then
|
if player.admin then
|
||||||
@ -290,8 +291,8 @@ local function on_built_entity(event)
|
|||||||
playtime = player.online_time + Session.get_session_player(player.name)
|
playtime = player.online_time + Session.get_session_player(player.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
if playtime < 432000 then
|
if playtime < this.required_playtime then
|
||||||
event.created_entity.destroy()
|
created_entity.destroy()
|
||||||
player.print('You have not grown accustomed to this technology yet.', {r = 0.22, g = 0.99, b = 0.99})
|
player.print('You have not grown accustomed to this technology yet.', {r = 0.22, g = 0.99, b = 0.99})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -344,7 +345,12 @@ local function on_player_used_capsule(event)
|
|||||||
|
|
||||||
local prefix = '[Capsule]'
|
local prefix = '[Capsule]'
|
||||||
msg = format(player.name .. ' damaged: %s with: %s', get_entities(name, entities), name)
|
msg = format(player.name .. ' damaged: %s with: %s', get_entities(name, entities), name)
|
||||||
local ban_msg = format('Damaged: %s with: %s. This action was performed automatically. Visit getcomfy.eu/discord for forgiveness', get_entities(name, entities), name)
|
local ban_msg =
|
||||||
|
format(
|
||||||
|
'Damaged: %s with: %s. This action was performed automatically. Visit getcomfy.eu/discord for forgiveness',
|
||||||
|
get_entities(name, entities),
|
||||||
|
name
|
||||||
|
)
|
||||||
|
|
||||||
do_action(player, prefix, msg, ban_msg, true)
|
do_action(player, prefix, msg, ban_msg, true)
|
||||||
else
|
else
|
||||||
@ -358,14 +364,14 @@ local function on_player_used_capsule(event)
|
|||||||
this.capsule_history = {}
|
this.capsule_history = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local t = math.abs(math.floor((game.tick) / 60))
|
local t = abs(floor((game.tick) / 60))
|
||||||
t = FancyTime.short_fancy_time(t)
|
t = FancyTime.short_fancy_time(t)
|
||||||
local str = '[' .. t .. '] '
|
local str = '[' .. t .. '] '
|
||||||
str = str .. msg
|
str = str .. msg
|
||||||
str = str .. ' at X:'
|
str = str .. ' at X:'
|
||||||
str = str .. math.floor(position.x)
|
str = str .. floor(position.x)
|
||||||
str = str .. ' Y:'
|
str = str .. ' Y:'
|
||||||
str = str .. math.floor(position.y)
|
str = str .. floor(position.y)
|
||||||
str = str .. ' '
|
str = str .. ' '
|
||||||
str = str .. 'surface:' .. player.surface.index
|
str = str .. 'surface:' .. player.surface.index
|
||||||
increment(this.capsule_history, str)
|
increment(this.capsule_history, str)
|
||||||
@ -377,6 +383,7 @@ local function on_entity_died(event)
|
|||||||
if not this.enabled then
|
if not this.enabled then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local cause = event.cause
|
local cause = event.cause
|
||||||
local name
|
local name
|
||||||
|
|
||||||
@ -414,15 +421,15 @@ local function on_entity_died(event)
|
|||||||
chest = '[color=yellow]' .. event.entity.name .. '[/color]'
|
chest = '[color=yellow]' .. event.entity.name .. '[/color]'
|
||||||
end
|
end
|
||||||
|
|
||||||
local t = math.abs(math.floor((game.tick) / 60))
|
local t = abs(floor((game.tick) / 60))
|
||||||
t = FancyTime.short_fancy_time(t)
|
t = FancyTime.short_fancy_time(t)
|
||||||
local str = '[' .. t .. '] '
|
local str = '[' .. t .. '] '
|
||||||
str = str .. name .. ' destroyed '
|
str = str .. name .. ' destroyed '
|
||||||
str = str .. chest
|
str = str .. chest
|
||||||
str = str .. ' at X:'
|
str = str .. ' at X:'
|
||||||
str = str .. math.floor(event.entity.position.x)
|
str = str .. floor(event.entity.position.x)
|
||||||
str = str .. ' Y:'
|
str = str .. ' Y:'
|
||||||
str = str .. math.floor(event.entity.position.y)
|
str = str .. floor(event.entity.position.y)
|
||||||
str = str .. ' '
|
str = str .. ' '
|
||||||
str = str .. 'surface:' .. event.entity.surface.index
|
str = str .. 'surface:' .. event.entity.surface.index
|
||||||
increment(this.friendly_fire_history, str)
|
increment(this.friendly_fire_history, str)
|
||||||
@ -432,7 +439,7 @@ local function on_entity_died(event)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local t = math.abs(math.floor((game.tick) / 60))
|
local t = abs(floor((game.tick) / 60))
|
||||||
t = FancyTime.short_fancy_time(t)
|
t = FancyTime.short_fancy_time(t)
|
||||||
local str = '[' .. t .. '] '
|
local str = '[' .. t .. '] '
|
||||||
if cause and cause.name == 'character' and cause.player then
|
if cause and cause.name == 'character' and cause.player then
|
||||||
@ -442,9 +449,9 @@ local function on_entity_died(event)
|
|||||||
end
|
end
|
||||||
str = str .. '[color=yellow]' .. event.entity.name .. '[/color]'
|
str = str .. '[color=yellow]' .. event.entity.name .. '[/color]'
|
||||||
str = str .. ' at X:'
|
str = str .. ' at X:'
|
||||||
str = str .. math.floor(event.entity.position.x)
|
str = str .. floor(event.entity.position.x)
|
||||||
str = str .. ' Y:'
|
str = str .. ' Y:'
|
||||||
str = str .. math.floor(event.entity.position.y)
|
str = str .. floor(event.entity.position.y)
|
||||||
str = str .. ' '
|
str = str .. ' '
|
||||||
str = str .. 'surface:' .. event.entity.surface.index
|
str = str .. 'surface:' .. event.entity.surface.index
|
||||||
|
|
||||||
@ -478,15 +485,15 @@ local function on_player_mined_entity(event)
|
|||||||
if #this.whitelist_mining_history > this.limit then
|
if #this.whitelist_mining_history > this.limit then
|
||||||
this.whitelist_mining_history = {}
|
this.whitelist_mining_history = {}
|
||||||
end
|
end
|
||||||
local t = math.abs(math.floor((game.tick) / 60))
|
local t = abs(floor((game.tick) / 60))
|
||||||
t = FancyTime.short_fancy_time(t)
|
t = FancyTime.short_fancy_time(t)
|
||||||
local str = '[' .. t .. '] '
|
local str = '[' .. t .. '] '
|
||||||
str = str .. player.name .. ' mined '
|
str = str .. player.name .. ' mined '
|
||||||
str = str .. '[color=yellow]' .. entity.name .. '[/color]'
|
str = str .. '[color=yellow]' .. entity.name .. '[/color]'
|
||||||
str = str .. ' at X:'
|
str = str .. ' at X:'
|
||||||
str = str .. math.floor(entity.position.x)
|
str = str .. floor(entity.position.x)
|
||||||
str = str .. ' Y:'
|
str = str .. ' Y:'
|
||||||
str = str .. math.floor(entity.position.y)
|
str = str .. floor(entity.position.y)
|
||||||
str = str .. ' '
|
str = str .. ' '
|
||||||
str = str .. 'surface:' .. entity.surface.index
|
str = str .. 'surface:' .. entity.surface.index
|
||||||
increment(this.whitelist_mining_history, str)
|
increment(this.whitelist_mining_history, str)
|
||||||
@ -513,15 +520,15 @@ local function on_player_mined_entity(event)
|
|||||||
this.mining_history = {}
|
this.mining_history = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local t = math.abs(math.floor((game.tick) / 60))
|
local t = abs(floor((game.tick) / 60))
|
||||||
t = FancyTime.short_fancy_time(t)
|
t = FancyTime.short_fancy_time(t)
|
||||||
local str = '[' .. t .. '] '
|
local str = '[' .. t .. '] '
|
||||||
str = str .. player.name .. ' mined '
|
str = str .. player.name .. ' mined '
|
||||||
str = str .. '[color=yellow]' .. event.entity.name .. '[/color]'
|
str = str .. '[color=yellow]' .. event.entity.name .. '[/color]'
|
||||||
str = str .. ' at X:'
|
str = str .. ' at X:'
|
||||||
str = str .. math.floor(event.entity.position.x)
|
str = str .. floor(event.entity.position.x)
|
||||||
str = str .. ' Y:'
|
str = str .. ' Y:'
|
||||||
str = str .. math.floor(event.entity.position.y)
|
str = str .. floor(event.entity.position.y)
|
||||||
str = str .. ' '
|
str = str .. ' '
|
||||||
str = str .. 'surface:' .. event.entity.surface.index
|
str = str .. 'surface:' .. event.entity.surface.index
|
||||||
increment(this.mining_history, str)
|
increment(this.mining_history, str)
|
||||||
@ -561,15 +568,15 @@ local function on_gui_opened(event)
|
|||||||
this.corpse_history = {}
|
this.corpse_history = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local t = math.abs(math.floor((game.tick) / 60))
|
local t = abs(floor((game.tick) / 60))
|
||||||
t = FancyTime.short_fancy_time(t)
|
t = FancyTime.short_fancy_time(t)
|
||||||
local str = '[' .. t .. '] '
|
local str = '[' .. t .. '] '
|
||||||
str = str .. player.name .. ' opened '
|
str = str .. player.name .. ' opened '
|
||||||
str = str .. '[color=yellow]' .. corpse_owner.name .. '[/color] body'
|
str = str .. '[color=yellow]' .. corpse_owner.name .. '[/color] body'
|
||||||
str = str .. ' at X:'
|
str = str .. ' at X:'
|
||||||
str = str .. math.floor(event.entity.position.x)
|
str = str .. floor(event.entity.position.x)
|
||||||
str = str .. ' Y:'
|
str = str .. ' Y:'
|
||||||
str = str .. math.floor(event.entity.position.y)
|
str = str .. floor(event.entity.position.y)
|
||||||
str = str .. ' '
|
str = str .. ' '
|
||||||
str = str .. 'surface:' .. event.entity.surface.index
|
str = str .. 'surface:' .. event.entity.surface.index
|
||||||
increment(this.corpse_history, str)
|
increment(this.corpse_history, str)
|
||||||
@ -616,15 +623,15 @@ local function on_pre_player_mined_item(event)
|
|||||||
this.corpse_history = {}
|
this.corpse_history = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local t = math.abs(math.floor((game.tick) / 60))
|
local t = abs(floor((game.tick) / 60))
|
||||||
t = FancyTime.short_fancy_time(t)
|
t = FancyTime.short_fancy_time(t)
|
||||||
local str = '[' .. t .. '] '
|
local str = '[' .. t .. '] '
|
||||||
str = str .. player.name .. ' mined '
|
str = str .. player.name .. ' mined '
|
||||||
str = str .. '[color=yellow]' .. corpse_owner.name .. '[/color] body'
|
str = str .. '[color=yellow]' .. corpse_owner.name .. '[/color] body'
|
||||||
str = str .. ' at X:'
|
str = str .. ' at X:'
|
||||||
str = str .. math.floor(entity.position.x)
|
str = str .. floor(entity.position.x)
|
||||||
str = str .. ' Y:'
|
str = str .. ' Y:'
|
||||||
str = str .. math.floor(entity.position.y)
|
str = str .. floor(entity.position.y)
|
||||||
str = str .. ' '
|
str = str .. ' '
|
||||||
str = str .. 'surface:' .. entity.surface.index
|
str = str .. 'surface:' .. entity.surface.index
|
||||||
increment(this.corpse_history, str)
|
increment(this.corpse_history, str)
|
||||||
@ -644,7 +651,7 @@ local function on_console_chat(event)
|
|||||||
this.message_history = {}
|
this.message_history = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local t = math.abs(math.floor((game.tick) / 60))
|
local t = abs(floor((game.tick) / 60))
|
||||||
t = FancyTime.short_fancy_time(t)
|
t = FancyTime.short_fancy_time(t)
|
||||||
local message = event.message
|
local message = event.message
|
||||||
local str = '[' .. t .. '] '
|
local str = '[' .. t .. '] '
|
||||||
@ -683,7 +690,7 @@ local function on_player_cursor_stack_changed(event)
|
|||||||
playtime = player.online_time + Session.get_session_player(player.name)
|
playtime = player.online_time + Session.get_session_player(player.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
if playtime < 1296000 then
|
if playtime < this.required_playtime then
|
||||||
if this.enable_capsule_cursor_warning then
|
if this.enable_capsule_cursor_warning then
|
||||||
if ammo_names[name] then
|
if ammo_names[name] then
|
||||||
local item_to_remove = player.remove_item({name = name, count = 1000})
|
local item_to_remove = player.remove_item({name = name, count = 1000})
|
||||||
@ -719,7 +726,8 @@ local function on_player_cancelled_crafting(event)
|
|||||||
'[Crafting]',
|
'[Crafting]',
|
||||||
player.name ..
|
player.name ..
|
||||||
' canceled their craft of item ' ..
|
' canceled their craft of item ' ..
|
||||||
event.recipe.name .. ' of total count ' .. crafting_queue_item_count .. ' in raw items (' .. crafted_items .. ' slots) but had no inventory left.'
|
event.recipe.name ..
|
||||||
|
' of total count ' .. crafting_queue_item_count .. ' in raw items (' .. crafted_items .. ' slots) but had no inventory left.'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -730,16 +738,16 @@ local function on_player_cancelled_crafting(event)
|
|||||||
this.cancel_crafting_history = {}
|
this.cancel_crafting_history = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local t = math.abs(math.floor((game.tick) / 60))
|
local t = abs(floor((game.tick) / 60))
|
||||||
t = FancyTime.short_fancy_time(t)
|
t = FancyTime.short_fancy_time(t)
|
||||||
local str = '[' .. t .. '] '
|
local str = '[' .. t .. '] '
|
||||||
str = str .. player.name .. ' canceled '
|
str = str .. player.name .. ' canceled '
|
||||||
str = str .. ' item [color=yellow]' .. event.recipe.name .. '[/color]'
|
str = str .. ' item [color=yellow]' .. event.recipe.name .. '[/color]'
|
||||||
str = str .. ' count was a total of: ' .. crafting_queue_item_count
|
str = str .. ' count was a total of: ' .. crafting_queue_item_count
|
||||||
str = str .. ' at X:'
|
str = str .. ' at X:'
|
||||||
str = str .. math.floor(player.position.x)
|
str = str .. floor(player.position.x)
|
||||||
str = str .. ' Y:'
|
str = str .. ' Y:'
|
||||||
str = str .. math.floor(player.position.y)
|
str = str .. floor(player.position.y)
|
||||||
str = str .. ' '
|
str = str .. ' '
|
||||||
str = str .. 'surface:' .. player.surface.index
|
str = str .. 'surface:' .. player.surface.index
|
||||||
increment(this.cancel_crafting_history, str)
|
increment(this.cancel_crafting_history, str)
|
||||||
@ -853,14 +861,14 @@ function Public.insert_into_capsule_history(player, position, msg)
|
|||||||
if #this.capsule_history > this.limit then
|
if #this.capsule_history > this.limit then
|
||||||
this.capsule_history = {}
|
this.capsule_history = {}
|
||||||
end
|
end
|
||||||
local t = math.abs(math.floor((game.tick) / 60))
|
local t = abs(floor((game.tick) / 60))
|
||||||
t = FancyTime.short_fancy_time(t)
|
t = FancyTime.short_fancy_time(t)
|
||||||
local str = '[' .. t .. '] '
|
local str = '[' .. t .. '] '
|
||||||
str = str .. '[color=yellow]' .. msg .. '[/color]'
|
str = str .. '[color=yellow]' .. msg .. '[/color]'
|
||||||
str = str .. ' at X:'
|
str = str .. ' at X:'
|
||||||
str = str .. math.floor(position.x)
|
str = str .. floor(position.x)
|
||||||
str = str .. ' Y:'
|
str = str .. ' Y:'
|
||||||
str = str .. math.floor(position.y)
|
str = str .. floor(position.y)
|
||||||
str = str .. ' '
|
str = str .. ' '
|
||||||
str = str .. 'surface:' .. player.surface.index
|
str = str .. 'surface:' .. player.surface.index
|
||||||
increment(this.capsule_history, str)
|
increment(this.capsule_history, str)
|
||||||
@ -964,6 +972,6 @@ Event.add(de.on_permission_group_added, on_permission_group_added)
|
|||||||
Event.add(de.on_permission_group_deleted, on_permission_group_deleted)
|
Event.add(de.on_permission_group_deleted, on_permission_group_deleted)
|
||||||
Event.add(de.on_permission_group_edited, on_permission_group_edited)
|
Event.add(de.on_permission_group_edited, on_permission_group_edited)
|
||||||
Event.add(de.on_permission_string_imported, on_permission_string_imported)
|
Event.add(de.on_permission_string_imported, on_permission_string_imported)
|
||||||
Event.add(defines.events.on_console_chat, on_console_chat)
|
Event.add(de.on_console_chat, on_console_chat)
|
||||||
|
|
||||||
return Public
|
return Public
|
88
utils/chatbot.lua
Normal file
88
utils/chatbot.lua
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
local Event = require 'utils.event'
|
||||||
|
local Server = require 'utils.server'
|
||||||
|
local Color = require 'utils.color_presets'
|
||||||
|
|
||||||
|
local font_color = Color.warning
|
||||||
|
local font_welcome = {r = 150, g = 100, b = 255, a = 255}
|
||||||
|
local font = 'default-game'
|
||||||
|
|
||||||
|
|
||||||
|
local brain = {
|
||||||
|
[1] = {'Our Discord server is at: https://getcomfy.eu/discord'},
|
||||||
|
[2] = {
|
||||||
|
'Need an admin? Join our discord at: https://getcomfy.eu/discord,',
|
||||||
|
'and report it in #i-need-halp',
|
||||||
|
'If you have played for more than 5h in our maps then,',
|
||||||
|
'you are eligible to run the command /jail and /free'
|
||||||
|
},
|
||||||
|
[3] = {'Scenario repository for download:', 'https://github.com/ComfyFactory/ComfyFactorio'},
|
||||||
|
[4] = {
|
||||||
|
'If you feel like the server is lagging, run the following command:',
|
||||||
|
'/server-ups',
|
||||||
|
'This will display the server UPS on your top right screen.'
|
||||||
|
},
|
||||||
|
[5] = {
|
||||||
|
"If you're not trusted - ask an admin to trust you."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
local links = {
|
||||||
|
['admin'] = brain[2],
|
||||||
|
['administrator'] = brain[2],
|
||||||
|
['discord'] = brain[1],
|
||||||
|
['download'] = brain[3],
|
||||||
|
['github'] = brain[3],
|
||||||
|
['greifer'] = brain[2],
|
||||||
|
['grief'] = brain[2],
|
||||||
|
['griefer'] = brain[2],
|
||||||
|
['griefing'] = brain[2],
|
||||||
|
['mod'] = brain[2],
|
||||||
|
['moderator'] = brain[2],
|
||||||
|
['scenario'] = brain[3],
|
||||||
|
['stealing'] = brain[2],
|
||||||
|
['stole'] = brain[2],
|
||||||
|
['troll'] = brain[2],
|
||||||
|
['lag'] = brain[4],
|
||||||
|
['lagging'] = brain[4],
|
||||||
|
['trust'] = brain[5],
|
||||||
|
['trusted'] = brain[5],
|
||||||
|
['untrusted'] = brain[5]
|
||||||
|
}
|
||||||
|
|
||||||
|
local function on_player_created(event)
|
||||||
|
local player = game.players[event.player_index]
|
||||||
|
player.print('[font=' .. font .. ']' .. 'Join the comfy discord >> getcomfy.eu/discord' .. '[/font]', font_welcome)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function process_bot_answers(event)
|
||||||
|
local player = game.players[event.player_index]
|
||||||
|
if player.admin then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local message = event.message
|
||||||
|
message = string.lower(message)
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_console_chat(event)
|
||||||
|
if not event.player_index then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local secs = Server.get_current_time()
|
||||||
|
if not secs then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
process_bot_answers(event)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Event.add(defines.events.on_player_created, on_player_created)
|
||||||
|
Event.add(defines.events.on_console_chat, on_console_chat)
|
60
utils/command_handler.lua
Normal file
60
utils/command_handler.lua
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
local Event = require 'utils.event'
|
||||||
|
local Server = require 'utils.server'
|
||||||
|
local Timestamp = require 'utils.timestamp'
|
||||||
|
local format = string.format
|
||||||
|
|
||||||
|
local function on_console_command(event)
|
||||||
|
local cmd = event.command
|
||||||
|
if not event.player_index then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local player = game.players[event.player_index]
|
||||||
|
local param = event.parameters
|
||||||
|
|
||||||
|
if not player.admin then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local server_time = Server.get_current_time()
|
||||||
|
if server_time then
|
||||||
|
server_time = format(' (Server time: %s)', Timestamp.to_string(server_time))
|
||||||
|
else
|
||||||
|
server_time = ' at tick: ' .. game.tick
|
||||||
|
end
|
||||||
|
|
||||||
|
if string.len(param) <= 0 then
|
||||||
|
param = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local commands = {
|
||||||
|
['editor'] = true,
|
||||||
|
['command'] = true,
|
||||||
|
['silent-command'] = true,
|
||||||
|
['sc'] = true,
|
||||||
|
['debug'] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if not commands[cmd] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if player then
|
||||||
|
if param then
|
||||||
|
print('[COMMAND HANDLER] ' .. player.name .. ' ran: ' .. cmd .. ' "' .. param .. '" ' .. server_time)
|
||||||
|
return
|
||||||
|
else
|
||||||
|
print('[COMMAND HANDLER] ' .. player.name .. ' ran: ' .. cmd .. server_time)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if param then
|
||||||
|
print('[COMMAND HANDLER] ran: ' .. cmd .. ' "' .. param .. '" ' .. server_time)
|
||||||
|
return
|
||||||
|
else
|
||||||
|
print('[COMMAND HANDLER] ran: ' .. cmd .. server_time)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Event.add(defines.events.on_console_command, on_console_command)
|
3
utils/commands.lua
Normal file
3
utils/commands.lua
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
require 'utils.commands.trust_system'
|
||||||
|
require 'utils.commands.misc'
|
||||||
|
require 'utils.commands.where'
|
@ -1,5 +1,5 @@
|
|||||||
local Session = require 'utils.datastore.session_data'
|
local Session = require 'utils.datastore.session_data'
|
||||||
local Modifiers = require 'player_modifiers'
|
local Modifiers = require 'utils.player_modifiers'
|
||||||
local Server = require 'utils.server'
|
local Server = require 'utils.server'
|
||||||
local Color = require 'utils.color_presets'
|
local Color = require 'utils.color_presets'
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
@ -239,7 +239,10 @@ commands.add_command(
|
|||||||
end
|
end
|
||||||
if not this.creative_are_you_sure then
|
if not this.creative_are_you_sure then
|
||||||
this.creative_are_you_sure = true
|
this.creative_are_you_sure = true
|
||||||
player.print('[WARNING] This command will enable creative/cheat-mode for all connected players, run this command again if you really want to do this!', Color.yellow)
|
player.print(
|
||||||
|
'[WARNING] This command will enable creative/cheat-mode for all connected players, run this command again if you really want to do this!',
|
||||||
|
Color.yellow
|
||||||
|
)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if this.creative_enabled then
|
if this.creative_enabled then
|
111
utils/commands/trust_system.lua
Normal file
111
utils/commands/trust_system.lua
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
local Event = require 'utils.event'
|
||||||
|
local Session = require 'utils.datastore.session_data'
|
||||||
|
|
||||||
|
commands.add_command(
|
||||||
|
'trust',
|
||||||
|
'Promotes a player to trusted!',
|
||||||
|
function(cmd)
|
||||||
|
local trusted = Session.get_trusted_table()
|
||||||
|
local player = game.player
|
||||||
|
|
||||||
|
if player and player.valid then
|
||||||
|
if not player.admin then
|
||||||
|
player.print("You're not admin!", {r = 1, g = 0.5, b = 0.1})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if cmd.parameter == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local target_player = game.get_player(cmd.parameter)
|
||||||
|
if target_player then
|
||||||
|
if trusted[target_player.name] then
|
||||||
|
game.print(target_player.name .. ' is already trusted!')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
trusted[target_player.name] = true
|
||||||
|
game.print(target_player.name .. ' is now a trusted player.', {r = 0.22, g = 0.99, b = 0.99})
|
||||||
|
for _, a in pairs(game.connected_players) do
|
||||||
|
if a.admin and a.name ~= player.name then
|
||||||
|
a.print('[ADMIN]: ' .. player.name .. ' trusted ' .. target_player.name, {r = 1, g = 0.5, b = 0.1})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if cmd.parameter == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local target_player = game.get_player(cmd.parameter)
|
||||||
|
if target_player then
|
||||||
|
if trusted[target_player.name] == true then
|
||||||
|
game.print(target_player.name .. ' is already trusted!')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
trusted[target_player.name] = true
|
||||||
|
game.print(target_player.name .. ' is now a trusted player.', {r = 0.22, g = 0.99, b = 0.99})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
commands.add_command(
|
||||||
|
'untrust',
|
||||||
|
'Demotes a player from trusted!',
|
||||||
|
function(cmd)
|
||||||
|
local trusted = Session.get_trusted_table()
|
||||||
|
local player = game.player
|
||||||
|
|
||||||
|
if player and player.valid then
|
||||||
|
if not player.admin then
|
||||||
|
player.print("You're not admin!", {r = 1, g = 0.5, b = 0.1})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if cmd.parameter == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local target_player = game.get_player(cmd.parameter)
|
||||||
|
if target_player then
|
||||||
|
if trusted[target_player.name] == false then
|
||||||
|
game.print(target_player.name .. ' is already untrusted!')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
trusted[target_player.name] = false
|
||||||
|
game.print(target_player.name .. ' is now untrusted.', {r = 0.22, g = 0.99, b = 0.99})
|
||||||
|
for _, a in pairs(game.connected_players) do
|
||||||
|
if a.admin == true and a.name ~= player.name then
|
||||||
|
a.print('[ADMIN]: ' .. player.name .. ' untrusted ' .. target_player.name, {r = 1, g = 0.5, b = 0.1})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if cmd.parameter == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local target_player = game.get_player(cmd.parameter)
|
||||||
|
if target_player then
|
||||||
|
if trusted[target_player.name] == false then
|
||||||
|
game.print(target_player.name .. ' is already untrusted!')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
trusted[target_player.name] = false
|
||||||
|
game.print(target_player.name .. ' is now untrusted.', {r = 0.22, g = 0.99, b = 0.99})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
Event.add(
|
||||||
|
defines.events.on_player_created,
|
||||||
|
function(event)
|
||||||
|
local player = game.get_player(event.player_index)
|
||||||
|
if not (player and player.valid) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local is_single_player = not game.is_multiplayer()
|
||||||
|
if is_single_player then
|
||||||
|
Session.set_trusted_player(player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
@ -276,7 +276,7 @@ function Public.get_trusted_player(player)
|
|||||||
return trusted and player and player.valid and trusted[player.name] or false
|
return trusted and player and player.valid and trusted[player.name] or false
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the table of trusted
|
--- Set a player as trusted
|
||||||
-- @param LuaPlayer
|
-- @param LuaPlayer
|
||||||
function Public.set_trusted_player(player)
|
function Public.set_trusted_player(player)
|
||||||
if trusted and player and player.valid then
|
if trusted and player and player.valid then
|
||||||
@ -284,6 +284,14 @@ function Public.set_trusted_player(player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set a player as untrusted
|
||||||
|
-- @param LuaPlayer
|
||||||
|
function Public.set_untrusted_player(player)
|
||||||
|
if trusted and player and player.valid then
|
||||||
|
trusted[player.name] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Returns the table of session
|
--- Returns the table of session
|
||||||
-- @param LuaPlayer
|
-- @param LuaPlayer
|
||||||
-- @return <table>
|
-- @return <table>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user