Difference between revisions of "AI Craftapalooza"
Troylaurin (talk | contribs) |
m (Marking as Historical.) |
||
(4 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | + | {{Historical}} | |
+ | |||
+ | v0.1.0 complete. All of the machines are craftable though there may be bugs. Comment on the talk page or report bugs to me in discord (SharkBite#8908) | ||
+ | |||
+ | Note that none of the machine scripts estimate required ingots to validate that you have enough dust, though they should still craft correctly as long as you have enough dust of each tier. | ||
<br /> | <br /> | ||
Line 11: | Line 15: | ||
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. | 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. | ||
+ | |||
+ | ===Known Bugs=== | ||
+ | |||
+ | #The parts scripts don't wait for production to be complete before exiting the script, which breaks the timing of some of the machines. | ||
+ | #The machine scripts don't count ingots, which means they don't reliably turn dust into ingots and appear to get stuck. You may be able to wake them up by crafting ingots until you have enough, otherwise try crafting ingots before launching the machine craft. | ||
===Usage=== | ===Usage=== | ||
Line 194: | Line 203: | ||
==Changelog== | ==Changelog== | ||
+ | 2020-02-15: (v0.1.1) | ||
+ | |||
+ | * Removed the unnecessary insulated cables from the boiler recipe | ||
+ | |||
+ | 2020-01-26: (v0.1.0) | ||
+ | |||
+ | * All of the machines completed with a few known (minor) bugs | ||
+ | * None of the machines estimate required ingots accurately | ||
+ | |||
2020-01-22: (v0.0.1) | 2020-01-22: (v0.0.1) | ||
Latest revision as of 19:10, 24 August 2023
v0.1.0 complete. All of the machines are craftable though there may be bugs. Comment on the talk page or report bugs to me in discord (SharkBite#8908)
Note that none of the machine scripts estimate required ingots to validate that you have enough dust, though they should still craft correctly as long as you have enough dust of each tier.
Contents
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.
Known Bugs
- The parts scripts don't wait for production to be complete before exiting the script, which breaks the timing of some of the machines.
- The machine scripts don't count ingots, which means they don't reliably turn dust into ingots and appear to get stuck. You may be able to wake them up by crafting ingots until you have enough, otherwise try crafting ingots before launching the machine craft.
Usage
- Choose the crafting MODE with '2' and OUTPUT with '3'. Refer to the following table to see what will be produced.
- 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.
- 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
- Optionally toggle CRAFT_INVENTORY as described above with '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) | - | - |
Status and error reporting
The craft_status
global variable is used to describe the current state of any crafting requests, and follows HTTP status codes.
craft_status
|
Meaning |
---|---|
102 | Craft in progress |
200 | No craft in progress, previous craft (if any) was completed successfully. |
412 | Not enough raw materials (dust or ingots) found to produce the requested craft. Look at the craft_require_tier and craft_require_count to see which tier of ingot is missing and how much is required for the desired craft.
|
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"></></span>'));
new ClipboardJS('.copy-btn', {
text: function(trigger) {
return $(trigger.nextElementSibling).text();
}
})
.on('success',function (e) {
$(e.trigger).html("<copied/>")
setTimeout(function() {
$(e.trigger).html("</>");
}, 3000);
})
.on('error',function (e) {
$(e.trigger).html("Error!")
setTimeout(function() {
$(e.trigger).html("</>");
}, 3000);
});
})();
|
The scripts
Command scripts
Script | Lines | Notes | Source | |||
---|---|---|---|---|---|---|
craft init | 9 | Impulse on wake |
| |||
craft GO | 13 | Impulse on 0
|
| |||
craft tier up | 1 | Impulse on 1 |
| |||
craft mode up | 2 | Impulse on 2 |
| |||
craft output up | 2 | Impulse on 3 |
| |||
craft count up | 5 | Impulse on 9 |
| |||
craft count down | 5 | Impulse on 8 |
| |||
craft inventory use | 1 | Impulse on 5 |
| |||
craft script check | 3 | Uses a timing hack to determine if the target script exists, and sets status to 404 if it doesn't. |
| |||
craft output producer | ? | Impulse on 4
|
TODO | |||
craft output machine | 4 | Impulse on 4
|
| |||
craft ingot | 13 | Inputs:
Note: will always use ingots in inventory, regardless of |
|
Parts scripts
Chips (1)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 3:1 | 20 |
| |||
craft 3:1:in | 18 |
| |||
craft 3:1:board | 16 |
| |||
craft 3:1:circuit | 16 |
|
Plates (2)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 3:2 | 9 |
|
Dense plates (3)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 3:3 | 14 |
|
Blocks (4)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 3:4 | 10 |
|
Cables (5)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 3:5 | 9 |
|
Insulated cables (6)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 3:6 | 21 |
|
Rods (7)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 3:7 | 9 |
|
Motors (8)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 3:8 | 20 |
| |||
craft 3:8:rods | 10 |
| |||
craft 3:8:wire | 9 |
|
Pumps (9)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 3:9 | 10 |
| |||
craft 3:9:in | 16 |
| |||
craft 3:9:plates | 9 |
| |||
craft 3:9:rings | 10 |
|
Wires
(pic)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft part:wire | 9 |
|
Screws
(pic)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft part:screw | 12 |
|
Machine scripts
Oven (1)
(pic)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 2:1 | 16 |
| |||
craft 2:1:in | 18 |
| |||
craft 2:1:plates | 11 |
|
Assembler (2)
(pic)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 2:2 | 17 |
| |||
craft 2:2:in | 13 |
| |||
craft 2:2:plates | 20 |
|
Refiner (3)
(pic)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 2:3 | 16 |
| |||
craft 2:3:in | 17 |
| |||
craft 2:3:misc | 18 |
|
Crusher (4)
(pic)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 2:4 | 14 |
| |||
craft 2:4:in | 18 |
|
Cutter (5)
(pic)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 2:5 | 15 |
| |||
craft 2:5:in | 17 |
| |||
craft 2:5:plates | 12 |
|
Presser (6)
(pic)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 2:6 | 17 |
| |||
craft 2:6:in | 22 |
|
Mixer (7)
(pic)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 2:7 | 14 |
| |||
craft 2:7:in | 18 |
|
Belt (8)
(pic)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 2:8 | 14 |
| |||
craft 2:8:in | 18 |
|
Shaper (9)
(pic)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 2:9 | 15 |
| |||
craft 2:9:in | 13 |
| |||
craft 2:9:plates | 18 |
|
Boiler (10)
(pic)
Name | Lines | Code | |||
---|---|---|---|---|---|
craft 2:10 | 18 |
| |||
craft 2:10:in | 13 |
| |||
craft 2:10:plates | 8 |
|
Producer scripts
TODO
Changelog
2020-02-15: (v0.1.1)
- Removed the unnecessary insulated cables from the boiler recipe
2020-01-26: (v0.1.0)
- All of the machines completed with a few known (minor) bugs
- None of the machines estimate required ingots accurately
2020-01-22: (v0.0.1)
- General and part scripts nominally complete
- Some machines prototyped