Stationeers

Stationeers

View Stats:
A Stack Based High Performance Hydro LArRE
Thought to post it as a workshop item but I'm lazy. So here it is.

Features:
- Support up to 127 Hydroponic Trays status tracing
- As of the previous feature, don't over do it, if you use the code against over 127 trays, it will stack overflow/underflow and may destroy your plants.
- Support 1 Chute Import Bin (output sink, seeds, plants will go there and please sort them out yourself)
- FIFO(First In First Out) Seeding(seeding=-1) scanning
- LIFO(Last In First Out) Seeded/Harvested operation
- Can unstuck itself if you load the game and the Larre is just in the extended state, it will stuck, this code contains logic that checks itself and unstuck.
- It will try to get as many seeds as possible, then get as many plants as possible, then plants those plants again as many as possible, than plants those seeds as many as possible. If there are no empty trays to plant, it will drop them to the output station.
- Fertilization not supported, as Hydro LArRE not support checking other slots but 0.

Installation:
- I assume the code start at line 1
- The most important thing, the layout, should be: Larre first, then ChuteImportBin(OutputStation), then Trays(every tray has a station on top).
- Change Dock Name at line 1
- Change Last Station Index at line 2
- Change Output Station Index at line 3
- If your Station Indexes are positive, change -1 to 1 at line 12
- If your Station Indexes are positive, change 1 to -1 at line 15
- Move Larre to it's own station(which should be station 0, and don't stash it), then start the code.
- Plant the first batch youself(any number will do), then larre will take over and make 127trays full.

It's ♥♥♥♥ code, but high performance, you'll see. Don't blame me for this ♥♥♥♥ code because of the 128 line limit.

define HydroLarreDock HASH("Hydro LArRE Dock 1") define LastStation -29 define OutputStation -1 lbn r0 HASH("StructureLarreDockHydroponics") HydroLarreDock PositionX Maximum bnez r0 mainLoop # larre already booted up move r15 1 # PendingStackStartIndex move r14 0 # PendingStackEndIndex move r13 128 # SeedingStackIndex, support up to 128 hydroponic trays move r12 256 # HarvestingStackIndex move r11 384 # EmptyStackIndex move r9 0 # ifWholeLineScanned add r8 LastStation -1 # r8: pos move r7 0 # seekPendingCount initLoop: add r8 r8 1 beq r8 OutputStation startMainLoop jal MoveTo CheckUnder: lbns r0 HASH("StructureLarreDockHydroponics") HydroLarreDock 255 Occupied Maximum brnez r0 5 move sp r11 push r8 move r11 sp j CheckUnderJump lbns r0 HASH("StructureLarreDockHydroponics") HydroLarreDock 255 Seeding Maximum brgt r0 -1 5 # matured or seeding move sp r14 push r8 mod r14 sp 128 j CheckUnderJump brgt r0 0 5 # seeding move sp r12 push r8 move r12 sp j CheckUnderJump move sp r13 push r8 move r13 sp CheckUnderJump: breqz r7 3 # r7: seekPendingCount ble r7 10 TrySeekPending move r7 0 beqz r9 initLoop j mainLoop startMainLoop: move r9 1 mainLoop: move r0 0 yield lbn r1 HASH("StructureLarreDockHydroponics") HydroLarreDock Extended Maximum breqz r1 5 # not unstuck, continue add r0 r0 1 brgt r0 5 2 # wait for 5 tick, then unstuck self j -5 # loop back and wait jal ActivateArm lbns r0 HASH("StructureLarreDockHydroponics") HydroLarreDock 0 Occupied Maximum brgtz r0 7 bgt r13 128 SeekSeeds bgt r12 256 SeekPlants TrySeekPending: add r1 r14 1 bne r1 r15 SeekPending j mainLoop lbns r0 HASH("StructureLarreDockHydroponics") HydroLarreDock 0 SortingClass Maximum lbns r1 HASH("StructureLarreDockHydroponics") HydroLarreDock 0 MaxQuantity Maximum lbns r2 HASH("StructureLarreDockHydroponics") HydroLarreDock 0 Quantity Maximum breq r0 4 5 # has seeds, go down brlt r2 r1 2 # now arm has plants, not full jr 5 # arm full, try empty breq r12 256 4 # try get plants, but no plants available, try empty j SeekPlants brlt r2 r1 9 # has seeds, not full, go try get seeds brgt r12 256 7 # has plants slots, go SeekPlants brgt r11 384 5 # has empty slots, go SeekEmpty move r8 OutputStation # no empty available, drop arm items jal MoveTo jal ActivateArm j mainLoop j SeekEmpty j SeekPlants breq r13 128 -8 # trying to get seeds, but no seeds available, try get plants j SeekSeeds SeekPending: add r7 r7 1 move sp r15 peek r8 mod r15 r15 128 add r15 r15 1 jal MoveTo j CheckUnder SeekSeeds: move r10 13 jal Seek jal ActivateArm j CheckUnder SeekPlants: move r10 12 jal Seek jal ActivateArm j CheckUnder SeekEmpty: move r10 11 jal Seek jal ActivateArm j CheckUnder Seek: move sp rr10 # current stack index pop r8 move rr10 sp MoveTo: sbn HASH("StructureLarreDockHydroponics") HydroLarreDock Setting r8 yield lbn r0 HASH("StructureLarreDockHydroponics") HydroLarreDock Idle Maximum breqz r0 -2 j ra ActivateArm: sbn HASH("StructureLarreDockHydroponics") HydroLarreDock Activate 1 yield lbn r0 HASH("StructureLarreDockHydroponics") HydroLarreDock Idle Maximum breqz r0 -2 j ra
Last edited by lisnaz; Jan 9 @ 7:51pm
< >
Showing 1-2 of 2 comments
Rocket  [developer] Jan 9 @ 6:02pm 
This is really cool. Is there anything missing from the IC system you can think of as you went through this? I'm always on the lookout for features or instructions to add.
lisnaz Jan 9 @ 6:40pm 
Originally posted by Rocket:
This is really cool. Is there anything missing from the IC system you can think of as you went through this? I'm always on the lookout for features or instructions to add.

Thanks.
For the bigger picture, a debugger may really be helpful, an external community emulator maybe useful, but it requires a lot of time to setup the device statuses.

For coding level, I guess:
- line limits, e.g.: comment lines should not be counted as line, it's simple to remove in the preprocessing, and because of this, relative jump may need to re-think, maybe comments line should not be numbered.
- The new machine instructions are nice addons but lacks documentations.
- No counterparty for function peek.
- Variable name should support underline.
- No sbns.
- Could add some simple conditional operations like treat >=0 like 2 or 3 or etc all count as positive, e.g.: sand a b c, if both b and c >=0, then set a to 1.
- Could add deeper call stack tracking, rather than single ra.
- Could add more stack, lol, so we may emulate array, map, etc.

I guess that's too much, you see what's fit.
Last edited by lisnaz; Jan 9 @ 8:10pm
< >
Showing 1-2 of 2 comments
Per page: 1530 50