Mindustry
Оцінок: 120
How To Use Procesors in 6.0
Автор: Circuitbreaker08
This guide will demonstrate how to use new processors and related items. Please mote this guide is not at all in a complete state.
3
2
8
2
2
   
Нагородити
До улюбленого
В улюблених
Прибрати
Introduction
This guide will teach you how to use processors and related items such as displays, memory cells and more to enhance your Mindustry experience. This guide is a work in progress, and may be incomplete for a long time. I intend to add new content as soon as possible. Some sections may be incomplete for some time.
Everything New Block In Logic
Micro Processor:
The most basic processor. It can execute programmed instructions.
Logic Processor:
This functions as a better, but larger processor. It has a higher tps and link range.
Hyper Processor:
It is is better than 2 the previous processors, but needs cryofluid to run. It is like an overclocked processor in the real world.
Message:
This block already existed in 5.0, but it is now retextured to blend in with the new purple theme.
Switch: It allows players to interact with the logic system without going into the code to do so.
Memory cell:
A block that allows two individual processors to communicate, and for processors to remember data after executing the "End" instruction.
Data Bank:
A larger memory cell that has 512 memory slots instead of 64.
Logic Display:
A block that displays graphical data with a size of 80x80 pixels.
Large Logic Display:
A larger version of the logic display that features a 179x179 pixel display.
The Basics
The primitive project is to turn a conveyor belt on and off with a switch.
The first step is to link blocks. Set up a conveyor belt, a processor, and a switch. Click on the processor.
No click on the belt and switch. It should look something like this.
Now click on the pencil icon below the processor. The interface will look like this.
Now press "Add" Click on "Sensor" The gui will now look like this.
This may look like a ton of mumbo jumbo, but this is the key to logic. If we deconstruct this command, the first part is the variable assigned. The game defaults to assigning it to "result" A best practice is to name a variable after its function. Like for this situation, you could use a word such as "active", but result will do for now. To properly read this block, click on the pencil next to "@copper" click on the tech tree icon. You will find it not to be a tech tree, but some properties like health, or power capacity.
Scroll down to the bottom to find enabled. Click on it. Now rename the 3rd and final field marked "in". Type in "switch1" Now add a control command. Use the same procedure as adding the the sensor. Fill in the blanks so the command reads "set enabled of conveyor1 to result" You should see this.
Feel free to play around with this as much as you want
Set
To use set, just name the variable, and a value. An example could be "active = 1."
Operation
This functions just like a calculator.
A Quick Tip
If you click on edit, you can copy code to your clipboard, as well as import from clipboard. This is good for sharing code, and I will use it in this guide. This can be edited in external programs, or even use a Python script to make preprogrammed changes, or even write one from scratch. But if you enter an invalid command and enter it, it will say it's invalid.
And if you copy and paste this into text, its says noop.
End, Jumps, and Looping Mecanics
This section is intended to demonstrate mechanics of command execution orders. End commands clear all variables in the processor, but not in memory cells or data banks. If the processor reaches the end of a sequence, it restarts at the top WITHOUT clearing variables. Jumps will make the processor start executing at the instruction the arrow points at, or in text the command number the last number indicates. You may think, that's useless! But the jump only executes if the condition is met. The conditions include ==, not <, <=, >, >=, and always. not is if the variables/values are unequal. the other inequalities act just like they do in math, but instead of declaring that state, its testing it. Always will jump no matter what.
Memory Cells and Data Banks
Data Banks are just cells with more capacity, so I won't bother. Here is a relay system to activate and deactivate a conveyor belt. This has three processors in the relay. I did make it loop around for presentation purposes.

Code for first processor:
sensor result switch1 @enabled
write result cell1 0

Code for intermediate processors:
read result cell1 0
write result cell2 0

Code for final processor:
read result cell1 0
control enabled conveyor1 result 0 0 0

Data is stored as a value in locations 0-63 in a cell, and 0-511 in data banks. Data will be overwritten when write is used, and stored as a variable in the processor when read is used.

These cells can also store data between execution of the "End" instruction. For example, we could count how many times switch is activated. But you might want to count how many times how many times it is reset. I know it sounds pointless, but it is only a proof of concept.
A Final Note
Thank you for reading my guide. Happy programming.
Коментарів: 24
carrot 31 берез. 2024 о 10:46 
i downloaded mindustry thinking hey just a simple tower defense game but no we have programming instead. ty for this guide and have my award
Circuitbreaker08  [автор] 7 листоп. 2022 о 18:09 
Yeah I might do that if I have some time. TBH, I need to look into that a little bit myself, but hey, whats the worse that could happen?
Awol 7 листоп. 2022 о 16:07 
Amazingly simple guide. Can you do one on making a unit take resources from the core to another building?
Glycia 16 черв. 2022 о 12:27 
ty <3
Circuitbreaker08  [автор] 20 жовт. 2021 о 16:40 
Just got another community award. Thanks for the love guys.
Circuitbreaker08  [автор] 1 серп. 2021 о 13:44 
If you hold down ctrl and left click on a unit, you can control it. From there you can press v to respawn from the core, or hit g to put a few surrounding units in formation. Press g again to disable. Bigger units control more units. Units in formation with shoot at the same spot as you, follow you, and assist with building.
SSP 1 серп. 2021 о 0:48 
Right but what about in the later attack levels when you need to direct the way your units attack the enemy base? I just barely scraped by in fungal pass by simply overwhelming the enemy and building turrets in range of their defense, but in the later ones my units will simply march to the enemy core without bothering to shoot at defenses on the way, which gets them killed. The processors seem to be there to help you organize them but it seems extremely difficult to actually get this to work.
Circuitbreaker08  [автор] 31 лип. 2021 о 12:57 
Logic is completely optional, and my main use is to save power by turning off force projectors when enemies are not nearby, and use flares to move items around to some hard to access blocks. If your have trouble, I advise trying a few other sectors, and come back with higher tech, and optimize your production of units and items.
SSP 31 лип. 2021 о 12:51 
Thanks for writing this because I was completely stumped by the processors. Do you know if there's a way to completely avoid using the processors and still win the game in its current state? I eventually gave up at around the third attack level and realizing I wasn't getting anywhere without using the processors to guide my units and the game not explaining how I was supposed to do that. Is there a strategy that just lets you use the non-logic stuff?
A Kings Ransom 12 берез. 2021 о 7:37 
I don't know if this is the best way to do this, but here's my program for making Megas go to a repair point when they get damaged. I find they always get on the frontline trying to repair something and end up getting killed, so this makes them cycle back for repairs:


sensor locx point1 @x
sensor locy point1 @y
ubind @mega
sensor h @unit @health
sensor hm @unit @maxHealth
op div hper h hm
op greaterThan result hper 0.75
jump 2 notEqual result false
ucontrol move locx locy 0 0 0
end