johanberntsson / PunyInform

A fast and compact library for writing text adventure games for the Z-machine running on 8-bit computers as well as other platforms.
MIT License
176 stars 17 forks source link

AfterLife() function with GS_QUIT value for deadflag #124

Closed auraes closed 4 months ago

auraes commented 4 months ago

The AfterLife() function, with PunyInform, is called not only when the player is dead, but also after the quit command (in this case deadflag = GS_QUIT), which can cause problems if not taken into account.
In this case, the quit command does not work:

[ AfterLife;
    deadflag = GS_PLAYING;
    "You're back in business!";
];

I have to do:

[ AfterLife;
    if (deadflag == GS_DEAD or GS_DEATHMESSAGE) {
        deadflag = GS_PLAYING;
        "You're back in business!";
    }
];

[ AfterLife;
    if (deadflag == GS_QUIT) @quit;
    deadflag = GS_PLAYING;
    "You're back in business!";
];

Adventureland game, designed by Scott Adams and ported to Infom6 (one of Inform 6's standard example games), highlights the issue:

[ AfterLife;
   if (deadflag==3) { deadflag=1; rfalse; }
   remove chigger_bites; remove infected_bites;
   deadflag=0; PlayerTo(Misty_Room);
];
fredrikr commented 4 months ago

Thanks, of course AfterLife shouldn't run after Quit. Fixed now.