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

Add inline context syntax for operations (short-hand `with` statements) #46

Closed tech-ticks closed 1 month ago

tech-ticks commented 2 months ago

Closes #49

Alternative for or addition to https://github.com/SkyTemple/ExplorerScript/pull/45.

Code example:

MovePositionOffset<actor ACTOR_ATTENDANT1>(1, 24, 0);
WaitExecuteLives(ACTOR_ATTENDANT1);

SetEffect<actor ACTOR_ATTENDANT1>(EFFECT_JOYOUS, 3);
MovePositionOffset<actor ACTOR_ATTENDANT1>(1, 48, 0);
WaitExecuteLives(ACTOR_ATTENDANT1);

SetEffect<actor ACTOR_ATTENDANT1>(EFFECT_NONE, 3);

The compiled code is identical with the existing with syntax.

theCapypara commented 2 months ago

@tech-ticks You changed the SsbScript syntax but did not change the compiler. You will need to also support this syntax in SsbScript or at least throw an exception.

tech-ticks commented 1 month ago

Sorry for the late reply. I opted for throwing an exception because with blocks are also not supported so it didn't feel like a good fit for the language.