Glimmr Canvas Editor

version 1/100805 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Part - Hacking game restore so that we can offer our own customized restore message

    The output from restoring rules are a rulebook.

    The last output from restoring rule (this is the default restoring the game rule):
        rule fails.
        
    Output from restoring:
        say "[bracket]Saved file successfully restored.[close bracket][paragraph break]";
        print the editor startup text;
        rule succeeds.

    [GL__M(##Restore, 1) = "Restore failed"]
    [ GL__M(##Restore, 2) = "Ok."]

    Include (-

    [ RESTORE_THE_GAME_R res fref;
        if (actor ~= player) rfalse;
        fref = glk_fileref_create_by_prompt($01, $02, 0);
        if (fref == 0) jump RFailed;
        gg_savestr = glk_stream_open_file(fref, $02, GG_SAVESTR_ROCK);
        glk_fileref_destroy(fref);
        if (gg_savestr == 0) jump RFailed;
        @restore gg_savestr res;
        glk_stream_close(gg_savestr, 0);
        gg_savestr = 0;
        .RFailed;
        GL__M(##Restore, 1);
    ];

    -) instead of "Restore The Game Rule" in "Glulx.i6t".

    Include (-
    [ SAVE_THE_GAME_R res fref;
        if (actor ~= player) rfalse;
        fref = glk_fileref_create_by_prompt($01, $01, 0);
        if (fref == 0) jump SFailed;
        gg_savestr = glk_stream_open_file(fref, $01, GG_SAVESTR_ROCK);
        glk_fileref_destroy(fref);
        if (gg_savestr == 0) jump SFailed;
        @save gg_savestr res;
        if (res == -1) {
            ! The player actually just typed "restore". We're going to print
            ! a successful restore message; the Z-Code Inform library does this correctly
            ! now. But first, we have to recover all the Glk objects; the values
            ! in our global variables are all wrong.
            GGRecoverObjects();
            glk_stream_close(gg_savestr, 0); ! stream_close
            gg_savestr = 0;
            if ( FollowRulebook( (+ output from restoring rules +) ) && RulebookFailed())
            {
                return GL__M(##Restore, 2);
            }
            return;
        }
        glk_stream_close(gg_savestr, 0); ! stream_close
        gg_savestr = 0;
        if (res == 0) return GL__M(##Save, 2);
        .SFailed;
        GL__M(##Save, 1);
    ];

    -) instead of "Save The Game Rule" in "Glulx.i6t".