From 34a78797615a819217f8a4f01d84948484b9c772 Mon Sep 17 00:00:00 2001 From: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com> Date: Sat, 19 Oct 2024 18:30:58 +0100 Subject: [PATCH] Quick fix for player physical position --- exp_commands/module/commands/authorities.lua | 22 ++++++++++++++++++- exp_commands/module/locale/en.cfg | 2 ++ .../module/config/gui/player_list_actions.lua | 4 ++-- .../module/modules/addons/advanced-start.lua | 6 ++--- .../module/modules/addons/death-logger.lua | 6 ++--- exp_legacy/module/modules/addons/deconlog.lua | 6 ++--- .../module/modules/addons/lawnmower.lua | 1 + .../module/modules/addons/nukeprotect.lua | 2 +- .../module/modules/addons/scorched-earth.lua | 5 +++-- .../module/modules/addons/spawn-area.lua | 2 +- .../module/modules/commands/artillery.lua | 1 + .../module/modules/commands/cheat-mode.lua | 1 + .../modules/commands/clear-inventory.lua | 2 +- exp_legacy/module/modules/commands/enemy.lua | 1 + exp_legacy/module/modules/commands/find.lua | 2 +- exp_legacy/module/modules/commands/home.lua | 8 +++---- .../module/modules/commands/last-location.lua | 2 +- .../module/modules/commands/pollution.lua | 1 + .../module/modules/commands/protection.lua | 1 + exp_legacy/module/modules/commands/repair.lua | 2 ++ .../modules/commands/surface-clearing.lua | 2 ++ .../module/modules/commands/teleport.lua | 4 ++-- .../module/modules/commands/waterfill.lua | 3 ++- exp_legacy/module/modules/control/warps.lua | 6 ++--- .../module/modules/factorio-control.lua | 5 ++++- exp_legacy/module/modules/gui/module.lua | 2 ++ exp_legacy/module/modules/gui/player-list.lua | 2 +- exp_legacy/module/modules/gui/production.lua | 1 + .../module/modules/gui/surveillance.lua | 4 ++-- exp_legacy/module/modules/gui/vlayer.lua | 10 ++++----- exp_legacy/module/modules/gui/warp-list.lua | 7 +++--- 31 files changed, 82 insertions(+), 41 deletions(-) diff --git a/exp_commands/module/commands/authorities.lua b/exp_commands/module/commands/authorities.lua index 1403507b..ee9be190 100644 --- a/exp_commands/module/commands/authorities.lua +++ b/exp_commands/module/commands/authorities.lua @@ -58,7 +58,27 @@ function Commands.get_disabled_commands() return table.get_keys(disabled_commands) end ---- If a command has the flag "admin_only" then only admins can use the command# +--- If a command has the flag "character_only" then the command can only be used outside of remote view +authorities.character_only = + add(function(player, command) + if command.flags.character_only and player.controller_type ~= defines.controllers.character then + return deny{ "exp-commands-permissions.character-only" } + else + return allow() + end + end) + +--- If a command has the flag "remote_only" then the command can only be used inside of remote view +authorities.remote_only = + add(function(player, command) + if command.flags.character_only and player.controller_type ~= defines.controllers.remote then + return deny{ "exp-commands-permissions.remote-only" } + else + return allow() + end + end) + +--- If a command has the flag "admin_only" then only admins can use the command authorities.admin_only = add(function(player, command) if command.flags.admin_only and not player.admin then diff --git a/exp_commands/module/locale/en.cfg b/exp_commands/module/locale/en.cfg index 13e9c736..47f1d00e 100644 --- a/exp_commands/module/locale/en.cfg +++ b/exp_commands/module/locale/en.cfg @@ -30,6 +30,8 @@ surface=Invalid Surface Name. color=Invalid Color Name. [exp-commands-permissions] +character-only=This command can not be used in remote view. +remote-only=This command can only be used in remote view. admin-only=This command is for game admins only. system-only=This command can not be ran by players. disabled=This command is currently disabled. diff --git a/exp_legacy/module/config/gui/player_list_actions.lua b/exp_legacy/module/config/gui/player_list_actions.lua index a8c64331..520971a1 100644 --- a/exp_legacy/module/config/gui/player_list_actions.lua +++ b/exp_legacy/module/config/gui/player_list_actions.lua @@ -38,8 +38,8 @@ end -- teleports one player to another local function teleport(from_player, to_player) - local surface = to_player.surface - local position = surface.find_non_colliding_position("character", to_player.position, 32, 1) + local surface = to_player.physical_surface + local position = surface.find_non_colliding_position("character", to_player.physical_position, 32, 1) if not position then return false end -- return false if no new position if from_player.driving then from_player.driving = false end -- kicks a player out a vehicle if in one from_player.teleport(position, surface) diff --git a/exp_legacy/module/modules/addons/advanced-start.lua b/exp_legacy/module/modules/addons/advanced-start.lua index 9126dbe8..2d8f0864 100644 --- a/exp_legacy/module/modules/addons/advanced-start.lua +++ b/exp_legacy/module/modules/addons/advanced-start.lua @@ -12,13 +12,13 @@ Event.add(defines.events.on_player_created, function(event) player.force.friendly_fire = config.friendly_fire game.map_settings.enemy_expansion.enabled = config.enemy_expansion local r = config.chart_radius - local p = player.position - player.force.chart(player.surface, { { p.x - r, p.y - r }, { p.x + r, p.y + r } }) + local p = player.physical_position + player.force.chart(player.physical_surface, { { p.x - r, p.y - r }, { p.x + r, p.y + r } }) end -- spawn items for item, callback in pairs(items) do if type(callback) == "function" then - local stats = player.force.get_item_production_statistics(player.surface) + local stats = player.force.get_item_production_statistics(player.physical_surface) local made = stats.get_input_count(item) local success, count = pcall(callback, made, stats.get_input_count, player) count = math.floor(count) diff --git a/exp_legacy/module/modules/addons/death-logger.lua b/exp_legacy/module/modules/addons/death-logger.lua index f5458be7..a1b9531a 100644 --- a/exp_legacy/module/modules/addons/death-logger.lua +++ b/exp_legacy/module/modules/addons/death-logger.lua @@ -27,7 +27,7 @@ local function create_map_tag(death) local time = map_tag_time_format(death.time_of_death) message = message .. " at " .. time end - death.tag = player.force.add_chart_tag(player.surface, { + death.tag = player.force.add_chart_tag(player.physical_surface, { position = death.position, icon = config.map_icon, text = message, @@ -65,7 +65,7 @@ end --- @param event EventData.on_player_died Event.add(defines.events.on_player_died, function(event) local player = game.players[event.player_index] - local corpse = player.surface.find_entity("character-corpse", player.position) + local corpse = player.surface.find_entity("character-corpse", player.physical_position) if not corpse or not corpse.valid then return end if config.use_chests_as_bodies then local inventory = assert(corpse.get_inventory(defines.inventory.character_corpse)) @@ -83,7 +83,7 @@ Event.add(defines.events.on_player_died, function(event) local death = { player_name = player.name, time_of_death = event.tick, - position = player.position, + position = player.physical_position, corpse = corpse, } if config.show_map_markers then diff --git a/exp_legacy/module/modules/addons/deconlog.lua b/exp_legacy/module/modules/addons/deconlog.lua index ff539da3..5b941c6e 100644 --- a/exp_legacy/module/modules/addons/deconlog.lua +++ b/exp_legacy/module/modules/addons/deconlog.lua @@ -98,7 +98,7 @@ if config.fired_rocket then return end if item.name == "rocket" then - add_log(get_secs() .. "," .. player.name .. ",shot-rocket," .. pos_to_string(player.position) .. "," .. pos_to_string(player.shooting_state.position)) + add_log(get_secs() .. "," .. player.name .. ",shot-rocket," .. pos_to_string(player.physical_position) .. "," .. pos_to_string(player.shooting_state.position)) end end) end @@ -117,7 +117,7 @@ if config.fired_explosive_rocket then return end if item.name == "explosive-rocket" then - add_log(get_secs() .. "," .. player.name .. ",shot-explosive-rocket," .. pos_to_string(player.position) .. "," .. pos_to_string(player.shooting_state.position)) + add_log(get_secs() .. "," .. player.name .. ",shot-explosive-rocket," .. pos_to_string(player.physical_position) .. "," .. pos_to_string(player.shooting_state.position)) end end) end @@ -138,7 +138,7 @@ if config.fired_nuke then end if item.name == "atomic-bomb" then - add_log(get_secs() .. "," .. player.name .. ",shot-nuke," .. pos_to_string(player.position) .. "," .. pos_to_string(player.shooting_state.position)) + add_log(get_secs() .. "," .. player.name .. ",shot-nuke," .. pos_to_string(player.physical_position) .. "," .. pos_to_string(player.shooting_state.position)) end end) end diff --git a/exp_legacy/module/modules/addons/lawnmower.lua b/exp_legacy/module/modules/addons/lawnmower.lua index 8c91f4f2..cadb324a 100644 --- a/exp_legacy/module/modules/addons/lawnmower.lua +++ b/exp_legacy/module/modules/addons/lawnmower.lua @@ -13,6 +13,7 @@ Commands.new_command("lawnmower", "Clean up biter corpse, decoratives and nuclea :register(function(player, range) local tile_to_do = {} + -- Intentionally left as player.position to allow use in remote view player.surface.destroy_decoratives{ position = player.position, radius = range } local entities = player.surface.find_entities_filtered{ position = player.position, radius = range, type = "corpse" } diff --git a/exp_legacy/module/modules/addons/nukeprotect.lua b/exp_legacy/module/modules/addons/nukeprotect.lua index b820a63f..e474de28 100644 --- a/exp_legacy/module/modules/addons/nukeprotect.lua +++ b/exp_legacy/module/modules/addons/nukeprotect.lua @@ -27,7 +27,7 @@ local function check_items(player, type) ExpUtil.move_items_to_surface{ items = items, - surface = player.surface, + surface = game.planets.nauvis.surface, allow_creation = true, name = "iron-chest", } diff --git a/exp_legacy/module/modules/addons/scorched-earth.lua b/exp_legacy/module/modules/addons/scorched-earth.lua index d4568152..bc143d9b 100644 --- a/exp_legacy/module/modules/addons/scorched-earth.lua +++ b/exp_legacy/module/modules/addons/scorched-earth.lua @@ -75,8 +75,9 @@ end -- When the player changes position the tile will have a chance to downgrade, debug check is here Event.add(defines.events.on_player_changed_position, function(event) local player = game.players[event.player_index] - local surface = player.surface - local position = player.position + if player.controller_type ~= defines.controllers.character then return end + local surface = player.physical_surface + local position = player.physical_position local strength = get_tile_strength(surface, position) if not strength then return end if get_probability(strength) > math.random() then diff --git a/exp_legacy/module/modules/addons/spawn-area.lua b/exp_legacy/module/modules/addons/spawn-area.lua index 439c047b..8550f434 100644 --- a/exp_legacy/module/modules/addons/spawn-area.lua +++ b/exp_legacy/module/modules/addons/spawn-area.lua @@ -222,7 +222,7 @@ Event.add(defines.events.on_player_created, function(event) if event.player_index ~= 1 then return end local player = game.players[event.player_index] local p = { x = 0, y = 0 } - local s = player.surface + local s = player.physical_surface get_spawn_force() spawn_area(s, p) if config.pattern.enabled then spawn_pattern(s, p) end diff --git a/exp_legacy/module/modules/commands/artillery.lua b/exp_legacy/module/modules/commands/artillery.lua index 7890ed53..fe6484d6 100644 --- a/exp_legacy/module/modules/commands/artillery.lua +++ b/exp_legacy/module/modules/commands/artillery.lua @@ -9,6 +9,7 @@ local Selection = require("modules.exp_legacy.modules.control.selection") --- @d local SelectionArtyArea = "ArtyArea" local function location_break(player, pos) + -- Intentionally left as player.surface to allow use in remote view if player.force.is_chunk_charted(player.surface, { x = math.floor(pos.left_top.x / 32), y = math.floor(pos.left_top.y / 32) }) then return true elseif player.force.is_chunk_charted(player.surface, { x = math.floor(pos.left_top.x / 32), y = math.floor(pos.right_bottom.y / 32) }) then diff --git a/exp_legacy/module/modules/commands/cheat-mode.lua b/exp_legacy/module/modules/commands/cheat-mode.lua index 8bf2ac92..4aacd0c7 100644 --- a/exp_legacy/module/modules/commands/cheat-mode.lua +++ b/exp_legacy/module/modules/commands/cheat-mode.lua @@ -36,6 +36,7 @@ Commands.new_command("toggle-always-day", { "expcom-cheat.description-day" }, "T :set_flag("admin_only") :add_param("surface", true, "surface") :set_defaults{ surface = function(player) + -- Intentionally left as player.surface to allow use in remote view return player.surface end } :register(function(player, surface) diff --git a/exp_legacy/module/modules/commands/clear-inventory.lua b/exp_legacy/module/modules/commands/clear-inventory.lua index 25d0de04..9b0f6977 100644 --- a/exp_legacy/module/modules/commands/clear-inventory.lua +++ b/exp_legacy/module/modules/commands/clear-inventory.lua @@ -21,7 +21,7 @@ Commands.new_command("clear-inventory", { "expcom-clr-inv.description" }, "Clear ExpUtil.transfer_inventory_to_surface{ inventory = inventory, - surface = player.surface, + surface = game.planets.nauvis.surface, name = "iron-chest", allow_creation = true, } diff --git a/exp_legacy/module/modules/commands/enemy.lua b/exp_legacy/module/modules/commands/enemy.lua index 9ccdf5c5..7af03f2d 100644 --- a/exp_legacy/module/modules/commands/enemy.lua +++ b/exp_legacy/module/modules/commands/enemy.lua @@ -17,6 +17,7 @@ Commands.new_command("remove-biters", { "expcom-enemy.description-remove" }, "Re :set_flag("admin_only") :add_param("surface", true, "surface") :set_defaults{ surface = function(player) + -- Intentionally left as player.surface to allow use in remote view return player.surface end } :register(function(_, surface) diff --git a/exp_legacy/module/modules/commands/find.lua b/exp_legacy/module/modules/commands/find.lua index c57fbaf2..54c27b90 100644 --- a/exp_legacy/module/modules/commands/find.lua +++ b/exp_legacy/module/modules/commands/find.lua @@ -13,7 +13,7 @@ Commands.new_command("find-on-map", { "expcom-find.description" }, "Find a playe :add_param("player", false, "player-online") :add_alias("find", "zoom-to") :register(function(player, action_player) - local position = action_player.position + local position = action_player.physical_position player.zoom_to_world(position, 1.75) return Commands.success -- prevents command complete message from showing end) diff --git a/exp_legacy/module/modules/commands/home.lua b/exp_legacy/module/modules/commands/home.lua index f34567a4..f0bf766f 100644 --- a/exp_legacy/module/modules/commands/home.lua +++ b/exp_legacy/module/modules/commands/home.lua @@ -13,7 +13,7 @@ Storage.register(homes, function(tbl) end) local function teleport(player, position) - local surface = player.surface + local surface = player.physical_surface local pos = surface.find_non_colliding_position("character", position, 32, 1) if not position then return false end if player.driving then player.driving = false end -- kicks a player out a vehicle if in one @@ -36,7 +36,7 @@ Commands.new_command("home", { "expcom-home.description-home" }, "Teleports you if not home or not home[1] then return Commands.error{ "expcom-home.no-home" } end - local rtn = floor_pos(player.position) + local rtn = floor_pos(player.physical_position) teleport(player, home[1]) home[2] = rtn Commands.print{ "expcom-home.return-set", rtn.x, rtn.y } @@ -51,7 +51,7 @@ Commands.new_command("home-set", { "expcom-home.description-home-set" }, "Sets y home = {} homes[player.index] = home end - local pos = floor_pos(player.position) + local pos = floor_pos(player.physical_position) home[1] = pos Commands.print{ "expcom-home.home-set", pos.x, pos.y } end) @@ -76,7 +76,7 @@ Commands.new_command("return", { "expcom-home.description-return" }, "Teleports if not home or not home[2] then return Commands.error{ "expcom-home.no-return" } end - local rtn = floor_pos(player.position) + local rtn = floor_pos(player.physical_position) teleport(player, home[2]) home[2] = rtn Commands.print{ "expcom-home.return-set", rtn.x, rtn.y } diff --git a/exp_legacy/module/modules/commands/last-location.lua b/exp_legacy/module/modules/commands/last-location.lua index e761bf05..67a10134 100644 --- a/exp_legacy/module/modules/commands/last-location.lua +++ b/exp_legacy/module/modules/commands/last-location.lua @@ -16,5 +16,5 @@ Commands.new_command("last-location", { "expcom-lastlocation.description" }, "Se :add_param("player", false, "player") :register(function(_, action_player) local action_player_name_color = format_player_name(action_player) - return Commands.success{ "expcom-lastlocation.response", action_player_name_color, string.format("%.1f", action_player.position.x), string.format("%.1f", action_player.position.y) } + return Commands.success{ "expcom-lastlocation.response", action_player_name_color, string.format("%.1f", action_player.physical_position.x), string.format("%.1f", action_player.physical_position.y) } end) diff --git a/exp_legacy/module/modules/commands/pollution.lua b/exp_legacy/module/modules/commands/pollution.lua index a968f179..0704d0bc 100644 --- a/exp_legacy/module/modules/commands/pollution.lua +++ b/exp_legacy/module/modules/commands/pollution.lua @@ -11,6 +11,7 @@ Commands.new_command("pollution-clear", { "expcom-pol.description-clr" }, "Clear :add_alias("pol-clr") :add_param("surface", true, "surface") :set_defaults{ surface = function(player) + -- Intentionally left as player.surface to allow use in remote view return player.surface end } :register(function(player, surface) diff --git a/exp_legacy/module/modules/commands/protection.lua b/exp_legacy/module/modules/commands/protection.lua index ca85750c..b8311da1 100644 --- a/exp_legacy/module/modules/commands/protection.lua +++ b/exp_legacy/module/modules/commands/protection.lua @@ -177,6 +177,7 @@ end) Event.add(Selection.events.on_player_selection_start, function(event) if event.selection ~= SelectionProtectEntity and event.selection ~= SelectionProtectArea then return end local player = game.players[event.player_index] + -- Intentionally left as player.surface to allow use in remote view local surface = player.surface renders[player.index] = {} -- Show protected entities diff --git a/exp_legacy/module/modules/commands/repair.lua b/exp_legacy/module/modules/commands/repair.lua index b3c15f96..3e3aad66 100644 --- a/exp_legacy/module/modules/commands/repair.lua +++ b/exp_legacy/module/modules/commands/repair.lua @@ -17,7 +17,9 @@ Commands.new_command("repair", { "expcom-repair.description" }, "Repairs entitie local revive_count = 0 local heal_count = 0 local range2 = range ^ 2 + -- Intentionally left as player.surface to allow use in remote view local surface = player.surface + -- Intentionally left as player.position to allow use in remote view local center = player.position local area = { { x = center.x - range, y = center.y - range }, { x = center.x + range, y = center.y + range } } if config.allow_ghost_revive then diff --git a/exp_legacy/module/modules/commands/surface-clearing.lua b/exp_legacy/module/modules/commands/surface-clearing.lua index b859a40d..67b1f25e 100644 --- a/exp_legacy/module/modules/commands/surface-clearing.lua +++ b/exp_legacy/module/modules/commands/surface-clearing.lua @@ -11,6 +11,7 @@ Commands.new_command("clear-item-on-ground", { "expcom-surface-clearing.descript :add_param("range", false, "integer-range", 1, 1000) :register(function(player, range) local items = {} --- @type LuaItemStack[] + -- Intentionally left as player.position to allow use in remote view local entities = player.surface.find_entities_filtered{ position = player.position, radius = range, name = "item-on-ground" } for _, e in pairs(entities) do if e.stack then @@ -31,6 +32,7 @@ Commands.new_command("clear-item-on-ground", { "expcom-surface-clearing.descript Commands.new_command("clear-blueprint", { "expcom-surface-clearing.description-cb" }, "Clear Blueprint") :add_param("range", false, "integer-range", 1, 1000) :register(function(player, range) + -- Intentionally left as player.position to allow use in remote view for _, e in pairs(player.surface.find_entities_filtered{ position = player.position, radius = range, type = "entity-ghost" }) do e.destroy() end diff --git a/exp_legacy/module/modules/commands/teleport.lua b/exp_legacy/module/modules/commands/teleport.lua index 43bcd981..90b59378 100644 --- a/exp_legacy/module/modules/commands/teleport.lua +++ b/exp_legacy/module/modules/commands/teleport.lua @@ -7,8 +7,8 @@ local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore require("modules.exp_legacy.config.expcore.command_general_parse") local function teleport(from_player, to_player) - local surface = to_player.surface - local position = surface.find_non_colliding_position("character", to_player.position, 32, 1) + local surface = to_player.physical_surface + local position = surface.find_non_colliding_position("character", to_player.physical_position, 32, 1) -- return false if no new position if not position then diff --git a/exp_legacy/module/modules/commands/waterfill.lua b/exp_legacy/module/modules/commands/waterfill.lua index a403ee19..137843d1 100644 --- a/exp_legacy/module/modules/commands/waterfill.lua +++ b/exp_legacy/module/modules/commands/waterfill.lua @@ -41,7 +41,7 @@ Selection.on_selection(SelectionConvertArea, function(event) return end - local entities = player.surface.find_entities_filtered{ area = area, name = "steel-chest" } + local entities = event.surface.find_entities_filtered{ area = area, name = "steel-chest" } if #entities == 0 then player.print("No steel chest found") @@ -60,6 +60,7 @@ Selection.on_selection(SelectionConvertArea, function(event) for _, entity in pairs(entities) do if clf_exp >= 1 then if entity.get_inventory(defines.inventory.chest).is_empty() then + -- Intentionally left as player.position to allow use in report view if (math.floor(player.position.x) ~= math.floor(entity.position.x)) or (math.floor(player.position.y) ~= math.floor(entity.position.y)) then table.insert(tiles_to_make, { name = "water-mud", position = entity.position }) entity.destroy() diff --git a/exp_legacy/module/modules/control/warps.lua b/exp_legacy/module/modules/control/warps.lua index 45006ae0..3707fe0d 100644 --- a/exp_legacy/module/modules/control/warps.lua +++ b/exp_legacy/module/modules/control/warps.lua @@ -6,7 +6,7 @@ @usage-- Making a new spawn warp local player = game.player local force = player.force -local spawn_id = Warps.add_warp(force.name, player.surface, player.position, player.name, 'Spawn') +local spawn_id = Warps.add_warp(force.name, player.physical_surface, player.physical_position, player.name, 'Spawn') Warps.set_spawn_warp(spawn_id, force) Warps.make_warp_tag(spawn_id) @@ -14,7 +14,7 @@ Warps.make_warp_tag(spawn_id) @usage-- Making a new warp with a warp area local player = game.player local force = player.force -local warp_id = Warps.add_warp(force.name, player.surface, player.position, player.name) +local warp_id = Warps.add_warp(force.name, player.physical_surface, player.physical_position, player.name) Warps.make_warp_area(warp_id) Warps.make_warp_tag(warp_id) @@ -313,7 +313,7 @@ end @usage-- Adding a new warp for your force at your position local player = game.player -local warp_id = Warps.add_warp(player.force.name, player.surface, player.position, player.name) +local warp_id = Warps.add_warp(player.force.name, player.physical_surface, player.physical_position, player.name) ]] function Warps.add_warp(force_name, surface, position, player_name, warp_name) diff --git a/exp_legacy/module/modules/factorio-control.lua b/exp_legacy/module/modules/factorio-control.lua index 6b99a579..7bd45a51 100644 --- a/exp_legacy/module/modules/factorio-control.lua +++ b/exp_legacy/module/modules/factorio-control.lua @@ -45,7 +45,10 @@ Event.add(defines.events.on_player_created, function(event) util.insert_safe(player, global.created_items) local r = global.chart_distance or 200 - player.force.chart(player.surface, { { player.position.x - r, player.position.y - r }, { player.position.x + r, player.position.y + r } }) + player.force.chart(player.physical_surface, { + { player.physical_position.x - r, player.physical_position.y - r }, + { player.physical_position.x + r, player.physical_position.y + r } + }) if not global.skip_intro then if game.is_multiplayer() then diff --git a/exp_legacy/module/modules/gui/module.lua b/exp_legacy/module/modules/gui/module.lua index cd93e53c..14d450f4 100644 --- a/exp_legacy/module/modules/gui/module.lua +++ b/exp_legacy/module/modules/gui/module.lua @@ -60,6 +60,7 @@ local elem_filter = { } local function clear_module(player, area, machine) + -- Intentionally left as player.surface to allow use in remote view for _, entity in pairs(player.surface.find_entities_filtered{ area = area, name = machine, force = player.force }) do for _, r in pairs(player.surface.find_entities_filtered{ position = entity.position, name = "item-request-proxy", force = player.force }) do if r then @@ -84,6 +85,7 @@ local function clear_module(player, area, machine) end local function apply_module(player, area, machine, modules) + -- Intentionally left as player.surface to allow use in remote view for _, entity in pairs(player.surface.find_entities_filtered{ area = area, name = machine, force = player.force }) do local m_current_recipe diff --git a/exp_legacy/module/modules/gui/player-list.lua b/exp_legacy/module/modules/gui/player-list.lua index 55d3e1d4..19b81055 100644 --- a/exp_legacy/module/modules/gui/player-list.lua +++ b/exp_legacy/module/modules/gui/player-list.lua @@ -117,7 +117,7 @@ local add_player_base = local selected_player = game.players[selected_player_name] if event.button == defines.mouse_button_type.left then -- LMB will open the map to the selected player - local position = selected_player.position + local position = selected_player.physical_position event.player.zoom_to_world(position, 1.75) else -- RMB will toggle the settings diff --git a/exp_legacy/module/modules/gui/production.lua b/exp_legacy/module/modules/gui/production.lua index 6c6026cb..a4bc0447 100644 --- a/exp_legacy/module/modules/gui/production.lua +++ b/exp_legacy/module/modules/gui/production.lua @@ -129,6 +129,7 @@ end) Event.on_nth_tick(60, function() for _, player in pairs(game.connected_players) do local frame = Gui.get_left_element(player, production_container) + -- Intentionally left as player.surface to allow use in remote view local stat = player.force.get_item_production_statistics(player.surface) local precision_value = precision[frame.container["production_st"].disp.table["production_0_e"].selected_index] local table = frame.container["production_st"].disp.table diff --git a/exp_legacy/module/modules/gui/surveillance.lua b/exp_legacy/module/modules/gui/surveillance.lua index 4aaa5a59..87187d12 100644 --- a/exp_legacy/module/modules/gui/surveillance.lua +++ b/exp_legacy/module/modules/gui/surveillance.lua @@ -52,7 +52,7 @@ local cctv_location = }:style{ width = 48, }:on_click(function(player, element, _) - element.parent.parent.parent.cctv_display.position = player.position + element.parent.parent.parent.cctv_display.position = player.physical_position end) local zoom_in = @@ -163,7 +163,7 @@ Event.add(defines.events.on_tick, function(_) if selected_index ~= 0 then selected_index = current_camera_set.buttons.table[cctv_player.name].items[selected_index] - current_camera_set["cctv_display"].position = game.players[selected_index].position + current_camera_set["cctv_display"].position = game.players[selected_index].physical_position current_camera_set["cctv_display"].surface_index = game.players[selected_index].surface_index else current_camera_set["cctv_display"].position = { x = 0, y = 0 } diff --git a/exp_legacy/module/modules/gui/vlayer.lua b/exp_legacy/module/modules/gui/vlayer.lua index 2af11cef..9047a6a2 100644 --- a/exp_legacy/module/modules/gui/vlayer.lua +++ b/exp_legacy/module/modules/gui/vlayer.lua @@ -80,7 +80,7 @@ Selection.on_selection(SelectionConvertArea, function(event) return nil end - local entities = player.surface.find_entities_filtered{ area = area, name = "steel-chest", force = player.force } + local entities = event.surface.find_entities_filtered{ area = area, name = "steel-chest", force = player.force } local frame = Gui.get_left_element(player, vlayer_container) local disp = frame.container["vlayer_st_2"].disp.table local target = vlayer_control_type_list[disp[vlayer_gui_control_type.name].selected_index] @@ -114,16 +114,16 @@ Selection.on_selection(SelectionConvertArea, function(event) e.destroy() if target == "energy" then - if not vlayer.create_energy_interface(player.surface, e_pos, player) then + if not vlayer.create_energy_interface(event.surface, e_pos, player) then player.print{ "vlayer.result-unable", { "vlayer.control-type-energy" }, { "vlayer.result-space" } } return nil end elseif target == "circuit" then - vlayer.create_circuit_interface(player.surface, e_pos, e_circ, player) + vlayer.create_circuit_interface(event.surface, e_pos, e_circ, player) elseif target == "storage_input" then - vlayer.create_input_interface(player.surface, e_pos, e_circ, player) + vlayer.create_input_interface(event.surface, e_pos, e_circ, player) elseif target == "storage_output" then - vlayer.create_output_interface(player.surface, e_pos, e_circ, player) + vlayer.create_output_interface(event.surface, e_pos, e_circ, player) end game.print{ "vlayer.interface-result", player.name, pos_to_gps_string(e_pos), { "vlayer.result-build" }, { "vlayer.control-type-" .. target:gsub("_", "-") } } diff --git a/exp_legacy/module/modules/gui/warp-list.lua b/exp_legacy/module/modules/gui/warp-list.lua index d086ff1a..e0bdb0d5 100644 --- a/exp_legacy/module/modules/gui/warp-list.lua +++ b/exp_legacy/module/modules/gui/warp-list.lua @@ -89,9 +89,10 @@ local add_new_warp = :style(Styles.sprite22) :on_click(function(player, _) -- Add the new warp + if player.controller_type ~= defines.controllers.character then return end local force_name = player.force.name - local surface = player.surface - local position = player.position + local surface = player.physical_surface + local position = player.physical_position -- Check if the warp is too close to water local water_tiles = surface.find_tiles_filtered{ collision_mask = "water-tile", radius = config.standard_proximity_radius + 1, position = position } @@ -783,7 +784,7 @@ Event.on_nth_tick(math.floor(60 / config.update_smoothing), function() local closest_distance = nil if #warp_ids > 0 then local surface = player.surface - local pos = player.position + local pos = player.physical_position local px, py = pos.x, pos.y -- Loop over each warp