improvement to moveSpawns so it can move multiple spawns correctly

This commit is contained in:
lustlion 2022-03-13 09:42:35 +01:00
parent a4af57ca6c
commit 62555b4526

View File

@ -47,10 +47,16 @@ function selectSpawns(x,y)
end end
function moveSpawns(x,y) function moveSpawns(x,y)
local difference_x = nil
local difference_y = nil
for _, spawn in pairs(LoadedObjects.Spawns) do for _, spawn in pairs(LoadedObjects.Spawns) do
if spawn.selected then if spawn.selected then
spawn.args[1] = math.floor((x/game.scale)+Camera.pos.x) if difference_x == nil then
spawn.args[2] = math.floor((y/game.scale)+Camera.pos.y) difference_x = math.floor((x/game.scale)+Camera.pos.x) - spawn.args[1]
difference_y = math.floor((y/game.scale)+Camera.pos.y) - spawn.args[2]
end
spawn.args[1] = spawn.args[1] + difference_x
spawn.args[2] = spawn.args[2] + difference_y
end end
end end
end end