This is actually a Mindustry bug.
When a schematic has gaps in link names (e.g., only uses switch2 and switch4) , the link numbers may get reassigned when building the schematic in game (to switch1 and swich2 in this case).
With the implementation of #284, the issue can be completely avoided by only using symbolic link names in the schematic definition and having the compiler and schematic builder assign the actual link names automatically, which prevents any gaps in link numbering.
Even if the Mindustry bug is fixed, there is still potentially an issue if the schematics are used in older versions of the game. There are several possible solutions:
- Display an error (demoted to a warning when the target is 8.1 if it gets fixed in Mindustry) when a gap in the link numbers is detected.
- Add phantom links to the schematic (i.e., links to non-existent block) to fill up gaps in link numbers.
- Renumber even physical links automatically to remove gaps.
I'm probably not going to do the second point, not even as an opt-in option. It would create schematics that link to blocks not originally included after being built, and figuring out the positions for the phantom blocks might be tricky. It is possible to add phantom links explicitly if need be.
The third point is a bit iffy when building schematic using mlog (and not Mindcode) code. The mlog code could use switch1 as a variable, for example, even accessing it indirectly via read or write, and forcing the renumbering of switch2 to switch1 could change the intended behavior of the program.
This is actually a Mindustry bug.
When a schematic has gaps in link names (e.g., only uses
switch2andswitch4) , the link numbers may get reassigned when building the schematic in game (toswitch1andswich2in this case).With the implementation of #284, the issue can be completely avoided by only using symbolic link names in the schematic definition and having the compiler and schematic builder assign the actual link names automatically, which prevents any gaps in link numbering.
Even if the Mindustry bug is fixed, there is still potentially an issue if the schematics are used in older versions of the game. There are several possible solutions:
I'm probably not going to do the second point, not even as an opt-in option. It would create schematics that link to blocks not originally included after being built, and figuring out the positions for the phantom blocks might be tricky. It is possible to add phantom links explicitly if need be.
The third point is a bit iffy when building schematic using mlog (and not Mindcode) code. The mlog code could use
switch1as a variable, for example, even accessing it indirectly viareadorwrite, and forcing the renumbering ofswitch2toswitch1could change the intended behavior of the program.