Quick fix for player physical position

This commit is contained in:
Cooldude2606
2024-10-19 18:30:58 +01:00
parent 90d0a122cd
commit 34a7879761
31 changed files with 82 additions and 41 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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,
}

View File

@@ -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)

View File

@@ -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)

View File

@@ -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 }

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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()