mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-03 14:21:36 +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)
22 lines
No EOL
559 B
JavaScript
22 lines
No EOL
559 B
JavaScript
/// <reference path="../../../udbscript.d.ts" />
|
|
|
|
`#version 4`;
|
|
|
|
`#name Calculate sector area`;
|
|
|
|
`#description Calculates the area of the selected sectors.`
|
|
|
|
let sectors = UDB.Map.getSelectedSectors();
|
|
|
|
if(sectors.length == 0)
|
|
UDB.die('You need to select at least one sector.');
|
|
|
|
let area = 0;
|
|
|
|
sectors.forEach(s => {
|
|
s.getTriangles().forEach(t => {
|
|
area += 0.5 * Math.abs(t[0].x * (t[1].y - t[2].y) + t[1].x * (t[2].y - t[0].y) + t[2].x * (t[0].y - t[1].y));
|
|
});
|
|
});
|
|
|
|
UDB.showMessage('The area of the selected sectors is ' + area + ' mu².'); |