1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-04 00:15:45 +02:00
This commit is contained in:
Gerkiz 2022-06-07 17:39:44 +02:00
parent 191b58ec03
commit 1e3f0ff811
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
local function chest_is_valid(chest)
if this.dungeons_initial_level ~= nil then
-- transport chests always are valid targets
if chest.name == 'blue-chest' or chest.name == 'red-chest' then
return true
end
if this.dungeons_initial_level ~= nil then
-- transport chests always are valid targets
if chest.name == 'blue-chest' or chest.name == 'red-chest' then
return true
end
end
for _, e in pairs(
chest.surface.find_entities_filtered(
@ -514,20 +514,20 @@ local function auto_stash(player, event)
furnaceList[name] = (furnaceList[name] or 0) + inventory[i].count
end
end
elseif shift and this.insert_into_wagon then
if button == defines.mouse_button_type.right then
elseif shift and this.insert_into_wagon then -- insert into wagon
if button == defines.mouse_button_type.right then -- insert all ores into wagon
if is_resource then
full_insert = {full = insert_into_wagon(inventory[i], chests, name, floaty_text_list), name = name}
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}
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
full_insert = {full = insert_item_into_chest(inventory[i], chests, filtered_chests, name, floaty_text_list, full_insert), name = name}
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}
end
if not full_insert.success then
@ -573,7 +573,7 @@ local function create_gui_button(player)
data.tooltip = tooltip
data.sprite = 'item/wooden-chest'
if data[player.index] then
if data and data[player.index] then
local f = data[player.index]
if f.frame and f.frame.valid then
f.frame.sprite = 'item/wooden-chest'
@ -652,7 +652,7 @@ local function on_gui_click(event)
local name = 'auto_stash'
if this.bottom_button then
local data = BottomFrame.get('bottom_quickbar_button')
if data[player.index] then
if data and data[player.index] then
data = data[player.index]
name = data.name
end
@ -692,7 +692,7 @@ function Public.bottom_button(value)
end
function Public.set_dungeons_initial_level(value)
this.dungeons_initial_level = value
this.dungeons_initial_level = value
end
Event.on_configuration_changed(do_whitelist)

View File

@ -128,12 +128,12 @@ commands.add_command(
return
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)
player_data.target_player = target_player
create_mini_camera_gui(player, target_player)
player_data.target = target
create_mini_camera_gui(player, target)
else
remove_player_data(player)
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()
for p, data in pairs(this.players) do
if data and data.target_player and data.target_player.valid then
local target_player = data.target_player
if data and data.target and data.target.valid then
local target = data.target
local camera_frame = data.camera_frame
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)
goto continue
end
@ -161,8 +161,8 @@ local function on_nth_tick()
goto continue
end
camera_frame.position = target_player.position
camera_frame.surface_index = target_player.surface.index
camera_frame.position = target.position
camera_frame.surface_index = target.surface.index
::continue::
end

View File

@ -78,9 +78,11 @@ end
local function add_revoked(name, admin, reason)
if name then
local date = Server.get_current_date_with_time()
if not revoked_permissions[name] then
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
else
return false
@ -429,10 +431,7 @@ local function vote_to_jail(player, griefer, msg)
votejail[griefer][player.name] = true
votejail[griefer].index = votejail[griefer].index + 1
Utils.print_to(player, 'You have voted to jail player ' .. griefer .. '.')
if
votejail[griefer].index >= settings.votejail_count or
(votejail[griefer].index == #game.connected_players - 1 and #game.connected_players > votejail[griefer].index)
then
if 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)
end
else
@ -460,10 +459,7 @@ local function vote_to_free(player, griefer)
votefree[griefer].index = votefree[griefer].index + 1
Utils.print_to(player, 'You have voted to free player ' .. griefer .. '.')
if
votefree[griefer].index >= settings.votejail_count or
(votefree[griefer].index == #game.connected_players - 1 and #game.connected_players > votefree[griefer].index)
then
if 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)
votejail[griefer] = nil
votefree[griefer] = nil
@ -496,6 +492,8 @@ local function jail(player, griefer, msg, raised)
local gulag = get_gulag_permission_group()
gulag.add_player(griefer)
local date = Server.get_current_date_with_time()
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
@ -504,7 +502,7 @@ local function jail(player, griefer, msg, raised)
jailed[griefer] = {jailed = true, actor = player, reason = msg}
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
Utils.print_to(nil, message)
@ -700,12 +698,11 @@ Server.on_data_set_changed(
end
local v = data.value
local k = data.key
if v and v.actor then
if v.jailed then
jail(v.actor, data.key, v.reason, true)
elseif not v.jailed then
free('script', data.key)
end
jail(v.actor, data.key, v.reason, true)
elseif k then
free('script', data.key)
end
end
)
@ -725,7 +722,6 @@ commands.add_command(
'jail',
'Sends the player to gulag! Valid arguments are:\n/jail <LuaPlayer> <reason>',
function()
return
end
)
@ -733,7 +729,6 @@ commands.add_command(
'free',
'Brings back the player from gulag.',
function()
return
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 cmd == 'jail' then
if not terms_tbl[player.name] then
Utils.warning(
player,
'Abusing the jail command will lead to revoked permissions. Jailing someone in case of disagreement is _NEVER_ OK!'
)
Utils.warning(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, 'Run this command again to if you really want to do this!')
for i = 1, 4 do
@ -909,10 +901,7 @@ Event.add(
if player.admin or playtime >= settings.playtime_for_instant_jail then
if cmd == 'jail' then
if not terms_tbl[player.name] then
Utils.warning(
player,
'Abusing the jail command will lead to revoked permissions. Jailing someone in case of disagreement is _NEVER_ OK!'
)
Utils.warning(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!')
for i = 1, 4 do
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 module_name = Gui.uid_name()
local locate_player_frame_name = Gui.uid_name()
local poke_player_frame_name = Gui.uid_name()
local this = {
player_list = {
@ -660,14 +662,21 @@ local function player_list_show(data)
return
end
local name_label =
local name_flow =
player_list_panel_table.add {
type = 'flow'
}
local name_label =
name_flow.add {
type = 'label',
name = p.index,
name = locate_player_frame_name,
caption = caption,
tooltip = tooltip
}
Gui.set_data(name_label, p.index)
local p_color = game.players[player_list[i].player_index]
name_label.style.font = 'default'
name_label.style.font_color = {
@ -716,20 +725,21 @@ local function player_list_show(data)
current_label.style.font = 'heading-3'
-- Poke
local flow = player_list_panel_table.add {type = 'flow', name = 'button_flow_' .. i, direction = 'horizontal'}
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}
button.style.font = 'default'
button.tooltip = 'Poke ' .. player_list[i].name .. ' with a random message!'
local poke_flow = player_list_panel_table.add {type = 'flow', name = 'button_flow_' .. i, direction = 'horizontal'}
poke_flow.add {type = 'label', name = 'button_spacer_' .. i, caption = ''}
local poke_button = poke_flow.add {type = 'button', name = poke_player_frame_name, caption = player_list[i].pokes}
Gui.set_data(poke_button, p.index)
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}
button.style.minimal_height = 30
button.style.minimal_width = 30
button.style.maximal_height = 30
button.style.maximal_width = 30
button.style.top_padding = 0
button.style.left_padding = 0
button.style.right_padding = 0
button.style.bottom_padding = 0
poke_button.style.minimal_height = 30
poke_button.style.minimal_width = 30
poke_button.style.maximal_height = 30
poke_button.style.maximal_width = 30
poke_button.style.top_padding = 0
poke_button.style.left_padding = 0
poke_button.style.right_padding = 0
poke_button.style.bottom_padding = 0
end
end
@ -851,49 +861,67 @@ local function on_gui_click(event)
actions[name]()
return
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')
if is_spamming then
return
end
local target = game.get_player(index)
local target = game.get_player(data)
if not target or not target.valid then
Gui.set_data(element, nil)
return
end
Gui.set_data(element, nil)
Where.create_mini_camera_gui(player, target)
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')
if is_spamming then
)
Gui.on_click(
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
end
local poked_player = string.sub(element.name, 13, string.len(element.name))
if player.name == poked_player then
local target = game.get_player(data)
if player.index == target.index then
Gui.set_data(element, nil)
return
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 = '>> '
str = str .. player.name
str = str .. ' has poked '
str = str .. poked_player
str = str .. target.name
str = str .. ' with '
local z = math.random(1, #pokemessages)
str = str .. pokemessages[z]
str = str .. ' <<'
game.print(str)
this.player_list.last_poke_tick[element.player_index] = game.tick
local p = game.players[poked_player]
this.player_list.pokes[p.index] = this.player_list.pokes[p.index] + 1
this.player_list.last_poke_tick[player.index] = game.tick
this.player_list.pokes[target.index] = this.player_list.pokes[target.index] + 1
Gui.set_data(element, nil)
end
end
end
)
local function refresh()
for _, player in pairs(game.connected_players) do