23-01-2025, 00:01
Author : Nik12111
Contributors : N/A
Quickbar Entry :
Description: Allows you to select villages on the map to get their coords.
1. Villages can be selected and deselected.
2. Selected villages will have their coords added to an textarea box on the right of the screen.
3. Selected villages will be highlighted in blue.
Contributors : N/A
Quickbar Entry :
Code:
javascript:(function () {
if (window.location.href.indexOf('screen=map') < 0) {
alert('Please run this script on the map page.');
return;
};
let IW_Map = window.SECmap;
function spawnSectorReplacer(data, sector) {
IW_Map.mapHandler.IWspawnSector(data, sector);
let beginX = sector.x - data.x;
let endX = beginX + IW_Map.mapSubSectorSize;
let beginY = sector.y - data.y;
let endY = beginY + IW_Map.mapSubSectorSize;
for (let x in data.tiles) {
x = parseInt(x, 10);
if (x < beginX || x >= endX) {
continue;
}
for (let y in data.tiles[x]) {
y = parseInt(y, 10);
if (y < beginY || y >= endY) {
continue;
}
let xCoord = data.x + x;
let yCoord = data.y + y;
let v = IW_Map.villages[(xCoord) * 1000 + yCoord];
if (v) {
var pl = (v.owner > 0 && window.SECmap.players[v.owner]) ? window.SECmap.players[v.owner] : 0;
var overlay = document.createElement('div');
overlay.style.position = 'absolute';
overlay.style.zIndex = '50';
overlay.style.width = (IW_Map.map.scale[0] - 1).toString() + 'px';
overlay.style.height = (IW_Map.map.scale[1] - 1).toString() + 'px';
overlay.style.opacity = 0.3;
overlay.style.background = $("#IW_CoordList").text().match(xCoord + "\\|" + yCoord) ? "blue" : "none";
overlay.id = ['IWoverlay', xCoord + "|" + yCoord].join("_");
sector.appendElement(overlay, x - beginX, y - beginY);
}
}
}
};
window.SECmap.mapHandler.onClick = function (x, y, e) {
var village = window.SECmap.villages[x * 1000 + y];
if (village) {
let coord = x + '|' + y;
let coords = $("#IW_CoordList").val().match(/\d{1,3}\|\d{1,3}/g) || [];
var ii = coords.indexOf(coord);
if (ii >= 0) {
coords.splice(ii, 1);
$('[id*="' + coord + '"]').css("background", "none")
} else {
coords.push(coord);
$('[id*="' + coord + '"]').css("background", "blue")
}
AddToList(coords);
} else
window.SECmap.context.hide();
return false;
};
IW_Map.mapHandler.IWspawnSector = IW_Map.mapHandler.spawnSector;
window.SECmap.mapHandler.spawnSector = spawnSectorReplacer;
window.SECmap.reload();
function AddToList(coords) {
$("#IW_CoordList").text($.map((coords || $("#IW_CoordList").text().match(/\d{1,3}\|\d{1,3}/g)), function (e) {
return e;
}).join(' '));
var new_count = ($('#IW_CoordList').val() !== '') ? $('#IW_CoordList').val().match(/\d{1,3}\|\d{1,3}/g).length : '0';
$('.select_count').text(new_count);
};
const tableHTML = `<br/>
<table class="vis" style="border-spacing: 0px; border-collapse: collapse;" width="100%">
<tbody>
<tr>
<th colspan="100%">Coord grabber</th>
</tr>
<tr>
<td>
<b><span class="select_count">0</span> Selected Villages</b><br>
<textarea style="height: 160px; width: 180px;" id="IW_CoordList" onfocus="this.select();"></textarea>
</td>
</tr>
</tbody>
</table>`;
$("#minimap_whole").after(tableHTML);
})();
Description: Allows you to select villages on the map to get their coords.
1. Villages can be selected and deselected.
2. Selected villages will have their coords added to an textarea box on the right of the screen.
3. Selected villages will be highlighted in blue.