mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2024-12-26 22:56:43 +02:00
Move files in main folder to utils
This commit is contained in:
parent
c524966624
commit
966dcf220a
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 Jailed = require 'utils.datastore.jail_data'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local AntiGrief = require 'antigrief'
|
||||
local AntiGrief = require 'utils.antigrief'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local Token = require 'utils.token'
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
local Misc = require 'commands.misc'
|
||||
local Misc = require 'utils.commands.misc'
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
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 Color = require 'utils.color_presets'
|
||||
local SessionData = require 'utils.datastore.session_data'
|
||||
|
@ -13,7 +13,7 @@ to your scenario control.lua.
|
||||
Minor changes by ~~~Gerkiz~~~
|
||||
--]]
|
||||
local Event = require 'utils.event'
|
||||
local Where = require 'commands.where'
|
||||
local Where = require 'utils.commands.where'
|
||||
local Session = require 'utils.datastore.session_data'
|
||||
local Jailed = require 'utils.datastore.jail_data'
|
||||
local Supporters = require 'utils.datastore.supporters'
|
||||
|
@ -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_commands'
|
||||
require 'utils.command_handler'
|
||||
require 'utils.utils'
|
||||
require 'utils.pause_game'
|
||||
require 'utils.table'
|
||||
@ -18,14 +19,15 @@ require 'utils.datastore.quickbar_data'
|
||||
require 'utils.datastore.message_on_join_data'
|
||||
require 'utils.datastore.player_tag_data'
|
||||
require 'utils.datastore.supporters'
|
||||
require 'chatbot'
|
||||
require 'commands'
|
||||
require 'antigrief'
|
||||
require 'utils.chatbot'
|
||||
require 'utils.commands'
|
||||
require 'utils.antigrief'
|
||||
require 'utils.debug.command'
|
||||
require 'modules.corpse_markers'
|
||||
require 'modules.floaty_chat'
|
||||
require 'modules.show_inventory'
|
||||
require 'modules.inserter_drops_pickup'
|
||||
require 'utils.debug.command'
|
||||
require 'modules.autostash'
|
||||
|
||||
require 'comfy_panel.main'
|
||||
require 'comfy_panel.player_list'
|
||||
@ -35,8 +37,6 @@ require 'comfy_panel.poll'
|
||||
require 'comfy_panel.score'
|
||||
require 'comfy_panel.config'
|
||||
|
||||
require 'modules.autostash'
|
||||
|
||||
---------------- !ENABLE MODULES HERE ----------------
|
||||
--require 'modules.admins_operate_biters'
|
||||
--require 'modules.the_floor_is_lava'
|
||||
|
@ -1,5 +1,5 @@
|
||||
local Server = require 'utils.server'
|
||||
local Modifiers = require 'player_modifiers'
|
||||
local Modifiers = require 'utils.player_modifiers'
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
|
||||
|
@ -12,7 +12,7 @@ require 'modules.dangerous_goods'
|
||||
require 'modules.custom_death_messages'
|
||||
require 'modules.launch_fish_to_win'
|
||||
|
||||
local AntiGrief = require 'antigrief'
|
||||
local AntiGrief = require 'utils.antigrief'
|
||||
local Terrain = require 'maps.fish_defender.terrain'
|
||||
local Unit_health_booster = require 'modules.biter_health_booster'
|
||||
local Session = require 'utils.datastore.session_data'
|
||||
|
@ -16,7 +16,7 @@ local Server = require 'utils.server'
|
||||
local Session = require 'utils.datastore.session_data'
|
||||
local Poll = require 'comfy_panel.poll'
|
||||
local Score = require 'comfy_panel.score'
|
||||
local AntiGrief = require 'antigrief'
|
||||
local AntiGrief = require 'utils.antigrief'
|
||||
local Core = require 'utils.core'
|
||||
local format_number = require 'util'.format_number
|
||||
local random = math.random
|
||||
|
@ -31,7 +31,7 @@ local Map = require 'modules.map_info'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local Treasure = require 'maps.mountain_fortress_v2.treasure'
|
||||
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_abs = math.abs
|
||||
|
@ -11,7 +11,7 @@ local Collapse = require 'modules.collapse'
|
||||
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||
local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions'
|
||||
local math2d = require 'math2d'
|
||||
local Misc = require 'commands.misc'
|
||||
local Misc = require 'utils.commands.misc'
|
||||
|
||||
local this = {
|
||||
power_sources = {index = 1},
|
||||
|
@ -2,7 +2,9 @@ local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local Session = require 'utils.datastore.session_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 = {}
|
||||
|
||||
@ -131,7 +133,7 @@ function Public.add_player_to_permission_group(player, group, forced)
|
||||
end
|
||||
end
|
||||
|
||||
if playtime < 5184000 then -- 24 hours
|
||||
if playtime < required_playtime then
|
||||
local not_trusted = game.permissions.get_group('not_trusted')
|
||||
if not player.admin then
|
||||
not_trusted.add_player(player)
|
||||
|
@ -37,9 +37,9 @@ local Task = require 'utils.task'
|
||||
local Token = require 'utils.token'
|
||||
local Alert = require 'utils.alert'
|
||||
local BottomFrame = require 'comfy_panel.bottom_frame'
|
||||
local AntiGrief = require 'antigrief'
|
||||
local Misc = require 'commands.misc'
|
||||
local Modifiers = require 'player_modifiers'
|
||||
local AntiGrief = require 'utils.antigrief'
|
||||
local Misc = require 'utils.commands.misc'
|
||||
local Modifiers = require 'utils.player_modifiers'
|
||||
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
|
||||
local Reset = require 'functions.soft_reset'
|
||||
local JailData = require 'utils.datastore.jail_data'
|
||||
|
@ -1,6 +1,6 @@
|
||||
local Server = require 'utils.server'
|
||||
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 mapkeeper = '[color=blue]Mapkeeper:[/color]'
|
||||
|
@ -19,7 +19,7 @@ local Poll = require 'comfy_panel.poll'
|
||||
local boss_biter = require 'maps.pidgeotto.boss_biters'
|
||||
local FDT = require 'maps.pidgeotto.table'
|
||||
local Score = require 'comfy_panel.score'
|
||||
local AntiGrief = require 'antigrief'
|
||||
local AntiGrief = require 'utils.antigrief'
|
||||
local math_random = math.random
|
||||
local insert = table.insert
|
||||
local enable_start_grace_period = true
|
||||
|
@ -1,5 +1,5 @@
|
||||
local Event = require 'utils.event'
|
||||
local Modifier = require 'player_modifiers'
|
||||
local Modifier = require 'utils.player_modifiers'
|
||||
local Color = require 'utils.color_presets'
|
||||
|
||||
local function validate_player(player)
|
||||
|
@ -1,10 +1,15 @@
|
||||
-- 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 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_spawn_value = 80
|
||||
|
@ -18,7 +18,7 @@ local math_sqrt = math.sqrt
|
||||
local math_floor = math.floor
|
||||
local Global = require 'utils.global'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local P = require 'player_modifiers'
|
||||
local P = require 'utils.player_modifiers'
|
||||
local visuals_delay = 1800
|
||||
local level_up_floating_text_color = {0, 205, 0}
|
||||
local xp_floating_text_color = {157, 157, 157}
|
||||
@ -755,7 +755,12 @@ local function one_punch(character, target, damage)
|
||||
vector[2] = vector[2] * 1000
|
||||
|
||||
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 = '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})
|
||||
else
|
||||
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
|
||||
|
||||
--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
|
||||
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
|
||||
end
|
||||
rpg_t[player.index].last_mined_entity_position.x = entity.position.x
|
||||
|
@ -1,6 +1,6 @@
|
||||
local ComfyGui = require 'comfy_panel.main'
|
||||
local Session = require 'utils.datastore.session_data'
|
||||
local P = require 'player_modifiers'
|
||||
local P = require 'utils.player_modifiers'
|
||||
local Gui = require 'utils.gui'
|
||||
local Color = require 'utils.color_presets'
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
local Public = require 'modules.rpg.core'
|
||||
local Gui = require 'utils.gui'
|
||||
local Event = require 'utils.event'
|
||||
local AntiGrief = require 'antigrief'
|
||||
local AntiGrief = require 'utils.antigrief'
|
||||
local Color = require 'utils.color_presets'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
|
||||
|
@ -1,6 +1,6 @@
|
||||
local Public = require 'modules.rpg.table'
|
||||
local Gui = require 'utils.gui'
|
||||
local P = require 'player_modifiers'
|
||||
local P = require 'utils.player_modifiers'
|
||||
local Session = require 'utils.datastore.session_data'
|
||||
|
||||
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!
|
||||
|
||||
local Event = require 'utils.event'
|
||||
local Player_modifiers = require 'player_modifiers'
|
||||
local Player_modifiers = require 'utils.player_modifiers'
|
||||
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.'
|
||||
|
||||
|
@ -15,14 +15,14 @@ M0JwPPnzLV+EcxobVOmRrEX45fZ5NCQz6S4h3qIRV18Vpu32sQNs
|
||||
8kwoXSdIr1kvNPjEJXfhPwM3fGG70zbN7n+hUH+/4j8HgVljp7wD
|
||||
VXdsJuZ76VsGvWeHyfNjW7REoyhvvvAetn9CzJb1cQ=<<<
|
||||
]]
|
||||
require 'player_modifiers'
|
||||
require 'utils.player_modifiers'
|
||||
require 'modules.rocks_broken_paint_tiles'
|
||||
require 'modules.rocks_heal_over_time'
|
||||
require 'modules.rocks_yield_ore_veins'
|
||||
require 'modules.no_deconstruction_of_neutral_entities'
|
||||
|
||||
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_floor = math.floor
|
||||
local math_abs = math.abs
|
||||
|
@ -17,6 +17,9 @@ local capsule_bomb_threshold = 8
|
||||
local de = defines.events
|
||||
|
||||
local format = string.format
|
||||
local floor = math.floor
|
||||
local random = math.random
|
||||
local abs = math.abs
|
||||
|
||||
local this = {
|
||||
enabled = true,
|
||||
@ -126,14 +129,14 @@ local function damage_player(player, kill, print_to_all)
|
||||
end
|
||||
return
|
||||
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})
|
||||
local messages = {
|
||||
'Ouch.. That hurt! Better be careful now.',
|
||||
'Just a fleshwound.',
|
||||
'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
|
||||
player.character.die('enemy')
|
||||
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
|
||||
playtime = player.online_time + Session.get_session_player(player.name)
|
||||
end
|
||||
if playtime < 2592000 then
|
||||
if playtime < this.required_playtime then
|
||||
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})
|
||||
end
|
||||
@ -208,7 +211,7 @@ local function on_player_ammo_inventory_changed(event)
|
||||
if Session.get_session_player(player.name) then
|
||||
playtime = player.online_time + Session.get_session_player(player.name)
|
||||
end
|
||||
if playtime < 1296000 then
|
||||
if playtime < this.required_playtime then
|
||||
if this.enable_capsule_cursor_warning then
|
||||
local nukes = player.remove_item({name = 'atomic-bomb', count = 1000})
|
||||
if nukes > 0 then
|
||||
@ -254,7 +257,7 @@ local function on_player_built_tile(event)
|
||||
if #this.landfill_history > this.limit then
|
||||
this.landfill_history = {}
|
||||
end
|
||||
local t = math.abs(math.floor((game.tick) / 60))
|
||||
local t = abs(floor((game.tick) / 60))
|
||||
t = FancyTime.short_fancy_time(t)
|
||||
local str = '[' .. t .. '] '
|
||||
str = str .. player.name .. ' at X:'
|
||||
@ -271,11 +274,9 @@ local function on_built_entity(event)
|
||||
return
|
||||
end
|
||||
|
||||
if game.tick < 1296000 then
|
||||
return
|
||||
end
|
||||
local created_entity = event.created_entity
|
||||
|
||||
if event.created_entity.type == 'entity-ghost' then
|
||||
if created_entity.type == 'entity-ghost' then
|
||||
local player = game.get_player(event.player_index)
|
||||
|
||||
if player.admin then
|
||||
@ -290,8 +291,8 @@ local function on_built_entity(event)
|
||||
playtime = player.online_time + Session.get_session_player(player.name)
|
||||
end
|
||||
|
||||
if playtime < 432000 then
|
||||
event.created_entity.destroy()
|
||||
if playtime < this.required_playtime then
|
||||
created_entity.destroy()
|
||||
player.print('You have not grown accustomed to this technology yet.', {r = 0.22, g = 0.99, b = 0.99})
|
||||
end
|
||||
end
|
||||
@ -344,7 +345,12 @@ local function on_player_used_capsule(event)
|
||||
|
||||
local prefix = '[Capsule]'
|
||||
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)
|
||||
else
|
||||
@ -358,14 +364,14 @@ local function on_player_used_capsule(event)
|
||||
this.capsule_history = {}
|
||||
end
|
||||
|
||||
local t = math.abs(math.floor((game.tick) / 60))
|
||||
local t = abs(floor((game.tick) / 60))
|
||||
t = FancyTime.short_fancy_time(t)
|
||||
local str = '[' .. t .. '] '
|
||||
str = str .. msg
|
||||
str = str .. ' at X:'
|
||||
str = str .. math.floor(position.x)
|
||||
str = str .. floor(position.x)
|
||||
str = str .. ' Y:'
|
||||
str = str .. math.floor(position.y)
|
||||
str = str .. floor(position.y)
|
||||
str = str .. ' '
|
||||
str = str .. 'surface:' .. player.surface.index
|
||||
increment(this.capsule_history, str)
|
||||
@ -377,6 +383,7 @@ local function on_entity_died(event)
|
||||
if not this.enabled then
|
||||
return
|
||||
end
|
||||
|
||||
local cause = event.cause
|
||||
local name
|
||||
|
||||
@ -414,15 +421,15 @@ local function on_entity_died(event)
|
||||
chest = '[color=yellow]' .. event.entity.name .. '[/color]'
|
||||
end
|
||||
|
||||
local t = math.abs(math.floor((game.tick) / 60))
|
||||
local t = abs(floor((game.tick) / 60))
|
||||
t = FancyTime.short_fancy_time(t)
|
||||
local str = '[' .. t .. '] '
|
||||
str = str .. name .. ' destroyed '
|
||||
str = str .. chest
|
||||
str = str .. ' at X:'
|
||||
str = str .. math.floor(event.entity.position.x)
|
||||
str = str .. floor(event.entity.position.x)
|
||||
str = str .. ' Y:'
|
||||
str = str .. math.floor(event.entity.position.y)
|
||||
str = str .. floor(event.entity.position.y)
|
||||
str = str .. ' '
|
||||
str = str .. 'surface:' .. event.entity.surface.index
|
||||
increment(this.friendly_fire_history, str)
|
||||
@ -432,7 +439,7 @@ local function on_entity_died(event)
|
||||
return
|
||||
end
|
||||
end
|
||||
local t = math.abs(math.floor((game.tick) / 60))
|
||||
local t = abs(floor((game.tick) / 60))
|
||||
t = FancyTime.short_fancy_time(t)
|
||||
local str = '[' .. t .. '] '
|
||||
if cause and cause.name == 'character' and cause.player then
|
||||
@ -442,9 +449,9 @@ local function on_entity_died(event)
|
||||
end
|
||||
str = str .. '[color=yellow]' .. event.entity.name .. '[/color]'
|
||||
str = str .. ' at X:'
|
||||
str = str .. math.floor(event.entity.position.x)
|
||||
str = str .. floor(event.entity.position.x)
|
||||
str = str .. ' Y:'
|
||||
str = str .. math.floor(event.entity.position.y)
|
||||
str = str .. floor(event.entity.position.y)
|
||||
str = str .. ' '
|
||||
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
|
||||
this.whitelist_mining_history = {}
|
||||
end
|
||||
local t = math.abs(math.floor((game.tick) / 60))
|
||||
local t = abs(floor((game.tick) / 60))
|
||||
t = FancyTime.short_fancy_time(t)
|
||||
local str = '[' .. t .. '] '
|
||||
str = str .. player.name .. ' mined '
|
||||
str = str .. '[color=yellow]' .. entity.name .. '[/color]'
|
||||
str = str .. ' at X:'
|
||||
str = str .. math.floor(entity.position.x)
|
||||
str = str .. floor(entity.position.x)
|
||||
str = str .. ' Y:'
|
||||
str = str .. math.floor(entity.position.y)
|
||||
str = str .. floor(entity.position.y)
|
||||
str = str .. ' '
|
||||
str = str .. 'surface:' .. entity.surface.index
|
||||
increment(this.whitelist_mining_history, str)
|
||||
@ -513,15 +520,15 @@ local function on_player_mined_entity(event)
|
||||
this.mining_history = {}
|
||||
end
|
||||
|
||||
local t = math.abs(math.floor((game.tick) / 60))
|
||||
local t = abs(floor((game.tick) / 60))
|
||||
t = FancyTime.short_fancy_time(t)
|
||||
local str = '[' .. t .. '] '
|
||||
str = str .. player.name .. ' mined '
|
||||
str = str .. '[color=yellow]' .. event.entity.name .. '[/color]'
|
||||
str = str .. ' at X:'
|
||||
str = str .. math.floor(event.entity.position.x)
|
||||
str = str .. floor(event.entity.position.x)
|
||||
str = str .. ' Y:'
|
||||
str = str .. math.floor(event.entity.position.y)
|
||||
str = str .. floor(event.entity.position.y)
|
||||
str = str .. ' '
|
||||
str = str .. 'surface:' .. event.entity.surface.index
|
||||
increment(this.mining_history, str)
|
||||
@ -561,15 +568,15 @@ local function on_gui_opened(event)
|
||||
this.corpse_history = {}
|
||||
end
|
||||
|
||||
local t = math.abs(math.floor((game.tick) / 60))
|
||||
local t = abs(floor((game.tick) / 60))
|
||||
t = FancyTime.short_fancy_time(t)
|
||||
local str = '[' .. t .. '] '
|
||||
str = str .. player.name .. ' opened '
|
||||
str = str .. '[color=yellow]' .. corpse_owner.name .. '[/color] body'
|
||||
str = str .. ' at X:'
|
||||
str = str .. math.floor(event.entity.position.x)
|
||||
str = str .. floor(event.entity.position.x)
|
||||
str = str .. ' Y:'
|
||||
str = str .. math.floor(event.entity.position.y)
|
||||
str = str .. floor(event.entity.position.y)
|
||||
str = str .. ' '
|
||||
str = str .. 'surface:' .. event.entity.surface.index
|
||||
increment(this.corpse_history, str)
|
||||
@ -616,15 +623,15 @@ local function on_pre_player_mined_item(event)
|
||||
this.corpse_history = {}
|
||||
end
|
||||
|
||||
local t = math.abs(math.floor((game.tick) / 60))
|
||||
local t = abs(floor((game.tick) / 60))
|
||||
t = FancyTime.short_fancy_time(t)
|
||||
local str = '[' .. t .. '] '
|
||||
str = str .. player.name .. ' mined '
|
||||
str = str .. '[color=yellow]' .. corpse_owner.name .. '[/color] body'
|
||||
str = str .. ' at X:'
|
||||
str = str .. math.floor(entity.position.x)
|
||||
str = str .. floor(entity.position.x)
|
||||
str = str .. ' Y:'
|
||||
str = str .. math.floor(entity.position.y)
|
||||
str = str .. floor(entity.position.y)
|
||||
str = str .. ' '
|
||||
str = str .. 'surface:' .. entity.surface.index
|
||||
increment(this.corpse_history, str)
|
||||
@ -644,7 +651,7 @@ local function on_console_chat(event)
|
||||
this.message_history = {}
|
||||
end
|
||||
|
||||
local t = math.abs(math.floor((game.tick) / 60))
|
||||
local t = abs(floor((game.tick) / 60))
|
||||
t = FancyTime.short_fancy_time(t)
|
||||
local message = event.message
|
||||
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)
|
||||
end
|
||||
|
||||
if playtime < 1296000 then
|
||||
if playtime < this.required_playtime then
|
||||
if this.enable_capsule_cursor_warning then
|
||||
if ammo_names[name] then
|
||||
local item_to_remove = player.remove_item({name = name, count = 1000})
|
||||
@ -719,7 +726,8 @@ local function on_player_cancelled_crafting(event)
|
||||
'[Crafting]',
|
||||
player.name ..
|
||||
' 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
|
||||
|
||||
@ -730,16 +738,16 @@ local function on_player_cancelled_crafting(event)
|
||||
this.cancel_crafting_history = {}
|
||||
end
|
||||
|
||||
local t = math.abs(math.floor((game.tick) / 60))
|
||||
local t = abs(floor((game.tick) / 60))
|
||||
t = FancyTime.short_fancy_time(t)
|
||||
local str = '[' .. t .. '] '
|
||||
str = str .. player.name .. ' canceled '
|
||||
str = str .. ' item [color=yellow]' .. event.recipe.name .. '[/color]'
|
||||
str = str .. ' count was a total of: ' .. crafting_queue_item_count
|
||||
str = str .. ' at X:'
|
||||
str = str .. math.floor(player.position.x)
|
||||
str = str .. floor(player.position.x)
|
||||
str = str .. ' Y:'
|
||||
str = str .. math.floor(player.position.y)
|
||||
str = str .. floor(player.position.y)
|
||||
str = str .. ' '
|
||||
str = str .. 'surface:' .. player.surface.index
|
||||
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
|
||||
this.capsule_history = {}
|
||||
end
|
||||
local t = math.abs(math.floor((game.tick) / 60))
|
||||
local t = abs(floor((game.tick) / 60))
|
||||
t = FancyTime.short_fancy_time(t)
|
||||
local str = '[' .. t .. '] '
|
||||
str = str .. '[color=yellow]' .. msg .. '[/color]'
|
||||
str = str .. ' at X:'
|
||||
str = str .. math.floor(position.x)
|
||||
str = str .. floor(position.x)
|
||||
str = str .. ' Y:'
|
||||
str = str .. math.floor(position.y)
|
||||
str = str .. floor(position.y)
|
||||
str = str .. ' '
|
||||
str = str .. 'surface:' .. player.surface.index
|
||||
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_edited, on_permission_group_edited)
|
||||
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
|
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 Modifiers = require 'player_modifiers'
|
||||
local Modifiers = require 'utils.player_modifiers'
|
||||
local Server = require 'utils.server'
|
||||
local Color = require 'utils.color_presets'
|
||||
local Event = require 'utils.event'
|
||||
@ -239,7 +239,10 @@ commands.add_command(
|
||||
end
|
||||
if not this.creative_are_you_sure then
|
||||
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
|
||||
end
|
||||
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
|
||||
end
|
||||
|
||||
--- Returns the table of trusted
|
||||
--- Set a player as trusted
|
||||
-- @param LuaPlayer
|
||||
function Public.set_trusted_player(player)
|
||||
if trusted and player and player.valid then
|
||||
@ -284,6 +284,14 @@ function Public.set_trusted_player(player)
|
||||
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
|
||||
-- @param LuaPlayer
|
||||
-- @return <table>
|
||||
|
Loading…
Reference in New Issue
Block a user