Stationeers

Stationeers

View Stats:
Handy IC10 Script for Automated Printing and Stacking
I put a stacker on a fabricator (printer), mainly to stop a pile of cables from spilling everywhere and pipes exploding all over the base. Eventually got tired of manually counting items as they finished and then messing with both power switches, so put the little script below together.

To set up to use this script, construct Basic Chutes to send the output of a printer into a stacker, then the output of the stacker to a Chute Outlet. On the printer, make sure to wire both power AND logic to the same network your IC10 is running on, and make sure you wire power to the stacker also on the same network. With your Labeler tool, rename your printer and stacker pair to the SAME name using the names from the script below, e.g. "MyAutolathe", or choose your own names and update the script names below.

Test that everything is working by turning the printer on and off. The stacker power should turn on and off with the printer. If this doesn't work, then nothing else will work either.

You don't need to construct all the printers to start with and it doesn't matter which of the printers you set up first: the script will happily ignore anything that it doesn't find. Does not matter if you are using a reverse stacker, the script figures out which one it is. Also, feel free to trim out what you don't need; e.g., who needs a stacker on the tool printer? If _you_ don't, you can remove the three lines starting with "move rName HASH("MyToolPrinter")".

To use your new automation, set number of items to print with the stacker dial & start printing the items you want. The printer will automatically stop when the count has been printed and the finished items will eject. Again, the script also controls power of the stacker with the printer's power, so there is just one switch to hit. Clears the count when printer is turned off, as a safety. If you open the printer (pull the lever), it will eject stacks of no-less-than MinIngotStackSize (100) by changing the stacker setting if it is smaller than that.

alias rName r8 alias rPrinter r9 alias rStackerId r10 define SStacker HASH("StructureStacker") define SStackerR HASH("StructureStackerReverse") define MinIngotStackSize 100 main: yield move rName HASH("MyAutolathe") move rPrinter HASH("StructureAutolathe") jal autoprint move rName HASH("MyPipeBender") move rPrinter HASH("StructureHydraulicPipeBender") jal autoprint move rName HASH("MyElectPrinter") move rPrinter HASH("StructureElectronicsPrinter") jal autoprint move rName HASH("MyToolPrinter") move rPrinter HASH("StructureToolManufactory") jal autoprint j main autoprint: # Find ID of stacker or reverse stacker with rName (highest ID) lbn rStackerId SStacker rName ReferenceId Maximum brgt rStackerId ninf 3 lbn rStackerId SStackerR rName ReferenceId Maximum ble rStackerId ninf ra # return if no stacker found # Control stacker power with printer power lbn r0 rPrinter rName On Sum sd rStackerId On r0 # Clear printer memory when printer power is off seqz r0 r0 sbn rPrinter rName ClearMemory r0 bnez r0 ra # Check if printer is open ld r1 rStackerId Setting # need r1 below as well lbn r0 rPrinter rName Open Sum beqz r0 autoprintPrinterNotOpen # Clear stacker if printer open and empty lbn r2 rPrinter rName Reagents Sum brnez r2 3 move r2 1 sd rStackerId Activate r2 # Force big stacks, so the floor isn't littered with individual ingots move r0 MinIngotStackSize brge r1 r0 3 move r1 r0 sd rStackerId Setting r1 autoprintPrinterNotOpen: # Return if printed item count < stacker setting lbn r0 rPrinter rName ExportCount Sum blt r0 r1 ra # When printed item count >= stacker setting # Stop printer, clear printed item count move r0 0 move r1 1 sbn rPrinter rName Activate r0 sbn rPrinter rName ClearMemory r1 # Wait for chutes to clear the last ingot, then eject Stacker yield sd rStackerId Activate r1 j ra
Last edited by Mazer Rackham; May 16 @ 5:17pm
< >
Showing 1-15 of 25 comments
That is a clever solution to an annoying problem.

I used to babysit the printers when printing stuff like pipes just to keep them flying around and my OCD always went berserk when I'd see stacks of sheets getting jammed together. Always had a thought that they might blow a window out or something.

I got the idea of hooking a stacker to a printer from watching Cows are Evil and it helps a lot.
Without this logic, it's still uncontrolled in terms of having to babysit resource usage. This is brilliant!

Thanks for sharing!
Edited the above to make suitable for running against multiple printers, as well as address a potential desync between printer and sorter.
Last edited by Mazer Rackham; May 6 @ 9:51pm
Turgem May 11 @ 6:12am 
I need more instructions???

Can you tell me where i put the name of printer and stacker ???
Do I select them on the pins of IC Housing? eg. D0 to E Printer and D1 to Stacker

sorry if the answer is already in my face
WussyBoy May 11 @ 9:42am 
@Turgem, I assume you are already familiar with the renamer tool. You'll have to use it some.

The code doesn't require any pins set on the housing. Lines like "alias Printer d1" would be the indication that device pins were used but the author uses definitions and links up specific devices in the first two lines of code.

The code does use registers, which are set on Line 7 using the word "alias". This alias is used to hold the name of the device that you set with your renamer tool. In line 8, "move rName HASH("EPrinter")" the name of the device you set yourself is grabbed and set to the alias on r2.

The code assumes you will want to chance Line 1 to a different sort of printer, change the name of the printer yourself and use that for Line 8 instead of "EPrinter".

The author has provided comments, starting with the "#" character in order to give the user some clues as to what is going on beyond the basic code, even providing a space for additional printers to use the code when entered between Line 9 and Line 11.

Hope this helps!
Turgem May 11 @ 8:10pm 
Thanks for the reply...

I did rename printer to e printer it did print out my chosen quantity of cable but didn't auto stop printing.
WussyBoy May 12 @ 11:36am 
I had a chance to load this up a little while ago and my error was different from your error.

Initially I was seeing behavior similar to yours, but I realized that I had forgotten to connect the data port on the electronics printer. Once that was done, I noticed that the script appears to be requiring the electronics printer and the stacker to be named the same, so I did that too, and when I tried again the printer would start to print a single item then deactivate itself immediately.

I went through and defined the stacker as "sName" and modified all the corresponding values that call the stacker, and that helped. It did print 3 items and then stop.

But the logic for slaving power together was not working correctly and the chip was flashing an error on my modified code line 22. Don't really have time to dig deeper at the moment, but I will.
Originally posted by Turgem:
I need more instructions???

Can you tell me where i put the name of printer and stacker ???
Do I select them on the pins of IC Housing? eg. D0 to E Printer and D1 to Stacker

sorry if the answer is already in my face

Updated the script to add a few refinements and wrote clear instructions. LMK if this works for you!
Originally posted by WussyBoy:
I had a chance to load this up a little while ago and my error was different from your error.

I updated the script to make things more clear + added instructions. You shouldn't need to change anything in the script related to the stacker, just name both printer and stacker the same.

I have to ask: is it possible that you didn't spin the stacker dial to change the number of items to print? If you leave it at "1", it will only print one item then stop.
Last edited by Mazer Rackham; May 12 @ 4:06pm
WussyBoy May 12 @ 6:45pm 
Originally posted by Mazer Rackham:
Originally posted by WussyBoy:
I had a chance to load this up a little while ago and my error was different from your error.

I updated the script to make things more clear + added instructions. You shouldn't need to change anything in the script related to the stacker, just name both printer and stacker the same.

I have to ask: is it possible that you didn't spin the stacker dial to change the number of items to print? If you leave it at "1", it will only print one item then stop.
I definitely had the stacker set to 3. I'll try the new version and see if that helps.
WussyBoy May 12 @ 8:14pm 
I tried it as posted, and there is an error on line 40.

beqz autoprintNoAdjustment

The computer is expecting a register value but there is only a branch line reference. I added an r1 for testing;

beqz r1 autoprintNoAdjustment

and the program ran, but I am still having the same issue with the printer starting and then instantly stopping. The code seems to run OK when I put it in the IC10 simulator via your link above, so perhaps there is a difference between the simulator and "real life".

I combed through the older version of the code earlier today step by step and it appears to be valid, but something is going wrong, unless I'm making another mistake somewhere.
Originally posted by WussyBoy:
I tried it as posted, and there is an error on line 40.

beqz autoprintNoAdjustment

The computer is expecting a register value but there is only a branch line reference. I added an r1 for testing;

beqz r1 autoprintNoAdjustment

Oops... That should be:
beqz r0 autoprintNoAdjustment

I updated the OP with this fix. FYI, r0 has the open status of the printer, so the code should branch if the printer is closed (eqz). r1 at this point has the stacker setting, which will always be > 1.

Sorry, but I'm lifting this code out of a larger script. I had it updated in one editor, but not the other, lol. The OP code should work now.
Last edited by Mazer Rackham; May 12 @ 10:01pm
Originally posted by WussyBoy:
I but I am still having the same issue with the printer starting and then instantly stopping. The code seems to run OK when I put it in the IC10 simulator via your link above, so perhaps there is a difference between the simulator and "real life".

Can you double check that you are using "r0" in the following line, and not "r1" by accident?
sbn rPrinter rName Activate r0
Last edited by Mazer Rackham; May 12 @ 10:58pm
WussyBoy May 13 @ 8:37am 
Yes, I confirmed that r0 is being used in that line.

I imported the newest version and the issue remains. Tried commenting out unused printers, as I'm testing with an electronics printer only, but no change.

When I hit the screen, I assume that flips the "Activate" bit to a 1 in the printer. I don't see anywhere else that "Activate" is used except to shut it off. Perhaps there is a step that allows the code to go from the player activating the printer through to line 53 before line 49 is done branching.

blt r0 r1 ra

The jal and ra references allow the code to cycle through all the printers one by one. It behaves as if something is immediately setting Activate to 0 almost as soon as the printer is activated.

At least that's the way it appears to my relatively unseasoned eye.
Originally posted by WussyBoy:
I imported the newest version and the issue remains. Tried commenting out unused printers, as I'm testing with an electronics printer only, but no change.

<snip>

It behaves as if something is immediately setting Activate to 0 almost as soon as the printer is activated.

Sounds like it to me, too. TBH, I have no clue... I had thought you maybe placed a reverse stacker instead of normal direction, but then the Setting in r1 would be NaN, with a result of the printer NOT stopping (I tested this by forcing `move r1 NaN`).

Guesses... Any chance you have another IC10, or other logic writer, on the network that's setting the printer Activate to 0, or otherwise messing with printer or stacker? Or, do you have a transformer on the loop and hit the network power limit when trying to print? Running mods? Not on the current version? Forgot to hit "Export"? Forgot to select the device that Export will write the code to?

FYI, I directly imported the script this time and verified it functions correctly. The only path to deactivating the rPrinter device in this script is if the Printer's "ExportCount" is greater than or equal to the Stacker's "Setting".
Last edited by Mazer Rackham; May 13 @ 1:38pm
< >
Showing 1-15 of 25 comments
Per page: 1530 50