Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name AD2460 Automated Outpost Transport
- // @namespace http://live.ad2460.com/game.pl
- // @version 0.1
- // @description Automatically transports resources from outposts every xx minutes
- // @author Covey @ J. T. Fidje
- // @match http://live.ad2460.com/game.pl
- // @grant none
- // ==/UserScript==
- // ===== Global Intervals =====
- var transportInterval = null;
- var nextTransportInterval = null;
- // ===== Global Integers =====
- var transportDelay = 20; // Number of minutes between every auto-transport. Change to fit your needs.
- var nextTransportCount = 0;
- // ===== Functions =====
- function activateAddOn(){
- initiateTransport();
- transportInterval =
- setInterval(initiateTransport,
- 1000 * 60 * transportDelay);
- if(transportInterval != null)
- clearInterval(transportInterval);
- }
- function initiateTransport(){
- resetNextTransportTimer();
- startNextTransportTimer();
- initiateAutoTransport();
- }
- function startNextTransportTimer(){
- nextTransportCount = 60 * transportDelay;
- nextTransportInterval =
- setInterval(function(){
- nextTransportCount --;
- }, 1000);
- }
- function resetNextTransportTimer(){
- nextTransportCount = 0;
- if(nextTransportInterval != null)
- clearInterval(nextTransportInterval);
- }
- function showRemainingTime(){
- var text = "";
- if(nextTransportCount > 60)
- text = (Math.ceil(nextTransportCount / 60).toString() + " minutes");
- else if(nextTransportCount == 1)
- text = "1 second";
- else if(nextTransportCount == 0)
- text = "Transport Ready!";
- else
- text = (nextTransportCount.toString() + " seconds");
- alert("Time remaining 'till next transport: " + text);
- }
- // ===== Buttons =====
- var startScriptBtn = document.createElement("BUTTON");
- var startScriptText = document.createTextNode("Activate Script!");
- startScriptBtn.appendChild(startScriptText);
- startScriptBtn.addEventListener("click", activateAddOn, false);
- document.body.appendChild(startScriptBtn);
- var timeRemainBtn = document.createElement("BUTTON");
- var timeRemainText = document.createTextNode("Check Time Remaining");
- timeRemainBtn.appendChild(timeRemainText);
- timeRemainBtn.addEventListener("click", showRemainingTime, false);
- document.body.appendChild(timeRemainBtn);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement