Advertisement
gabrielzsm

Coordinates Extraction Script

Dec 11th, 2020
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. javascript:
  2. /*
  3. *
  4. *
  5. * [Script] - Extract the coordinated of villages as you click on the map
  6. */
  7. if (game_data.player.premium == false) {
  8. alert("Premium Account is necessary to use this script");
  9. end();
  10. }
  11. javascript:var win = (window.frames.length > 0) ? window.main : window;
  12. var coords = [];
  13. var outputID = 'villageList';
  14. var encodeID = 'cbBBEncode';
  15. var isEncoded = true;
  16. function fnRefresh()
  17. {
  18. $("#coord_picker").draggable();
  19. // win.$('#' + outputID).attr('value', coords.map(function(e)
  20. // {console.log(isEncoded ? '[coord]' + e + '[\/coord]' : e);
  21. // return isEncoded ? '[coord]' + e + '[\/coord]' : e;
  22. // //return 'OK';
  23. // }
  24. // ).join(isEncoded ? '\n' : ' '));
  25. win.$('#' + outputID).text(
  26. coords.map(function(e) {
  27. return isEncoded ? '[coord]' + e + '[\/coord]' : e;
  28. }).join(isEncoded ? '\n' : ' ')
  29. );
  30. }
  31. win.$(win.document).ready(function()
  32. {
  33. if (win.$('#' + outputID).length <= 0)
  34. {
  35. if (win.game_data.screen == 'map')
  36. {
  37. 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>';
  38. //ele = win.$('body').append(win.$('#villageList').css('background-color', 'red'));
  39. ele = win.$('body').append(win.$(srcHTML));
  40. win.TWMap.map._handleClick = function(e)
  41. {
  42. //console.log(e);
  43. var pos = this.coordByEvent(e);
  44. //console.log(pos);
  45. var coord = pos.join("|");
  46. //console.log(coord);
  47. var ii = coords.indexOf(coord);
  48. if (ii >= 0)
  49. {
  50. coords.splice(ii, 1);
  51.  
  52. }
  53. else
  54. {
  55. coords.push(coord);
  56.  
  57. }
  58. fnRefresh();
  59. return false;
  60.  
  61. }
  62. ;
  63.  
  64. }
  65. else
  66. {
  67. alert("The script only works on the map screen, you'll be redirected now");
  68. self.location = win.game_data.link_base_pure.replace(/screen\=\w*/i, "screen=map");
  69.  
  70. }
  71. }
  72. }
  73. );
  74. void(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement