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

Merge branch 'develop' into develop

This commit is contained in:
Gerkiz 2022-06-07 17:42:30 +02:00 committed by GitHub
commit 2a4475da41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 98 additions and 81 deletions

View File

@ -58,11 +58,11 @@ local function prepare_floaty_text(list, surface, position, name, count)
end end
local function chest_is_valid(chest) local function chest_is_valid(chest)
if this.dungeons_initial_level ~= nil then if this.dungeons_initial_level ~= nil then
-- transport chests always are valid targets -- transport chests always are valid targets
if chest.name == 'blue-chest' or chest.name == 'red-chest' then if chest.name == 'blue-chest' or chest.name == 'red-chest' then
return true return true
end end
end end
for _, e in pairs( for _, e in pairs(
chest.surface.find_entities_filtered( chest.surface.find_entities_filtered(
@ -514,20 +514,20 @@ local function auto_stash(player, event)
furnaceList[name] = (furnaceList[name] or 0) + inventory[i].count furnaceList[name] = (furnaceList[name] or 0) + inventory[i].count
end end
end end
elseif shift and this.insert_into_wagon then elseif shift and this.insert_into_wagon then -- insert into wagon
if button == defines.mouse_button_type.right then if button == defines.mouse_button_type.right then -- insert all ores into wagon
if is_resource then if is_resource then
full_insert = {full = insert_into_wagon(inventory[i], chests, name, floaty_text_list), name = name} full_insert = {full = insert_into_wagon(inventory[i], chests, name, floaty_text_list), name = name}
end end
end end
if button == defines.mouse_button_type.left then if button == defines.mouse_button_type.left then -- insert all filtered into wagon
full_insert = {full = insert_into_wagon_filtered(inventory[i], chests, name, floaty_text_list), name = name} full_insert = {full = insert_into_wagon_filtered(inventory[i], chests, name, floaty_text_list), name = name}
end end
elseif button == defines.mouse_button_type.right then elseif button == defines.mouse_button_type.right then -- only ores to nearby chests
if is_resource then if is_resource then
full_insert = {full = insert_item_into_chest(inventory[i], chests, filtered_chests, name, floaty_text_list, full_insert), name = name} full_insert = {full = insert_item_into_chest(inventory[i], chests, filtered_chests, name, floaty_text_list, full_insert), name = name}
end end
elseif button == defines.mouse_button_type.left then elseif button == defines.mouse_button_type.left then -- all items to nearby chests
full_insert = {full = insert_item_into_chest(inventory[i], chests, filtered_chests, name, floaty_text_list, full_insert), name = name} full_insert = {full = insert_item_into_chest(inventory[i], chests, filtered_chests, name, floaty_text_list, full_insert), name = name}
end end
if not full_insert.success then if not full_insert.success then
@ -573,7 +573,7 @@ local function create_gui_button(player)
data.tooltip = tooltip data.tooltip = tooltip
data.sprite = 'item/wooden-chest' data.sprite = 'item/wooden-chest'
if data[player.index] then if data and data[player.index] then
local f = data[player.index] local f = data[player.index]
if f.frame and f.frame.valid then if f.frame and f.frame.valid then
f.frame.sprite = 'item/wooden-chest' f.frame.sprite = 'item/wooden-chest'
@ -652,7 +652,7 @@ local function on_gui_click(event)
local name = 'auto_stash' local name = 'auto_stash'
if this.bottom_button then if this.bottom_button then
local data = BottomFrame.get('bottom_quickbar_button') local data = BottomFrame.get('bottom_quickbar_button')
if data[player.index] then if data and data[player.index] then
data = data[player.index] data = data[player.index]
name = data.name name = data.name
end end
@ -692,7 +692,7 @@ function Public.bottom_button(value)
end end
function Public.set_dungeons_initial_level(value) function Public.set_dungeons_initial_level(value)
this.dungeons_initial_level = value this.dungeons_initial_level = value
end end
Event.on_configuration_changed(do_whitelist) Event.on_configuration_changed(do_whitelist)

View File

@ -128,12 +128,12 @@ commands.add_command(
return return
end end
local target_player = game.get_player(cmd.parameter) local target = game.get_player(cmd.parameter)
if validate_player(target_player) then if validate_player(target) then
local player_data = create_player_data(player) local player_data = create_player_data(player)
player_data.target_player = target_player player_data.target = target
create_mini_camera_gui(player, target_player) create_mini_camera_gui(player, target)
else else
remove_player_data(player) remove_player_data(player)
player.print('[Where] Please type a name of a player who is connected.', Color.warning) player.print('[Where] Please type a name of a player who is connected.', Color.warning)
@ -146,12 +146,12 @@ commands.add_command(
local function on_nth_tick() local function on_nth_tick()
for p, data in pairs(this.players) do for p, data in pairs(this.players) do
if data and data.target_player and data.target_player.valid then if data and data.target and data.target.valid then
local target_player = data.target_player local target = data.target
local camera_frame = data.camera_frame local camera_frame = data.camera_frame
local player = game.get_player(p) local player = game.get_player(p)
if not (validate_player(player) and validate_player(target_player)) then if not (validate_player(player) or validate_player(target)) then
remove_player_data(player) remove_player_data(player)
goto continue goto continue
end end
@ -161,8 +161,8 @@ local function on_nth_tick()
goto continue goto continue
end end
camera_frame.position = target_player.position camera_frame.position = target.position
camera_frame.surface_index = target_player.surface.index camera_frame.surface_index = target.surface.index
::continue:: ::continue::
end end

View File

@ -78,9 +78,11 @@ end
local function add_revoked(name, admin, reason) local function add_revoked(name, admin, reason)
if name then if name then
local date = Server.get_current_date_with_time()
if not revoked_permissions[name] then if not revoked_permissions[name] then
revoked_permissions[name] = true revoked_permissions[name] = true
set_data(revoked_permissions_set, name, {revoked = true, actor = admin, reason = reason}) set_data(revoked_permissions_set, name, {revoked = true, actor = admin, reason = reason, date = date})
return true return true
else else
return false return false
@ -429,10 +431,7 @@ local function vote_to_jail(player, griefer, msg)
votejail[griefer][player.name] = true votejail[griefer][player.name] = true
votejail[griefer].index = votejail[griefer].index + 1 votejail[griefer].index = votejail[griefer].index + 1
Utils.print_to(player, 'You have voted to jail player ' .. griefer .. '.') Utils.print_to(player, 'You have voted to jail player ' .. griefer .. '.')
if if votejail[griefer].index >= settings.votejail_count or (votejail[griefer].index == #game.connected_players - 1 and #game.connected_players > votejail[griefer].index) then
votejail[griefer].index >= settings.votejail_count or
(votejail[griefer].index == #game.connected_players - 1 and #game.connected_players > votejail[griefer].index)
then
Public.try_ul_data(griefer, true, votejail[griefer].actor, msg) Public.try_ul_data(griefer, true, votejail[griefer].actor, msg)
end end
else else
@ -460,10 +459,7 @@ local function vote_to_free(player, griefer)
votefree[griefer].index = votefree[griefer].index + 1 votefree[griefer].index = votefree[griefer].index + 1
Utils.print_to(player, 'You have voted to free player ' .. griefer .. '.') Utils.print_to(player, 'You have voted to free player ' .. griefer .. '.')
if if votefree[griefer].index >= settings.votejail_count or (votefree[griefer].index == #game.connected_players - 1 and #game.connected_players > votefree[griefer].index) then
votefree[griefer].index >= settings.votejail_count or
(votefree[griefer].index == #game.connected_players - 1 and #game.connected_players > votefree[griefer].index)
then
Public.try_ul_data(griefer, false, votefree[griefer].actor) Public.try_ul_data(griefer, false, votefree[griefer].actor)
votejail[griefer] = nil votejail[griefer] = nil
votefree[griefer] = nil votefree[griefer] = nil
@ -496,6 +492,8 @@ local function jail(player, griefer, msg, raised)
local gulag = get_gulag_permission_group() local gulag = get_gulag_permission_group()
gulag.add_player(griefer) gulag.add_player(griefer)
local date = Server.get_current_date_with_time()
local message = griefer .. ' has been jailed by ' .. player .. '. Cause: ' .. msg local message = griefer .. ' has been jailed by ' .. player .. '. Cause: ' .. msg
if to_jail_player.character and to_jail_player.character.valid and to_jail_player.character.driving then if to_jail_player.character and to_jail_player.character.valid and to_jail_player.character.driving then
@ -504,7 +502,7 @@ local function jail(player, griefer, msg, raised)
jailed[griefer] = {jailed = true, actor = player, reason = msg} jailed[griefer] = {jailed = true, actor = player, reason = msg}
if not raised then if not raised then
set_data(jailed_data_set, griefer, {jailed = true, actor = player, reason = msg}) set_data(jailed_data_set, griefer, {jailed = true, actor = player, reason = msg, date = date})
end end
Utils.print_to(nil, message) Utils.print_to(nil, message)
@ -700,12 +698,11 @@ Server.on_data_set_changed(
end end
local v = data.value local v = data.value
local k = data.key
if v and v.actor then if v and v.actor then
if v.jailed then jail(v.actor, data.key, v.reason, true)
jail(v.actor, data.key, v.reason, true) elseif k then
elseif not v.jailed then free('script', data.key)
free('script', data.key)
end
end end
end end
) )
@ -725,7 +722,6 @@ commands.add_command(
'jail', 'jail',
'Sends the player to gulag! Valid arguments are:\n/jail <LuaPlayer> <reason>', 'Sends the player to gulag! Valid arguments are:\n/jail <LuaPlayer> <reason>',
function() function()
return
end end
) )
@ -733,7 +729,6 @@ commands.add_command(
'free', 'free',
'Brings back the player from gulag.', 'Brings back the player from gulag.',
function() function()
return
end end
) )
@ -883,10 +878,7 @@ Event.add(
if trusted and playtime >= settings.playtime_for_vote and playtime < settings.playtime_for_instant_jail and not player.admin then if trusted and playtime >= settings.playtime_for_vote and playtime < settings.playtime_for_instant_jail and not player.admin then
if cmd == 'jail' then if cmd == 'jail' then
if not terms_tbl[player.name] then if not terms_tbl[player.name] then
Utils.warning( Utils.warning(player, 'Abusing the jail command will lead to revoked permissions. Jailing someone in case of disagreement is _NEVER_ OK!')
player,
'Abusing the jail command will lead to revoked permissions. Jailing someone in case of disagreement is _NEVER_ OK!'
)
Utils.warning(player, "Jailing someone because they're afk or other stupid reasons is NOT valid!") Utils.warning(player, "Jailing someone because they're afk or other stupid reasons is NOT valid!")
Utils.warning(player, 'Run this command again to if you really want to do this!') Utils.warning(player, 'Run this command again to if you really want to do this!')
for i = 1, 4 do for i = 1, 4 do
@ -909,10 +901,7 @@ Event.add(
if player.admin or playtime >= settings.playtime_for_instant_jail then if player.admin or playtime >= settings.playtime_for_instant_jail then
if cmd == 'jail' then if cmd == 'jail' then
if not terms_tbl[player.name] then if not terms_tbl[player.name] then
Utils.warning( Utils.warning(player, 'Abusing the jail command will lead to revoked permissions. Jailing someone in case of disagreement is _NEVER_ OK!')
player,
'Abusing the jail command will lead to revoked permissions. Jailing someone in case of disagreement is _NEVER_ OK!'
)
Utils.warning(player, 'Run this command again to if you really want to do this!') Utils.warning(player, 'Run this command again to if you really want to do this!')
for i = 1, 4 do for i = 1, 4 do
Task.set_timeout_in_ticks(delay, play_alert_sound, {name = player.name}) Task.set_timeout_in_ticks(delay, play_alert_sound, {name = player.name})

View File

@ -26,6 +26,8 @@ local Token = require 'utils.token'
local Public = {} local Public = {}
local module_name = Gui.uid_name() local module_name = Gui.uid_name()
local locate_player_frame_name = Gui.uid_name()
local poke_player_frame_name = Gui.uid_name()
local this = { local this = {
player_list = { player_list = {
@ -660,14 +662,21 @@ local function player_list_show(data)
return return
end end
local name_label = local name_flow =
player_list_panel_table.add { player_list_panel_table.add {
type = 'flow'
}
local name_label =
name_flow.add {
type = 'label', type = 'label',
name = p.index, name = locate_player_frame_name,
caption = caption, caption = caption,
tooltip = tooltip tooltip = tooltip
} }
Gui.set_data(name_label, p.index)
local p_color = game.players[player_list[i].player_index] local p_color = game.players[player_list[i].player_index]
name_label.style.font = 'default' name_label.style.font = 'default'
name_label.style.font_color = { name_label.style.font_color = {
@ -716,20 +725,21 @@ local function player_list_show(data)
current_label.style.font = 'heading-3' current_label.style.font = 'heading-3'
-- Poke -- Poke
local flow = player_list_panel_table.add {type = 'flow', name = 'button_flow_' .. i, direction = 'horizontal'} local poke_flow = player_list_panel_table.add {type = 'flow', name = 'button_flow_' .. i, direction = 'horizontal'}
flow.add {type = 'label', name = 'button_spacer_' .. i, caption = ''} poke_flow.add {type = 'label', name = 'button_spacer_' .. i, caption = ''}
local button = flow.add {type = 'button', name = 'poke_player_' .. player_list[i].name, caption = player_list[i].pokes} local poke_button = poke_flow.add {type = 'button', name = poke_player_frame_name, caption = player_list[i].pokes}
button.style.font = 'default' Gui.set_data(poke_button, p.index)
button.tooltip = 'Poke ' .. player_list[i].name .. ' with a random message!' poke_button.style.font = 'default'
poke_button.tooltip = 'Poke ' .. player_list[i].name .. ' with a random message!'
label.style.font_color = {r = 0.83, g = 0.83, b = 0.83} label.style.font_color = {r = 0.83, g = 0.83, b = 0.83}
button.style.minimal_height = 30 poke_button.style.minimal_height = 30
button.style.minimal_width = 30 poke_button.style.minimal_width = 30
button.style.maximal_height = 30 poke_button.style.maximal_height = 30
button.style.maximal_width = 30 poke_button.style.maximal_width = 30
button.style.top_padding = 0 poke_button.style.top_padding = 0
button.style.left_padding = 0 poke_button.style.left_padding = 0
button.style.right_padding = 0 poke_button.style.right_padding = 0
button.style.bottom_padding = 0 poke_button.style.bottom_padding = 0
end end
end end
@ -851,49 +861,67 @@ local function on_gui_click(event)
actions[name]() actions[name]()
return return
end end
end
Gui.on_click(
locate_player_frame_name,
function(event)
local player = event.player
local element = event.element
local data = Gui.get_data(element)
if not data then
return
end
if not element.valid then
return
end
--Locate other players
local index = tonumber(element.name)
if index and game.get_player(index) and index == game.get_player(index).index then
local is_spamming = SpamProtection.is_spamming(player, nil, 'PlayerList Locate Player') local is_spamming = SpamProtection.is_spamming(player, nil, 'PlayerList Locate Player')
if is_spamming then if is_spamming then
return return
end end
local target = game.get_player(index)
local target = game.get_player(data)
if not target or not target.valid then if not target or not target.valid then
Gui.set_data(element, nil)
return return
end end
Gui.set_data(element, nil)
Where.create_mini_camera_gui(player, target) Where.create_mini_camera_gui(player, target)
end end
--Poke other players )
if string.sub(element.name, 1, 11) == 'poke_player' then
local is_spamming = SpamProtection.is_spamming(player, nil, 'PlayerList Poke Player') Gui.on_click(
if is_spamming then poke_player_frame_name,
function(event)
local player = event.player
local element = event.element
local data = Gui.get_data(element)
if not data then
return return
end end
local poked_player = string.sub(element.name, 13, string.len(element.name)) local target = game.get_player(data)
if player.name == poked_player then
if player.index == target.index then
Gui.set_data(element, nil)
return return
end end
if this.player_list.last_poke_tick[element.player_index] + 300 < game.tick then
if this.player_list.last_poke_tick[player.index] + 300 < game.tick then
local str = '>> ' local str = '>> '
str = str .. player.name str = str .. player.name
str = str .. ' has poked ' str = str .. ' has poked '
str = str .. poked_player str = str .. target.name
str = str .. ' with ' str = str .. ' with '
local z = math.random(1, #pokemessages) local z = math.random(1, #pokemessages)
str = str .. pokemessages[z] str = str .. pokemessages[z]
str = str .. ' <<' str = str .. ' <<'
game.print(str) game.print(str)
this.player_list.last_poke_tick[element.player_index] = game.tick this.player_list.last_poke_tick[player.index] = game.tick
local p = game.players[poked_player] this.player_list.pokes[target.index] = this.player_list.pokes[target.index] + 1
this.player_list.pokes[p.index] = this.player_list.pokes[p.index] + 1 Gui.set_data(element, nil)
end end
end end
end )
local function refresh() local function refresh()
for _, player in pairs(game.connected_players) do for _, player in pairs(game.connected_players) do