Created
December 9, 2017 00:48
-
-
Save Talon1024/5bbb2251f321e044926f68e9709d0f3d to your computer and use it in GitHub Desktop.
SLADE script - replace textures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- SLADE: https://github.com/sirjuddington/SLADE | |
-- License: WTFPL | |
local editor = App.mapEditor() | |
local sideTexParts = { "textureBottom", "textureMiddle", "textureTop" } | |
local texsToReplace = { | |
["FNEW1"] = "METAL", | |
["N_MTSP3I"] = "AQSUPP01", | |
["N_MTSP3J"] = "AQRUST10", | |
["N_MTSP3F"] = "-", | |
["ABRICK1"] = "A-BRICK1" | |
} | |
local flatsToReplace = { | |
["FNEW1"] = "CEIL5_2", | |
["DEM2_6"] = "AQF045" | |
} | |
local secFlats = { "textureFloor", "textureCeiling" } | |
local sides = editor.map.sidedefs | |
-- Replace line textures | |
for sidx,side in ipairs(sides) do | |
for spidx,sidepart in ipairs(sideTexParts) do | |
local sdtx = side[sidepart] | |
local newtx = texsToReplace[sdtx] | |
if newtx ~= nil then | |
local sidepartk = string.lower(sidepart) -- It doesn't work if I don't do this | |
side:setStringProperty(sidepartk, newtx) | |
end | |
end | |
end | |
local sectors = editor.map.sectors | |
-- Replace flats | |
for scidx,sector in ipairs(sectors) do | |
for fli,flat in ipairs(secFlats) do | |
local curFlatx = sector[flat] | |
local newtx = flatsToReplace[curFlatx] | |
if newtx ~= nil then | |
local flatk = string.lower(flat) | |
sector:setStringProperty(flatk, newtx) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment