AI Craftapalooza

From The Perfect Tower II
Revision as of 17:32, 21 January 2021 by Troylaurin (talk | contribs)
Jump to navigation Jump to search

IN PROGRESS. USE AT YOUR OWN RISK


Overview

Craftapalooza is a set of scripts to manage the factory directly, rather than having to manually craft anything.

It is separated into sections: The general scripts, which are always required and from the UX of the crafting system (see Usage below), and collections of crafting scripts further broken up into parts, machines and producers. Note that the parts scripts are required as they are used by the machine and producer scripts, but the latter are for the most part optional.

If you leave the CRAFT_INVENTORY variable to its default value of 1.0, then the scripts will try to reuse items that are already in your inventory to minimise the required work. This also enables the scripts to be interrupted and resumed later - for the most part, the scripts will determine what has already been made and simply pick up where they left off. There is a notable exception that the AI cannot see the contents of machines, so for the best reliability, ensure that none of the machines are busy processing anything before starting any craft.

Conversely you can toggle CRAFT_INVENTORY to 0.0 and then any crafts will create all required items to create your desired output. Note that this can cause an increase in the number of cables, rods, screws etc in your inventory if the requested craft doesn't consume all of the created parts.

Usage

  1. Choose the crafting MODE with '2' and OUTPUT with '3'. Refer to the following table to see what will be produced.
  2. Choose the TIER you want to produce with '1' (loops from 1 to 10). Note that some items can only be crafted for tiers 1 to 5.
  3. Choose the COUNT of items you want to produce with '8' to decrease and '9' to increase the target count. The count increments in units from 1-10, then by tens through 20, 30... 90, 100, then 200, 300 etc
  4. Optionally toggle CRAFT_INVENTORY as described above with '5'.
  5. Hit '0' while in the factory to start production.
MODE 1 (producers) 2 (machines) 3 (parts)
OUTPUT
1 White (town) Oven Chips (T1-5)
2 Yellow (powerplant) Assembler Plates
3 Orange (mine) Refiner Dense plates
4 Red (factory) Crusher Blocks
5 Purple (headquarters) Cutter Cables
6 Pink (arcade) Presser Insulated cables
7 Green (laboratory) Mixer Rods
8 Cyan (shipyard) Belt Motors
9 Light blue (trading post) Shaper Pumps
10 Dark blue (workshop) Boiler Dust (tier up)
11 Grey (museum) - -
12 Brown (construction firm) - -
13 Black (statue of Cubos) - -

Importing the scripts

The import codes for each script can be found in the tables below. The easiest way to import them is to install GreaseMonkey or TamperMonkey and install the following tamperscript which will add a </> button to the top of each code block. If you click on this button, the contents of the block will be copied into your clipboard for ease of pasting into the game's import window.

Click to copy (tamperscript)
// ==UserScript==
// @name         Click to copy on <pre> tags
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add click to copy buttons to <pre> tags
// @author       Troy.Laurin@gmail.com
// @match        https://www.perfecttower2.com/wiki/*
// @grant        GM_addStyle
// @require      https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js
// @require      http://code.jquery.com/jquery-3.5.1.slim.min.js
// ==/UserScript==

(function() {
    'use strict';

    // ------------------------------------------
    // CSS part injected in the page
    GM_addStyle(" \
.precontainer { \
position: relative; \
} \
.copy-btn { \
background: #DDD; \
font-family: monospace; \
font-weight: bolder; \
margin: 0; \
opacity: 0; \
padding: 4px; \
position: absolute; \
right: 1px; \
top: 1px; \
cursor: pointer; \
-webkit-transition: opacity 0.3s ease-in-out; \
-o-transition: opacity 0.3s ease-in-out; \
transition: opacity 0.3s ease-in-out; \
} \
.precontainer:hover >.copy-btn { \
opacity: 1; \
} \
table { width: 100% } \
");

    $('pre').wrap('<div class="precontainer"></div>');
    $('pre').before($('<span class="copy-btn">&lt;/&gt;</span>'));

    new ClipboardJS('.copy-btn', {
        text: function(trigger) {
            return $(trigger.nextElementSibling).text();
        }
    })
        .on('success',function (e) {
        $(e.trigger).html("&lt;copied/&gt;")
        setTimeout(function() {
            $(e.trigger).html("&lt;/&gt;");
        }, 3000);
    })
        .on('error',function (e) {
        $(e.trigger).html("Error!")
        setTimeout(function() {
            $(e.trigger).html("&lt;/&gt;");
        }, 3000);
    });
})();

The scripts

Command scripts


Parts scripts


Machine scripts


Producer scripts