Fixed other errors

This commit is contained in:
Cooldude2606
2021-05-06 01:10:54 +01:00
parent 6e00b2cd40
commit ecf2c59bb1
4 changed files with 5 additions and 3 deletions

View File

@@ -30,7 +30,7 @@ Event.on_nth_tick(config.update_time, function()
-- Check for active players
for _, player in ipairs(game.connected_players) do
if player.afk_time < config.afk_time
or config.admin_as_active and config.player.admin
or config.admin_as_active and player.admin
or config.trust_as_active and player.online_time > config.trust_time
or config.active_role and Roles.player_has_role(player, config.active_role) then
-- Active player was found

View File

@@ -55,7 +55,7 @@ local function sort_players(players, func)
for index, player in ipairs(players) do
local value = func(player)
-- Check if the item will make the top 5 elements
if value > threshold or index <= 5 then
if index <= 5 or value > threshold then
local inserted = false
values[player] = value
-- Find where in the top 5 to insert the element

View File

@@ -157,7 +157,7 @@ Event.add(defines.events.on_pre_player_mined_item, function(event)
local player = game.get_player(event.player_index)
-- Check if the player should be ignored
if config.ignore_admins and player.admin then return end
if entity.last_user.index == player.index then return end
if entity.last_user == nil or entity.last_user.index == player.index then return end
if config.ignore_permission and Roles.player_allowed(player, config.ignore_permission) then return end
-- Check if the entity is protected

View File

@@ -35,9 +35,11 @@ function Public.start_spectate(player)
assert(player and player.valid, 'Invalid player given to follower')
if spectating[player.index] or not player.character then return false end
local character = player.character
local opened = player.opened
player.set_controller{ type = defines.controllers.spectator }
player.associate_character(character)
spectating[player.index] = character
if opened then player.opened = opened end -- Maintain opened after controller change
return true
end