ThePix / QuestJS

A major re-write of Quest that is written in JavaScript and will run in the browser.
MIT License
66 stars 13 forks source link

UNDO issue (and fix?) #26

Closed KVonGit closed 3 years ago

KVonGit commented 3 years ago

Hello!

I could only UNDO one time before receiving an error concerning the nonexistence of game.timeSaveAttribute.

I added this to settings.setup to modify the game.postLoad function. Instead of deleting the attribute, this sets it to an empty string, and UNDO works properly (so far).

                //Fix UNDO!!
        //UNDO only works once in this game using Quest 6 version 0.2 without this fix.
        //It throws 'missing game.timeSaveAttribute' error without this fix. (Probably because I use turnscripts?)

        game.postLoad = function(){
            game.timerEvents = [];
            const arr = game.timeSaveAttribute.split(' ');
            for (let el of arr) {
                const params = el.split('/');
                const interval = params[2] === '-' ? undefined : parseInt(params[2]);
                game.timerEvents.push({eventName:params[0], triggerTime:parseInt(params[1]), interval:interval});
            }
            //delete game.timeSaveAtrribute;  /*KV commented this line out*/
            //KV added the next line of code.
            game.timeSaveAttribute = '';
        };
ThePix commented 3 years ago

Thanks, fixed.