2022-11-13 00:15:17 +00:00
|
|
|
/// <reference path="../../../udbscript.d.ts" />
|
|
|
|
|
2022-01-06 17:46:37 +00:00
|
|
|
`#version 4`;
|
|
|
|
|
2021-11-28 13:00:24 +00:00
|
|
|
`#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;
|
|
|
|
|
2022-01-06 17:46:37 +00:00
|
|
|
UDB.Map.getLinedefs().forEach(ld => {
|
2021-11-28 13:00:24 +00:00
|
|
|
totalLength += ld.length;
|
|
|
|
|
|
|
|
if(ld.angle % 90 == 0)
|
|
|
|
orthogonalLength += ld.length;
|
|
|
|
});
|
|
|
|
|
|
|
|
orthogonalPercentage = (orthogonalLength / totalLength * 100).toFixed(2);
|
|
|
|
|
2022-01-06 17:46:37 +00:00
|
|
|
UDB.showMessage('The map is ' + orthogonalPercentage + '% square.');
|