Lonami / pyndustric

A Python compiler for Mindustry's logic processors assembly language
MIT License
48 stars 9 forks source link

Use of subscripting? #29

Closed TelosTelos closed 3 years ago

TelosTelos commented 3 years ago

Just noting here that I've been thinking of allowing two uses for object[ index ]

memoryblock[integer] should be usable to read/write from the slot with that number in a memory block

object['@sensableattribute'] should compile to a sensor command to read @sensableattribute in object. We already allow most current/future sensable attributes via object.sensableattribute but this may not work for future attributes that contain underscores. I also have yet to check whether mlog allows dynamic assignment of attribute type, e.g. as in the following pseudocode, but if it does, we'd need some syntax like this to have any hope of allowing it:

res = @copper
amt = vault1[ res ]
Lonami commented 3 years ago

Probably easier to provide a method read, because subscripting is for sensing things, not reading. So we'll have:

index = 7
memory1.read(index)

resource = Env.copper
container1[resource]