Skip to content

Instantly share code, notes, and snippets.

@Talon1024
Created December 9, 2017 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Talon1024/5bbb2251f321e044926f68e9709d0f3d to your computer and use it in GitHub Desktop.
Save Talon1024/5bbb2251f321e044926f68e9709d0f3d to your computer and use it in GitHub Desktop.
SLADE script - replace textures
-- 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