[WIP][0.11.20] Smart Box (v0.0.4)
Posted: Sat Jun 27, 2015 7:53 pm
Note: This is a very early version of this mod, it still requires a lot of work, check TODO list below.
This mod adds a new entity called Smart Box and an item called Smart Box Programmer.
Smart Box is an advanced belt splitter / sorter / merger, which can be programmed. Right now there are just few commands available, but I'm going to add much more.
It is unlocked with Smart Boxes technology, which requires Plastics, Advanced Electronics and Logistics 3.
Note: If you want to test it quickly, just enter these two commands into the console:
How does it work?
Smart Box is a big entity, taking 4x4 tiles on the map. It has 8 inputs / outputs, numbered from 1 to 8 - consult image below:
You can enter commands in these text fields. You may put each command in new line or many commands in one line, separated by a space. Below is list of commands available at this moment:
Commands list
Examples:
1. Take all the copper from an input and place it on left lane of an output, take all the iron from an input and place it on right lane of an output:
Another solution, using conditional instructions:
Explanation:
- in the first line of the code, smart box takes an item from input 1
- in the second line, smart box checks if item in the buffer is an iron plate. If it is, it jumps to line 3; otherwise it puts it to left lane of output 2 and jumps to line 1.
- in the third line, smart box puts an item from buffer to right lane of output 2. Since it is last line of code it will return to line 1 after executing it.
2. Take all the copper from one input and all the iron from another input and place them on the same lane of output one after another (so there will be always a chain copper-iron-copper-iron-copper-...):
3. Sort 8 different items from one input into different output lanes:
4. Take any item from one of 7 inputs and place it alternately on both lanes of the output belt:
5. Put 4 items on output 2 and then put 1 item on output 3:
Explanation:
- in the first line of this code counter 1 is set to 0
- in the second line smart box takes an item from the input 1 and increases value of the counter 1 by 1
- in third line smart box checks if value of counter 1 is equal to 5 - if it is, it jumps to line 4; otherwise it puts item to output 3 and jumps to line 2
- in fourth line smart box puts item to output 3. This is the last line, so after executing it code will continue from the first line (so the counter 1 will be set to 0 again).
TODO:
1. Make proper graphics instead of placeholders that are in use now.
2. [DONE] Improve GUI as much as possible
3. [DONE] Add more commands (better conditional instructions, possibly more advanced loops)
4. [DONE] Change Smart Box so it will work only if powered by electricity.
5. Make it possible to copy program from one Smart Box and paste it on another.
6. Ballance and optimalizations.
7. Read information from logistics network and use it in code.
Downloads:
There are two version of this mod. One uses a custom, monospace font, but it requires you to install this font in Factorio directory.
Note 1: Install only one of these version!
Note 2: If you updated this mod from an earlier version, you have to start a new game, loading a game saved with earlier version of the mod may result in crash.
Download normal version: Download version without font: Changelog:
v0.0.4
This mod adds a new entity called Smart Box and an item called Smart Box Programmer.
Smart Box is an advanced belt splitter / sorter / merger, which can be programmed. Right now there are just few commands available, but I'm going to add much more.
It is unlocked with Smart Boxes technology, which requires Plastics, Advanced Electronics and Logistics 3.
Note: If you want to test it quickly, just enter these two commands into the console:
Code: Select all
/c game.player.insert{ name="smart-box", count=1 }
/c game.player.insert{ name="smart-box-programmer", count=1 }
Smart Box is a big entity, taking 4x4 tiles on the map. It has 8 inputs / outputs, numbered from 1 to 8 - consult image below:
Input and output placement
To setup program that will be executed by a Smart Box, you need a Smart Box Programmer. Craft it and click with it in your hand on a Smart Box placed on the map to open code window (as seen below):Code GUI
Code GUI is rather ugly but it works - of course, I'll do my best to improve it.You can enter commands in these text fields. You may put each command in new line or many commands in one line, separated by a space. Below is list of commands available at this moment:
Commands list
Input related commands
Output related commands
Counters
Jumps
Note: If there is any error in the code you wrote, a message showing incorrect command will appear. Smart Box will not do anything until its program is free of errors.Examples:
1. Take all the copper from an input and place it on left lane of an output, take all the iron from an input and place it on right lane of an output:
Code: Select all
in:1 out?:copper-plate:2:L out?:iron-plate:2:R
Code: Select all
in:1
jump?b=:iron-plate:3 out:2:L jump:1
out:2:R
- in the first line of the code, smart box takes an item from input 1
- in the second line, smart box checks if item in the buffer is an iron plate. If it is, it jumps to line 3; otherwise it puts it to left lane of output 2 and jumps to line 1.
- in the third line, smart box puts an item from buffer to right lane of output 2. Since it is last line of code it will return to line 1 after executing it.
2. Take all the copper from one input and all the iron from another input and place them on the same lane of output one after another (so there will be always a chain copper-iron-copper-iron-copper-...):
Code: Select all
in:1 out:2:L in:8 out:2:L
Code: Select all
in:1
out?:copper-plate:2:L out?:iron-plate:2:R
out?:coal:3:L out?:raw-wood:3:R
out?:electronic-circuit:4:L out?:advanced-circuit:4:R
out?:stone:5:L out?:stone-brick:5:R
Code: Select all
in?:1 in?:2 in?:3 in?:4 in?:5 in?:6 in?:7 out:8:L
in?:1 in?:2 in?:3 in?:4 in?:5 in?:6 in?:7 out:8:R
Code: Select all
c=:1:0
in:1 c+:1:1
jump?c=:1:5:4 out:2:L jump:2
out:3:L
- in the first line of this code counter 1 is set to 0
- in the second line smart box takes an item from the input 1 and increases value of the counter 1 by 1
- in third line smart box checks if value of counter 1 is equal to 5 - if it is, it jumps to line 4; otherwise it puts item to output 3 and jumps to line 2
- in fourth line smart box puts item to output 3. This is the last line, so after executing it code will continue from the first line (so the counter 1 will be set to 0 again).
TODO:
1. Make proper graphics instead of placeholders that are in use now.
2. [DONE] Improve GUI as much as possible
3. [DONE] Add more commands (better conditional instructions, possibly more advanced loops)
4. [DONE] Change Smart Box so it will work only if powered by electricity.
5. Make it possible to copy program from one Smart Box and paste it on another.
6. Ballance and optimalizations.
7. Read information from logistics network and use it in code.
Downloads:
There are two version of this mod. One uses a custom, monospace font, but it requires you to install this font in Factorio directory.
How to install font
You can also use version without this custom font, but it is not recommended - code readability is much better with monospace font.Note 1: Install only one of these version!
Note 2: If you updated this mod from an earlier version, you have to start a new game, loading a game saved with earlier version of the mod may result in crash.
Download normal version: Download version without font: Changelog:
v0.0.4
- increased processing speed for commands not related to input / output
- Smart Box now requires electric power to operate
- changed recipe for Smart Box
- added commands related to counters and jumps - Smart Box code is Turing-complete now!
- increased speed of command processing in Smart Box
- GUI now uses a monospace font for better clarity of code
- Code lines are now numbered
- Increased number of maximum lines of code to 64
- Added buttons to scroll code
- Removed debugging information that was printed to the console
- Fixed input area
- Initial release