[WIP][0.11.20] Smart Box (v0.0.4)

Topics and discussion about specific mods
Post Reply
kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

[WIP][0.11.20] Smart Box (v0.0.4)

Post by kds71 »

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:

Code: Select all

/c game.player.insert{ name="smart-box", count=1 }
/c game.player.insert{ name="smart-box-programmer", count=1 }
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:
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
Another solution, using conditional instructions:

Code: Select all

in:1
jump?b=:iron-plate:3 out:2:L jump:1
out:2:R
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-...):

Code: Select all

in:1 out:2:L in:8 out:2:L
3. Sort 8 different items from one input into different output lanes:

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
4. Take any item from one of 7 inputs and place it alternately on both lanes of the output belt:

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
5. Put 4 items on output 2 and then put 1 item on output 3:

Code: Select all

c=:1:0
in:1 c+:1:1
jump?c=:1:5:4 out:2:L jump:2
out:3:L
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.
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:
smart-box_0.0.4.zip
(21.45 KiB) Downloaded 248 times
Download version without font:
smart-box-nf_0.0.4.zip
(20.55 KiB) Downloaded 224 times
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
v0.0.3
  • added commands related to counters and jumps - Smart Box code is Turing-complete now!
  • increased speed of command processing in Smart Box
v0.0.2
  • 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
v0.0.1
  • Initial release
Last edited by kds71 on Tue Jun 30, 2015 6:19 pm, edited 10 times in total.

jorgenRe
Filter Inserter
Filter Inserter
Posts: 535
Joined: Wed Apr 09, 2014 3:32 pm
Contact:

Re: [WIP][0.11.20] Smart Box (v0.0.2)

Post by jorgenRe »

That is a pretty ingenious mod you got there :)!
Gonna take a look onto how you did it ;) !
Logo
Noticed the told change in FFF #111 so il continue to use my signature ^_^
Thanks for listening to our suggestions, devs :D!
I would jump of joy if we could specify which tiles spawned in a surfaces

kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Re: [WIP][0.11.20] Smart Box (v0.0.2)

Post by kds71 »

jorgenRe wrote:That is a pretty ingenious mod you got there :)!
Thank you :)
jorgenRe wrote:Gonna take a look onto how you did it ;) !
I just uploaded new version with even more commands (counters and jumps), now the Smart Box is Turing-complete!

User avatar
StanFear
Fast Inserter
Fast Inserter
Posts: 236
Joined: Sun Dec 15, 2013 2:49 pm
Contact:

Re: [WIP][0.11.20] Smart Box (v0.0.4)

Post by StanFear »

waoh !

this is an amazing mod you have there,
kinda hopping the networking in 0.12 and 0.13 won't be able to replace what you did, or I wouldn't have any excuse to use it :p

one suggestion thougth, you said you were thinking about adding readability to the logistic network, do you plan on reading from wireless or from the wires ? (both would be interesting)
and ... what about 4 more outputs / inputs (actually maybe only 3) ? which ? logistic chests !

kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Re: [WIP][0.11.20] Smart Box (v0.0.4)

Post by kds71 »

StanFear wrote:one suggestion thougth, you said you were thinking about adding readability to the logistic network, do you plan on reading from wireless or from the wires ? (both would be interesting)
and ... what about 4 more outputs / inputs (actually maybe only 3) ? which ? logistic chests !
I'm not entirely sure yet, but I think that adding logistics chests that can communicate with a Smart Box as its additional inputs / outputs would be the best way to deal with logistic network - both wired and wireless.
StanFear wrote:kinda hopping the networking in 0.12 and 0.13 won't be able to replace what you did, or I wouldn't have any excuse to use it :p
Well, I think of this mod more as a proof of concept than anything else. I think that everything that Smart Box can do is possible to achieve even now (using a lot of smart inserters - they're Turing-complete as well), I just wanted to make a programmable entity :)

User avatar
StanFear
Fast Inserter
Fast Inserter
Posts: 236
Joined: Sun Dec 15, 2013 2:49 pm
Contact:

Re: [WIP][0.11.20] Smart Box (v0.0.4)

Post by StanFear »

kds71 wrote: Well, I think of this mod more as a proof of concept than anything else. I think that everything that Smart Box can do is possible to achieve even now (using a lot of smart inserters - they're Turing-complete as well), I just wanted to make a programmable entity :)
well I don't know about you but making sure I always have the same amount of two items in my chest is not something I can achieve with inserters only :)

kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Re: [WIP][0.11.20] Smart Box (v0.0.4)

Post by kds71 »

StanFear wrote:well I don't know about you but making sure I always have the same amount of two items in my chest is not something I can achieve with inserters only :)
Ah, you mean once I finish communication with logistic network? Because right now there is no way to achieve it with a Smart Box as well.

It will take some time, right now I'm focused on making it possible to copy / paste programs between different instances of Smart Box.

User avatar
StanFear
Fast Inserter
Fast Inserter
Posts: 236
Joined: Sun Dec 15, 2013 2:49 pm
Contact:

Re: [WIP][0.11.20] Smart Box (v0.0.4)

Post by StanFear »

kds71 wrote:
StanFear wrote:well I don't know about you but making sure I always have the same amount of two items in my chest is not something I can achieve with inserters only :)
Ah, you mean once I finish communication with logistic network? Because right now there is no way to achieve it with a Smart Box as well.
hummm... yeah there is (at least in theory), just count the items going to the chest and comming out of it


and the copy will be done the same way copy of recepies in assembling machines work ?

kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Re: [WIP][0.11.20] Smart Box (v0.0.4)

Post by kds71 »

StanFear wrote:hummm... yeah there is (at least in theory), just count the items going to the chest and comming out of it
Awesome, looks like you found a way to use my mod that I didn't think of :) It is actually possible to do, here is an album: http://imgur.com/a/bAAVM
It would be much easier if there was a way to compare two counters, I think I should implement it.

Of course, it is not perfect. First thing - items going out of target chests must go through the same smart box again, which is not an ideal solution. Second - more important - problem: it works properly as long the player doesn't add / remove items to one of target chests manually. These two problems should be solved once I implement connection between Smart Box and wired / wireless logistic network.
StanFear wrote:and the copy will be done the same way copy of recepies in assembling machines work ?
I was rather thinking about additional frame with saved programs, something like I did in my Upgrade with construction robots mod. It looks like that: http://i.imgur.com/f8fQyrT.png (I'm talking about that store / restore frame).

User avatar
StanFear
Fast Inserter
Fast Inserter
Posts: 236
Joined: Sun Dec 15, 2013 2:49 pm
Contact:

Re: [WIP][0.11.20] Smart Box (v0.0.4)

Post by StanFear »

kds71 wrote: Awesome, looks like you found a way to use my mod that I didn't think of :) It is actually possible to do, here is an album: http://imgur.com/a/bAAVM
It would be much easier if there was a way to compare two counters, I think I should implement it.
what you did works, although, I was thinking about keeping two differents items in stock whith the same amount of each
but hey, well done !

and, yeah comparing counters would be great !
kds71 wrote: Of course, it is not perfect. First thing - items going out of target chests must go through the same smart box again, which is not an ideal solution. Second - more important - problem: it works properly as long the player doesn't add / remove items to one of target chests manually. These two problems should be solved once I implement connection between Smart Box and wired / wireless logistic network.
well obviously, if the player messes with it, it won't be working as well :) but hey, it's factorio we're talking about, players shouldn't mess with automated stuff
kds71 wrote: I was rather thinking about additional frame with saved programs, something like I did in my Upgrade with construction robots mod. It looks like that: http://i.imgur.com/f8fQyrT.png (I'm talking about that store / restore frame).
oh, ok I see, why not, although, since here you have a world item, it would apeare more user friendly to have it done like in the rest of the game
but hey, your mod, your choices ! it'll be good to be able to copy from one smartbox to the other anyways :)

Neotix
Filter Inserter
Filter Inserter
Posts: 599
Joined: Sat Nov 23, 2013 9:56 pm
Contact:

Re: [WIP][0.11.20] Smart Box (v0.0.4)

Post by Neotix »

Programmable entires is what I always wanted in Factorio :D It bring new level of gameplay. You could ask YuokiTani to make some nice graphic for SmartBox.

kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Re: [WIP][0.11.20] Smart Box (v0.0.4)

Post by kds71 »

StanFear wrote:what you did works, although, I was thinking about keeping two differents items in stock whith the same amount of each
Ah, this one is a little bit more tricky, since you will have to do something with excess items, but I think it is possible to do as well.
StanFear wrote:well obviously, if the player messes with it, it won't be working as well :) but hey, it's factorio we're talking about, players shouldn't mess with automated stuff
I think that once I implement communication with logistic network it will be possible to keep it working even if player removes items manually - it would just read amount of items in each chest every few ticks and try to keep them ballanced.
StanFear wrote:oh, ok I see, why not, although, since here you have a world item, it would apeare more user friendly to have it done like in the rest of the game
I might be wrong, but I'm affraid it is not possible, since there are no events related to copying and pasting entity settings.
Neotix wrote:You could ask YuokiTani to make some nice graphic for SmartBox.
We will see, perhaps I will be able to do something on my own :) Right now graphics have very low priority, I want to implement all the features first.

User avatar
StanFear
Fast Inserter
Fast Inserter
Posts: 236
Joined: Sun Dec 15, 2013 2:49 pm
Contact:

Re: [WIP][0.11.20] Smart Box (v0.0.4)

Post by StanFear »

kds71 wrote: Ah, this one is a little bit more tricky, since you will have to do something with excess items, but I think it is possible to do as well.
yeah just sending them to another buffered chest that can be used by assembling machines
kds71 wrote: I think that once I implement communication with logistic network it will be possible to keep it working even if player removes items manually - it would just read amount of items in each chest every few ticks and try to keep them ballanced.
obviously, this would make it easier
kds71 wrote: I might be wrong, but I'm affraid it is not possible, since there are no events related to copying and pasting entity settings.
about that, I have no idea :(

kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Re: [WIP][0.11.20] Smart Box (v0.0.4)

Post by kds71 »

Ah, I just saw the forums and realized that changes in Factorio v0.12 related to modding will be bigger than I expected. I think I will postpone work on this mod until v0.12 is released.

Post Reply

Return to “Mods”