mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-25 21:31:14 +00:00
5b2b149b40
Improved UDBScript to version 5: - Added Plane class - Added BlockMap, BlockEntry, and BlackMapQueryResult classes - Sector class - Added getLabelPositions method to get the position of sector labels (where tags, effects etc. are displayed) - Added support for JavaScript BigInt for UDMF fields. This means it's not necessary anymore to use UniValue to assign integers to new UDMF fields. Instead it can be done like this: sector.fields.my_int_field = 1n; - Added type information file (udbscript.d.ts)
27 lines
No EOL
776 B
JavaScript
27 lines
No EOL
776 B
JavaScript
/// <reference path="../../udbscript.d.ts" />
|
|
|
|
`#version 4`;
|
|
|
|
`#name Reorder Things Indices`;
|
|
|
|
`#description Reorderts the thing inddices of the selected things, so that the thing indices are ascending in the order the things were selected.`;
|
|
|
|
let things = UDB.Map.getSelectedThings();
|
|
|
|
if(things.length < 2)
|
|
UDB.die('You have to select at least 2 things.');
|
|
|
|
let sorted = [...things].sort((a, b) => a.index - b.index);
|
|
|
|
let copies = things.map(t => {
|
|
let nt = UDB.Map.createThing([ 0, 0 ]);
|
|
t.copyPropertiesTo(nt);
|
|
return nt;
|
|
});
|
|
|
|
for(let i=0; i < sorted.length; i++)
|
|
copies[i].copyPropertiesTo(sorted[i]);
|
|
|
|
// Delete the old things. Have to do it in an extra loop sice it'd just fill
|
|
// up the old thing indexes
|
|
copies.reverse().forEach(t => t.delete()); |