Add 3 example scripts that recreate ZB actions

This commit is contained in:
spherallic 2024-03-13 18:45:28 +01:00
parent 01ad1d07f9
commit 2ca05336dd
3 changed files with 68 additions and 0 deletions

View file

@ -0,0 +1,13 @@
/// <reference path="../udbscript.d.ts" />
`#version 5`;
`#name Reset linedef actions`;
`#description Resets the action of all selected linedefs to 0.`;
UDB.Map.getSelectedOrHighlightedLinedefs().forEach(line => {
if (line.action > 0) {
line.action = 0;
}
});

View file

@ -0,0 +1,30 @@
/// <reference path="../udbscript.d.ts" />
`#version 5`;
`#name Clear linedef midtextures`;
`#description Clears all midtextures from two-sided linedefs, and optionally removes all flags related to them (Peg Midtexture, Solid Midtexture, Repeat Midtexture)`;
`#scriptoptions
clearflags
{
description = "Remove midtexture-related flags";
default = true;
type = 3; // Boolean
}
`;
UDB.Map.getSelectedOrHighlightedLinedefs().forEach(line => {
if (line.front != null && line.back != null) {
line.front.middleTexture = "-";
line.back.middleTexture = "-";
if (UDB.ScriptOptions.clearflags) {
line.flags['midpeg'] = false;
line.flags['midsolid'] = false;
line.flags['wrapmidtex'] = false;
}
}
});

View file

@ -0,0 +1,25 @@
/// <reference path="../udbscript.d.ts" />
`#version 5`;
`#name Select extra vertices`;
`#description Given a selection of vertices, this only keeps vertices that are not essential to sector geometry selected.`;
UDB.Map.getSelectedOrHighlightedVertices().forEach(vertex => {
let lines = vertex.getLinedefs();
if (lines.length == 2)
{
let l1 = lines[0].angle%180;
let l2 = lines[1].angle%180;
if (l1 != l2)
{
vertex.selected = false;
}
}
else
{
vertex.selected = false;
}
});