Exit243 Posted March 8, 2021 While mapping in Slade I've written some editor scripts to speed up texturing. Now I realize they might be worth sharing because scenarios seem quite common. First script selects all adjacent sectors that have the same floor texture as currently selected sectors. Second script selects all adjacent lines that have the same front textures as currently selected lines. Third script select all lines in-between adjacent sectors that have the same front textures as currently selected lines. To use scripts, click Tools -> Script Manager -> New Editor Script -> Type: Map Editor -> Paste the name -> OK -> Paste code -> Save Then go back to map editor, select some sectors/lines, click Tools -> Run Script -> Scriptname select_connected_floor_textures.lua Spoiler -- 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 editor = App.mapEditor() local selectedSectors = editor:selectedSectors() if #selectedSectors == 0 then App.logMessage('Select Connected Floor Textures: No Sectors Selected') return end local seen = {} local queue = {} local targetTexture = selectedSectors[1].textureFloor for i = 1, #selectedSectors do local sector = selectedSectors[i] table.insert(queue, sector) seen[sector.index] = true end while true do local isQueueEmpty = true for i, entry in ipairs(queue) do if entry then local connectedSides = entry.connectedSides for j = 1, #connectedSides do local line = connectedSides[j].line local sideSectors = { line.side1.sector, line.side2.sector } for _, sector in ipairs(sideSectors) do if not seen[sector.index] then if sector.textureFloor == targetTexture then editor:select(sector) table.insert(queue, sector) end seen[sector.index] = true end end end isQueueEmpty = false queue[i] = nil end end if isQueueEmpty then break end end App.logMessage('Select Connected Floor Textures: Success') end select_connected_line_textures.lua Spoiler -- 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 editor = App.mapEditor() local selectedLines = editor:selectedLines() if #selectedLines == 0 then App.logMessage('Select Connected Line Textures: No Lines Selected') return end local seen = {} local queue = {} local targetTextureBottom = selectedLines[1].side1.textureBottom local targetTextureMiddle = selectedLines[1].side1.textureMiddle local targetTextureTop = selectedLines[1].side1.textureTop for i = 1, #selectedLines do local line = selectedLines[i] table.insert(queue, line) seen[line.index] = true end while true do local isQueueEmpty = true for i, entry in ipairs(queue) do if entry then local vertices = { entry.vertex1, entry.vertex2 } for j = 1, #vertices do local vertex = vertices[j] local connectedLines = vertex:connectedLines() for k = 1, #connectedLines do local line = connectedLines[k] if not seen[line.index] then local bottomMatch = line.side1.textureBottom == targetTextureBottom local middleMatch = line.side1.textureMiddle == targetTextureMiddle local topMatch = line.side1.textureTop == targetTextureTop if bottomMatch and middleMatch and topMatch then editor:select(line) table.insert(queue, line) end seen[line.index] = true end end end isQueueEmpty = false queue[i] = nil end end if isQueueEmpty then break end end App.logMessage('Select Connected Line Textures: Success') end select_connected_stairs_textures.lua Spoiler -- 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 editor = App.mapEditor() local selectedLines = editor:selectedLines() if #selectedLines == 0 then App.logMessage('Select Connected Stairs Textures: No Lines Selected') return end local seen = {} local queue = {} local targetTextureBottom = selectedLines[1].side1.textureBottom local targetTextureMiddle = selectedLines[1].side1.textureMiddle local targetTextureTop = selectedLines[1].side1.textureTop for i = 1, #selectedLines do local line = selectedLines[i] table.insert(queue, line) seen[line.index] = true end while true do local isQueueEmpty = true for i, entry in ipairs(queue) do if entry then -- line -> sides -> sectors -> lines local sides = { entry.side1, entry.side2 } for j = 1, #sides do local sector = sides[j].sector local connectedSides = sector.connectedSides for k = 1, #connectedSides do local line = connectedSides[k].line if not seen[line.index] then local bottomMatch = line.side1.textureBottom == targetTextureBottom local middleMatch = line.side1.textureMiddle == targetTextureMiddle local topMatch = line.side1.textureTop == targetTextureTop if bottomMatch and middleMatch and topMatch then editor:select(line) table.insert(queue, line) end seen[line.index] = true end end end isQueueEmpty = false queue[i] = nil end end if isQueueEmpty then break end end App.logMessage('Select Connected Stairs Textures: Success') end 0 Quote Share this post Link to post
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.