UltimateZoneBuilder/Build/UDBScript/Scripts/Examples/Information/mapsquareness.js
biwa 5eb438e3ba
Add map scripting capabilities to UDB (#656)
Added map scripting capabilities to UDB (#656). Documentation at https://biwa.github.io/udbscript-docs/
2021-11-28 14:00:24 +01:00

17 lines
No EOL
469 B
JavaScript

`#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;
Map.getLinedefs().forEach(ld => {
totalLength += ld.length;
if(ld.angle % 90 == 0)
orthogonalLength += ld.length;
});
orthogonalPercentage = (orthogonalLength / totalLength * 100).toFixed(2);
showMessage('The map is ' + orthogonalPercentage + '% square.');