Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
- /* _ __ _ _ _ _____ ___ _ */
- /* | | / /(_)| | | | | __ \ / _ \ | | */
- /* | |/ / _ | |_ | |_ ___ _ __ | | \/ __ _ _ __ ___ ___ / /_\ \ _ _ | |_ ___ */
- /* | \ | || __|| __| / _ \| '_ \ | | __ / _` || '_ ` _ \ / _ \ | _ || | | || __| / _ \ */
- /* | |\ \| || |_ | |_ | __/| | | || |_\ \| (_| || | | | | || __/ | | | || |_| || |_ | (_) | */
- /* \_| \_/|_| \__| \__| \___||_| |_| \____/ \__,_||_| |_| |_| \___| \_| |_/ \__,_| \__| \___/ */
- /* */
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
- /*
- * KittenGame Auto - Version 1.0 by LordPankake
- *
- * * * * * * FEATURES * * * * * * *
- *
- * - Automate catnip gathering
- * - Automate observing sky-events
- * - Automate converting catnip to wood
- * - Automate sending hunters
- */
- var autoMap = [];
- // Setup data
- init();
- // Create gui based on data
- createGUI();
- // Start the main loop
- requestAnimationFrame(mainLoop);
- /**
- * Creates the automation tasks.
- */
- function init() {
- var auto_Gather = new Automation(false, "Gather: ", function() {
- $("div:contains('Gather catnip')").click();
- });
- var auto_Observe = new Automation(false, "Observe: ", function(){
- $("#observeBtn").click();
- });
- var auto_Nip2Wood = new Automation(false, "Nip2Wood: ", function(){
- var catnip = gamePage.resPool.get('catnip');
- if (catnip.perTickUI < 0) { return; }
- if (catnip.value / catnip.maxValue < 0.75) { return; }
- gamePage.craft('wood', 25);
- });
- var auto_Hunt = new Automation(false, "Hunt: ", function(){
- var catpower = gamePage.resPool.get('manpower');
- if (catpower.value > 100) {
- $("a:contains('Send hunters')").click();
- }
- });
- autoMap.push(auto_Gather);
- autoMap.push(auto_Observe);
- autoMap.push(auto_Nip2Wood);
- autoMap.push(auto_Hunt);
- }
- /**
- * Creates the GUI based on automation tasks created in the init method.
- */
- function createGUI() {
- // Misc variables
- var colDisabled = "#4f3030";
- var colEnabled = "#374f30";
- // Buttons
- var btnArray = [];
- var index;
- for (index = 0; index < autoMap.length; index++) {
- var btnAuto = document.createElement("DIV");
- btnAuto.setAttribute('id', index);
- btnAuto.onclick = function() {
- var auto = autoMap[parseInt(this.getAttribute('id'))];
- auto.active = !auto.active;
- this.style.backgroundColor = auto.active ? colEnabled : colDisabled;
- this.innerHTML = auto.titleText + auto.active;
- };
- btnArray.push(btnAuto);
- }
- // Style tweaking & appending
- var elemMenu = document.createElement("div");
- elemMenu.style.position = "relative";
- elemMenu.style.zIndex = "99999";
- elemMenu.style.backgroundColor = "#000";
- elemMenu.style.padding = "5px";
- elemMenu.style.margins = "2px 2px 2px 2px";
- for (index = 0; index < btnArray.length; index++) {
- var elemButton = btnArray[index];
- elemButton.innerHTML = autoMap[index].titleText + autoMap[index].active;
- elemButton.style.padding = "5px";
- elemButton.style.border = "1px solid #FFF";
- elemButton.style.backgroundColor = autoMap[index].active ? colEnabled : colDisabled;
- elemButton.style.display = "inline-block";
- elemMenu.appendChild(elemButton);
- }
- document.getElementById("footerLinks").appendChild(elemMenu);
- }
- /**
- * The main loop. Requires the window to be open.
- */
- function mainLoop() {
- var index;
- for (index = 0; index < autoMap.length; index++) {
- var auto = autoMap[index];
- // Skip if not active
- if (!auto.active) {
- continue;
- }
- // Run task
- auto.autoTask();
- }
- requestAnimationFrame(mainLoop);
- }
- /**
- * Class containing data about the task.
- */
- function Automation(param_active, param_titleText, param_autoTask) {
- this.titleText = param_titleText;
- this.autoTask = param_autoTask;
- this.active = param_active;
- }
Advertisement
Add Comment
Please, Sign In to add comment