Add 2 new scripts

This commit is contained in:
spherallic 2024-05-07 01:30:01 +02:00
parent b1833b0100
commit ac74639453
2 changed files with 107 additions and 0 deletions

View file

@ -0,0 +1,48 @@
/// <reference path="../../udbscript.d.ts" />
`#version 4`;
`#name Modify NiGHTS track order`;
`#description Inserts or removes an order index from the selected thing's mare`;
`#scriptoptions
operation
{
description = "Insert/remove?";
default = 0;
type = 11; // Enum
enumvalues {
0 = "Insert";
1 = "Remove";
}
}
`;
// Get the selected things
let selected = UDB.Map.getSelectedThings();
if (selected.length != 1)
UDB.die('More than one thing selected, aborting script.');
if (selected[0].type < 1700 || selected[0].type > 1702)
UDB.die('Thing is not a track element, aborting script.');
let mare = selected[0].args[0];
let order = selected[0].args[1];
let operation = UDB.ScriptOptions.operation;
UDB.Map.getThings().filter(o => o.type >= 1700 && o.type <= 1702).forEach(thing => {
if (thing.args[0] == mare)
{
if (operation == 0 && thing.args[1] > order)
thing.args[1] = thing.args[1] + 1;
else if (operation == 1 && thing.args[1] > order)
thing.args[1] = thing.args[1] - 1;
else if (operation == 1 && thing.args[1] == order)
thing.delete();
}
});

View file

@ -0,0 +1,59 @@
/// <reference path="../../udbscript.d.ts" />
`#version 4`;
`#name Copy plane texture properties to opposite plane`;
`#description Copies plane texture properties (rotation, offsets) of all selected sectors to its opposite plane.`;
`#scriptoptions
direction
{
description = "Copy direction";
default = 0;
type = 11; // Enum
enumvalues {
0 = "Floor to ceiling";
1 = "Ceiling to floor";
}
}
copytexture
{
description = "Copy texture?";
default = 0;
type = 11; // Enum
enumvalues {
0 = "No";
1 = "Yes";
}
}
`;
// Get the selected things
let selected = UDB.Map.getSelectedSectors();
if (selected.length == 0)
UDB.die('This script requires a selection!');
let direction = UDB.ScriptOptions.direction;
let copytexture = UDB.ScriptOptions.copytexture;
UDB.Map.getSelectedSectors().forEach(sector => {
if (direction == 0)
{
sector.fields.xpanningceiling = sector.fields.xpanningfloor;
sector.fields.ypanningceiling = sector.fields.ypanningfloor;
sector.fields.rotationceiling = sector.fields.rotationfloor;
if (copytexture == 1) sector.ceilingTexture = sector.floorTexture;
}
else
{
sector.fields.xpanningfloor = sector.fields.xpanningceiling;
sector.fields.ypanningfloor = sector.fields.ypanningceiling;
sector.fields.rotationfloor = sector.fields.rotationceiling;
if (copytexture == 1) sector.floorTexture = sector.ceilingTexture;
}
});