SLADE
SLADE copied to clipboard
Enable Lua scripts to change the coordinates of map vertices
SLADE Version: 3.1.11 Operating System: Linux
Issue Details: I've written the following script to rescale a map on the X and Y dimensions:
-- A map script will run the execute function (below) on the current map
-- Map scripts can be selected and run from the "Tools->Run Script" menu in the map editor
function execute(map)
local scale = App.promptNumber('Rescale Map', 'What scale factor?', 1, 0, 1024)
if scale then
for i,v in ipairs(map.vertices) do
v:setFloatProperty('x', scale * v:x())
v:setFloatProperty('y', scale * v:y())
end
for i,t in ipairs(map.things) do
t:setFloatProperty('x', scale * t.x)
t:setFloatProperty('y', scale * t.y)
end
end
end
It works fine for the Things on the map, but the vertices don't move.
I just looked at the Console window and now I see a message saying that the X and Y properties of vertices can't be changed via scripting. If there's no way to make this work, one suggestion I have is to at least open the output window to display that message.
I'll leave this open as an enhancement request for adding the functionality to change these properties; if this isn't something you think would be worth adding, feel free to close it of course.