Map/Coord Extracting Coordinates from the Map by Clicking

Gafiam

Non-stop Poster
Reaction score
97
Author
Unknown
Contributors
N/A
Quickbar Entry
javascript:
/*
*
*
* [Script] - Extract the coordinated of villages as you click on the map
*/
if (game_data.player.premium == false) {
alert("Premium Account is necessary to use this script");
end();
}
javascript:var win = (window.frames.length > 0) ? window.main : window;
var coords = [];
var outputID = 'villageList';
var encodeID = 'cbBBEncode';
var isEncoded = true;
function fnRefresh()
{
$("#coord_picker").draggable();
// win.$('#' + outputID).attr('value', coords.map(function(e)
// {console.log(isEncoded ? '[coord]' + e + '[\/coord]' : e);
// return isEncoded ? '[coord]' + e + '[\/coord]' : e;
// //return 'OK';
// }
// ).join(isEncoded ? '\n' : ' '));
win.$('#' + outputID).text(
coords.map(function(e) {
return isEncoded ? '[coord]' + e + '[\/coord]' : e;
}).join(isEncoded ? '\n' : ' ')
);
}
win.$(win.document).ready(function()
{
if (win.$('#' + outputID).length <= 0)
{
if (win.game_data.screen == 'map')
{
var srcHTML = '<div id="coord_picker" style="z-index: 99; position: absolute; top: 90px; width: auto; height: auto; background-color:#CEBC98; background-image: url(../graphic/index/bg-tile.jpg); border:2px solid; visibility: visible; cursor:pointer">' + '<center><span style="color:blue;text-decoration:underline;align:center;">Extract Coordinates from the Map</span><br/><br/>' + '<center><input type="checkbox" id="cbBBEncode" onClick="isEncoded=this.checked;fnRefresh();"' + (isEncoded ? 'checked' : '') + '/>BB-Codes<br/>' + '<center><input type="radio" id="drag" onClick="drag=this.checked;fnRefresh();"' + (isEncoded ? '' : '') + '/>Release (select to be able to drag the window)<br/>' + '<textarea id="' + outputID + '" cols="40" rows="10"resize="none" value="" onFocus="this.select();"></textarea><br/><input type=button value="Close Window" onClick="document.getElementById(\'coord_picker\').style.display=\'none\'">' + '</div>';
//ele = win.$('body').append(win.$('#villageList').css('background-color', 'red'));
ele = win.$('body').append(win.$(srcHTML));
win.TWMap.map._handleClick = function(e)
{
//console.log(e);
var pos = this.coordByEvent(e);
//console.log(pos);
var coord = pos.join("|");
//console.log(coord);
var ii = coords.indexOf(coord);
if (ii >= 0)
{
coords.splice(ii, 1);

}
else
{
coords.push(coord);

}
fnRefresh();
return false;

}
;

}
else
{
alert("The script only works on the map screen, you'll be redirected now");
self.location = win.game_data.link_base_pure.replace(/screen\=\w*/i, "screen=map");

}
}
}
);
void(0);
Public?
Public
This had been my message on Ticket 14420540 to authorize this script previously:

I have a script for Coordinates extraction saved since some years ago and I couldn't find the author, so I decided to ask if you could authorize this script myself...

If you execute this on the Map Overview it will open a window where the coordinates of any position/village you click on the Map (not the Minimap) will show up on the window making a list of coordinates (with or without the [coord] BB-Code) that you can use for others scripts like fakes, planning attacks, etc.

It is really useful, and I hope it can become an authorized script.

As a last piece of information, if you click and drag using the minimap to navigate, you should be able to get coordinates from more locations of the map without having to reopen the script or map.

Lastly, if you click on the Village a second time, the coordinate will be removed from the list.

https://pastebin.com/3V6Cdqeg

I'd like to submit it for approval again
 
Upvote 0
Top