Tip
This mod supports the latest Mindustry 8 Beta release. There's also a version compatible with Mindustry 7, which has fewer features and is no longer being developed.
Note
Using this mod on maps with lost of processors may have a negative performance impact on the game.
Mod intended to make debugging in Mindustry Logic a bit easier. Provided functionality:
- Settings for overriding instruction limit (the limit can be increased up to 2000 instructions). This allows you to insert debugging code (e.g., additional
printinstructions) into your code, even if the original instruction limit is exceeded. - Buttons to copy the variables (including their full, unrounded values) and the processor's text buffer to clipboard. The variables can be pasted into a spreadsheet and sorted by name for easier inspection.
- Custom mlog instructions for performing runtime checks.
- Indication of failed runtime checks, stopped processors, and processors performing a
wait.
The custom instructions are used by Mindcode to perform runtime checks. They can be used by other compilers too or by a manually written mlog.
When a runtime check fails, the program execution stops at the given instruction, and an accompanying message is displayed above the processor.
This is a complex instruction, most useful to verify the value of a variable used as an index into an array is within bounds. Using out-of-bounds index for internal arrays can cause erratic, hard-to-diagnose behavior. The instruction takes these parameters:
type: keyword. Specifies the required type of the value being tested:any: any value is allowed,notNull: any value exceptnullis allowed,decimal: a numerical value is required,integer: an integer value is required,multiple: an integer value that is a specified multiple is required.
multiple: the required multiple in casetypeismultiple.min: the minimum allowed value.opMin: one oflessThanorlessThanEq, specifies whether the minimum value is included in the allowed range.value: the value being tested.opMax: one oflessThanorlessThanEq, specifies whether the maximum value is included in the allowed range.max: the maximum allowed value.message: the error message to display in case the assertion fails.
The instruction compares an actual value to an expected value and displays an error message if they are not equal. The instruction takes these parameters:
expected: the expected value.actual: the actual value.message: the error message to display in case the assertion fails.
The values are compared using the strictEqual mlog operator.
This instruction must be used at the beginning of a block of code which generates text into the text buffer (using any of the printing instructions, print, printchar or format). The assertprints instruction is then used to compare the output generted by the program to an expected string. The instruction takes these parameters:
position: output variable receiving the current position in the text buffer.
This instruction compares the output generated by the program to an expected string. The instruction takes these parameters:
position: the position in the text buffer at the beginning of the tested code (must be the variable used by theassertflushinstruction).expected: the expected string.message: the error message to display in case the assertion fails.
When the instruction finishes, the text buffer is restored to the state of the previous assertflush instruction.
Note
The content of the text buffer is not saved into the map file. Therefore, when a map is loaded from a save file, the asssertprint instruction may spuriously fail.
This instruction displays an error message and stops the program execution. The instruction takes these parameters:
message: the error message to display.p1..p9: additional parameters to display in the error message.
If the message contains placeholders in the form [[1] to [[9], they are replaced by the corresponding parameters. If there are other parameters not used by the message, whose value is not null, they are appended to the message one by one.
Allows increasing the instruction limit in logic processors. The increased limit may be used to add debugging code to your program, which otherwise wouldn't fit due to the standard instruction limit being exceeded.
Sets the minimal wait time specified in the wait instruction parameter which causes the wait to be indicated on processors. It is possible to completely hide the indication by setting the value to 0.
To indicate the stopped and waiting processors, the mod needs to inspect the state of all processors on the map periodically. At most the given number of processors gets inspected in each tick. If there are a lot of processors on the map and the performance suffers, reducing this value may help.
Governs the use of visual effects on the map itself to draw attention to stopped or failed processors. Effects can be turned off completely, performed just once hwen the processor is stopped or failed, or performed periodically with a given interval.
