UltimateZoneBuilder/Build/UDBScript/Scripts/Examples/Information/mapsquareness.js
biwa 5b2b149b40
UDBScript version 5 (#819)
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)
2022-11-13 01:15:17 +01:00

21 lines
No EOL
542 B
JavaScript

/// <reference path="../../../udbscript.d.ts" />
`#version 4`;
`#name Show Map Squareness`;
`#description Shows how square a map is. Computes the percentage of orthogonal lines, based on their length.`;
let totalLength = 0;
let orthogonalLength = 0;
UDB.Map.getLinedefs().forEach(ld => {
totalLength += ld.length;
if(ld.angle % 90 == 0)
orthogonalLength += ld.length;
});
orthogonalPercentage = (orthogonalLength / totalLength * 100).toFixed(2);
UDB.showMessage('The map is ' + orthogonalPercentage + '% square.');