SkyTemple / ExplorerScript

ExplorerScript and SSBScript: Script languages for decompiled SSB (Pokémon Mystery Dungeon Explorers of Sky)
MIT License
16 stars 6 forks source link

Allow multiple operations in `with` blocks #45

Closed tech-ticks closed 1 month ago

tech-ticks commented 2 months ago

Closes #4

Multiple statements in with blocks

This PR allows multiple statements in a single with block. For example, the following ExplorerScript:

with (actor ACTOR_ATTENDANT1) {
        SetEffect(EFFECT_JOYOUS, 3);
        MovePositionOffset(1, 48, 0);
}

generates this SSBScript:

lives(ACTOR_ATTENDANT1);
SetEffect(EFFECT_JOYOUS, 3);
lives(ACTOR_ATTENDANT1);
MovePositionOffset(1, 48, 0);
theCapypara commented 2 months ago

cool stuff! I'll try to review it soon.

Regarding the future work: In theory it should be relatively simple to implement self, the compiler ctx would need a mechanism similiar to how loops are kept track of to know what is the active with-block if any and if self is encountered that is checked and used (or if None the compilation failed).

theCapypara commented 1 month ago

@tech-ticks I think general consensus is not having super/self, so I think only documentation is missing here, right?