Finnisher Posted October 9, 2023 Hello, I'm helping a friend with mapping and saw they had at some point accidentally made the "outside" of their map a sector, namely all boundary linedefs were 2-sided. Deleting the sector fixed that but now there are nearly thousand linedefs missing a middle texture. The old texture is still there as either upper or lower though for most if not all, as they probably had retextured a lot of them after the sector accident. Could I write a script to copy upper or lower texture to middle texture for 1-sided linedefs with missing middle texture? That would make fixing the map so much easier. I'm using Doom Builder X but if for example UDB has better tools for such I'm all in. Or if Slade etc would be better suited. All help massively appreciated, I wanna help my friend make the map as they are naturally quite down now. Ofc can do it manually but hoping a script would be possible. So to recap along the lines: - IF linedef is 1-sided AND if linedef has upper OR lower texture AND no middle texture, copy upper/lower texture to middle texture (and optionally delete the upper/lower texture) 0 Quote Share this post Link to post
Worst Posted October 9, 2023 You could do this with UDB scripting. Here is an UDB script that could work: Spoiler `#version 4`; `#name Fill missing midtextures on 1-sided lines with lower or upper textures`; `#description Fills missing midtextures on 1-sided lines which contain textures on lower or upper parts. If both are present, lower takes priority over upper texture.`; // Get all selected lidedefs let lines = UDB.Map.getSelectedLinedefs(true); if(lines.length == 0) UDB.die('You need to select at least one linedef.'); let fill_count = 0; let progress_count = 0; lines.forEach(l => { // If line has no back side (1-sided) if (l.back == null) { if (l.front != null) { // Get the front sidedef. let s = l.front; // Middle texture must be missing if (s.middleTexture == "-") { // If lower texture exists, use it for middle if (s.lowerTexture !== "-") { s.middleTexture = s.lowerTexture; fill_count++; UDB.log("Linedef " + l.index + " middle texture filled with lower texture '" + s.lowerTexture + "'."); } // Otherwise if upper texture exists, use it for middle else if (s.upperTexture !== "-") { s.middleTexture = s.upperTexture; fill_count++; UDB.log("Linedef " + l.index + " middle texture filled with upper texture '" + s.upperTexture + "'."); } } } } progress_count++; UDB.setProgress( Math.round((progress_count/lines.length)*100) ); }); UDB.setProgress(100); UDB.log('Middle textures filled: ' + fill_count); The script needs to be saved in a text file with the '.js' (javascript) extension, for example "1sidedlinemidtexfill.js" and saved under the "UDBScript\Scripts" folder found inside the UltimateDoomBuilder folder. Then in UDB there is a bar on the right side of the editor that has a "Scripts" tab. From there you can select the script, and run it with the "Run" button at the bottom of that tab. Note that for this script, you need to select the lines that it should apply to. If you want, you can just select all lines in the map. It will still only apply it to 1-sided linedefs that match the conditions. 3 Quote Share this post Link to post
Finnisher Posted October 9, 2023 Oh thanks a literal metric tonne! i'll give it a spin right away! Been thinking of moving to UDB anyway since it seems to be most feature rich even if I intend to keep to vanilla / LR / Boom mapping myself 1 Quote Share this post Link to post
Finnisher Posted October 9, 2023 1 hour ago, Worst said: You could do this with UDB scripting. Here is an UDB script that could work: Reveal hidden contents `#version 4`; `#name Fill missing midtextures on 1-sided lines with lower or upper textures`; `#description Fills missing midtextures on 1-sided lines which contain textures on lower or upper parts. If both are present, lower takes priority over upper texture.`; // Get all selected lidedefs let lines = UDB.Map.getSelectedLinedefs(true); if(lines.length == 0) UDB.die('You need to select at least one linedef.'); let fill_count = 0; let progress_count = 0; lines.forEach(l => { // If line has no back side (1-sided) if (l.back == null) { if (l.front != null) { // Get the front sidedef. let s = l.front; // Middle texture must be missing if (s.middleTexture == "-") { // If lower texture exists, use it for middle if (s.lowerTexture !== "-") { s.middleTexture = s.lowerTexture; fill_count++; UDB.log("Linedef " + l.index + " middle texture filled with lower texture '" + s.lowerTexture + "'."); } // Otherwise if upper texture exists, use it for middle else if (s.upperTexture !== "-") { s.middleTexture = s.upperTexture; fill_count++; UDB.log("Linedef " + l.index + " middle texture filled with upper texture '" + s.upperTexture + "'."); } } } } progress_count++; UDB.setProgress( Math.round((progress_count/lines.length)*100) ); }); UDB.setProgress(100); UDB.log('Middle textures filled: ' + fill_count); The script needs to be saved in a text file with the '.js' (javascript) extension, for example "1sidedlinemidtexfill.js" and saved under the "UDBScript\Scripts" folder found inside the UltimateDoomBuilder folder. Then in UDB there is a bar on the right side of the editor that has a "Scripts" tab. From there you can select the script, and run it with the "Run" button at the bottom of that tab. Note that for this script, you need to select the lines that it should apply to. If you want, you can just select all lines in the map. It will still only apply it to 1-sided linedefs that match the conditions. It worked perfectly, thank you thank you thank you! 2 Quote Share this post Link to post
andrewj Posted October 11, 2023 For what it's worth, the Eureka editor would not have left the middle textures as "-", but copied the lower texture to the middle when deleting the outer sector. It surprises me that DoomBuilder just leaves things broken like that..... 2 Quote Share this post Link to post
Finnisher Posted October 11, 2023 Oh that sounds convenient will give Eureka a look. 0 Quote Share this post Link to post
smeghammer Posted October 24, 2023 On 10/11/2023 at 1:04 PM, Finnisher said: Oh that sounds convenient will give Eureka a look. Do it! It's my weapon of choice :-) 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.