mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-22 16:31:33 +00:00
5eb438e3ba
Added map scripting capabilities to UDB (#656). Documentation at https://biwa.github.io/udbscript-docs/
18 lines
No EOL
486 B
JavaScript
18 lines
No EOL
486 B
JavaScript
`#name Calculate sector area`;
|
|
|
|
`#description Calculates the area of the selected sectors.`
|
|
|
|
let sectors = Map.getSelectedSectors();
|
|
|
|
if(sectors.length == 0)
|
|
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));
|
|
});
|
|
});
|
|
|
|
showMessage('The area of the selected sectors is ' + area + ' mu².'); |