1
0
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:
hanakocz 2022-12-02 16:40:24 +01:00 committed by GitHub
commit b44a289664
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 27 deletions

View File

@ -1089,11 +1089,13 @@ local function deny_building(event)
if entity.position.x >= 254 then if entity.position.x >= 254 then
if entity.name ~= 'entity-ghost' then if entity.name ~= 'entity-ghost' then
if event.player_index then if not string.match(entity.name, 'rail') then
game.get_player(event.player_index).insert({name = entity.name, count = 1}) if event.player_index then
else game.get_player(event.player_index).insert({name = entity.name, count = 1})
local inventory = event.robot.get_inventory(defines.inventory.robot_cargo) else
inventory.insert({name = entity.name, count = 1}) local inventory = event.robot.get_inventory(defines.inventory.robot_cargo)
inventory.insert({name = entity.name, count = 1})
end
end end
end end

View File

@ -122,9 +122,9 @@ Public.difficulty_options = {
{value = 0.9, icon = 'item/piercing-rounds-magazine', text = {'pirates.difficulty_normal'}, associated_color = {r = 255, g = 255, b = 50}}, {value = 0.9, icon = 'item/piercing-rounds-magazine', text = {'pirates.difficulty_normal'}, associated_color = {r = 255, g = 255, b = 50}},
{value = 1.3, icon = 'item/uranium-rounds-magazine', text = {'pirates.difficutly_hard'}, associated_color = {r = 255, g = 50, b = 50}}, {value = 1.4, icon = 'item/uranium-rounds-magazine', text = {'pirates.difficutly_hard'}, associated_color = {r = 255, g = 50, b = 50}},
{value = 1.8, icon = 'item/atomic-bomb', text = {'pirates.difficulty_nightmare'}, associated_color = {r = 170, g = 60, b = 60}}, {value = 2.1, icon = 'item/atomic-bomb', text = {'pirates.difficulty_nightmare'}, associated_color = {r = 170, g = 60, b = 60}},
} }
function Public.get_difficulty_option_from_value(difficulty_value) function Public.get_difficulty_option_from_value(difficulty_value)
-- given a difficulty value, key in to the closesy entry in the above table. (organising things this way allows us to make changes to the 'value' keys in the above table without disrupting e.g. past highscores data) -- given a difficulty value, key in to the closesy entry in the above table. (organising things this way allows us to make changes to the 'value' keys in the above table without disrupting e.g. past highscores data)

View File

@ -8,6 +8,11 @@ local ban_by_join_enabled = false
local try_get_ban = Server.try_get_ban local try_get_ban = Server.try_get_ban
local valid_commands = {
['ban'] = true,
['unban'] = true
}
local try_get_is_banned_token = local try_get_is_banned_token =
Token.register( Token.register(
function(data) function(data)
@ -52,7 +57,9 @@ Event.add(
Event.add( Event.add(
defines.events.on_console_command, defines.events.on_console_command,
function(event) function(event)
Server.ban_handler(event) if valid_commands[event.command] then
Server.ban_handler(event)
end
end end
) )

View File

@ -1330,11 +1330,10 @@ function Public.ban_handler(event)
return return
end end
if len(user) <= 2 then if len(user) <= 1 then
return return
end end
local player_index
local reason local reason
local str = '' local str = ''
@ -1343,36 +1342,26 @@ function Public.ban_handler(event)
insert(t, i) insert(t, i)
end end
player_index = t[1] local target = t[1]
for i = 2, #t do for i = 2, #t do
str = str .. t[i] .. ' ' str = str .. t[i] .. ' '
reason = str reason = str
end end
if not player_index then if not target then
return print('[on_console_command] - player_index was undefined.') return print('[on_console_command] - target was undefined.')
end
local target
if game.get_player(player_index) then
target = game.get_player(player_index)
if not target or not target.valid then
return
end
else
return
end end
if event.player_index then if event.player_index then
local player = game.get_player(event.player_index) local player = game.get_player(event.player_index)
if player and player.valid and player.admin then if player and player.valid and player.admin then
local data = Public.build_embed_data() local data = Public.build_embed_data()
data.username = target.name data.username = target
data.admin = player.name data.admin = player.name
if cmd == 'ban' then if cmd == 'ban' then
Public.set_data(jailed_data_set, target.name, nil) -- this is added here since we don't want to clutter the jail dataset. Public.set_data(jailed_data_set, target, nil) -- this is added here since we don't want to clutter the jail dataset.
if not reason then if not reason then
data.reason = 'Not specified.' data.reason = 'Not specified.'
Public.to_banned_embed(data) Public.to_banned_embed(data)
@ -1389,7 +1378,7 @@ function Public.ban_handler(event)
end end
else else
local data = Public.build_embed_data() local data = Public.build_embed_data()
data.username = target.name data.username = target
data.admin = '<server>' data.admin = '<server>'
if event.user_override then if event.user_override then
@ -1397,7 +1386,7 @@ function Public.ban_handler(event)
end end
if cmd == 'ban' then if cmd == 'ban' then
Public.set_data(jailed_data_set, target.name, nil) -- this is added here since we don't want to clutter the jail dataset. Public.set_data(jailed_data_set, target, nil) -- this is added here since we don't want to clutter the jail dataset.
if not reason then if not reason then
data.reason = 'Not specified.' data.reason = 'Not specified.'
Public.to_banned_embed(data) Public.to_banned_embed(data)