deltanedas / anuke-logic

Mindustry mod that adds more logic blocks.
GNU General Public License v3.0
9 stars 7 forks source link

Fix information in RTFM entry for Reflect command #2

Closed stoneRdev closed 3 years ago

stoneRdev commented 3 years ago

So, the RTFM entry for reflect states that it cannot be used to create variables, and that cell-less access requires set "arr_n " = 0 for n => capacity. I'm pretty sure I just did what that said was impossible, but I'd like to share for a second opinion and maybe to have the manual entry changed if this proves it possible. Here's the code, it sets up variables "reg_0" => "reg_9" using Reflect:

set registerNameHeader "reg_"
set initialValue 0
set i 48
set m 57
string push t "" i 0
string add rd registerNameHeader t 0
reflect set rd initialValue
op add i i 1
jump 4 lessThanEq i m
print reg_0
print "\n"
print reg_9
printflush message1

It's a bit hacky, and will only go from 0 to 9 without an extra loop for the other digit, but does in fact set all the variables properly (checked by an attached message block)

What are your thoughts on this?

deltanedas commented 3 years ago
print reg_0
print "\n"
print reg_9

here you are creating variables, so reflect set has something to work with. (for those 2 only) if you try to get them with reflect get val "reg_0" you'll get null back.