Community

SCI Programming => SCI Syntax Help => Topic started by: Doan Sephim on December 27, 2020, 10:42:15 AM

Title: [SOLVED] SCI0 - Autosave
Post by: Doan Sephim on December 27, 2020, 10:42:15 AM
How difficult would it be to create an autosave function that runs whenever the player enters a new room?

Ideally, it would always replace the previous autosave file and be located at the top of the restore window with the name "autosave"

I'm looking in the Game script and found the Save method, but I'm not sure how to call this method without producing a window. I'd like this to go on "behind the scenes," as it were.

Code: [Select]
(method (save &tmp [strDescBuf 20] gameNum oldCursor hSound)
(Load rsFONT gSaveRestoreFont)
(Load rsCURSOR gLoadingCursor)
(= oldCursor (self setCursor: gNormalCursor))
(= hSound (Sound pause: 1))
(if (GetSaveDisk TRUE)
(if gPrintDlg (gPrintDlg dispose:))
(= gameNum (Save doit: @strDescBuf))
(if (!= gameNum -1)
(= oldCursor (self setCursor: gLoadingCursor 1))
(if
(not (SaveGame objectName gameNum @strDescBuf gVersion))
(Print
{Your save game disk is full. You must either use another disk or save over an existing saved game.}
#font
0
#button
{OK}
1
)
)
(self setCursor: oldCursor (HaveMouse))
)
(GetSaveDisk FALSE)
)
(Sound pause: hSound)
)

Not having a feature like this isn't a big deal and I place a low priority on implementing it, but it certainly would be nice!

I'm going to experiement with this bit of code here, but if anyone has better ideas or guiding thoughts, let me know.

Code: [Select]
(SaveGame objectName gameNum @strDescBuf gVersion))
Title: Re: SCI0 - Autosave
Post by: Kawa on December 27, 2020, 04:00:12 PM
You actually have most of the answer right there already: (SaveGame (gGame name?) 0 "Autosave" gVersion), in perhaps Main::newRoom.
Title: Re: SCI0 - Autosave
Post by: Collector on December 27, 2020, 04:27:53 PM
Has anyone tried decompiling QfG4 yet? It has an autosave.
Title: Re: SCI0 - Autosave
Post by: Collector on December 27, 2020, 04:31:20 PM
You actually have most of the answer right there already: (SaveGame (gGame name?) 0 "Autosave" gVersion), in perhaps Main::newRoom.

Wouldn't that save on every new room? I would think you would want it to only auto save on entry to a dangerous room. Perhaps have a flag for new room that can be set if there is any danger.
Title: Re: SCI0 - Autosave
Post by: Kawa on December 27, 2020, 04:39:06 PM
Or just put that line in the init for those specific rooms lol.

How difficult would it be to create an autosave function that runs whenever the player enters a new room?
It wasn't specified that it should only autosave in dangerous rooms~




Has anyone tried decompiling QfG4 yet? It has an autosave.
Picking a random room, 600, I found this at the bottom of its init:
Code: [Select]
(if (and (proc0_4 380) (!= gPrevRoomNum 810))
  (gGame save: true)
)
Notice the extra parameter. Normally, Main::save just calls Game::save. QFG's Glory::save only does that if false or nothing is given. If it's true, it does a lot of stuff but ultimately saves "Automatic Save".
Title: Re: SCI0 - Autosave
Post by: Collector on December 27, 2020, 05:43:16 PM
Remember that it names the autosave "Automatic Save" and overwrites any previous autosave, so there is more to the save method than previous SCI versions, as I would assume you would realize. Also, the game control has an autosave option for the player to be able to turn it on and off.
Title: Re: SCI0 - Autosave [Solved]
Post by: Doan Sephim on December 27, 2020, 10:02:48 PM
You actually have most of the answer right there already: (SaveGame (gGame name?) 0 "Autosave" gVersion), in perhaps Main::newRoom.

Yup, this does it very cleanly! Simple and effective. And I suppose I could make a toggle if someone wants to turn off the autosave and have a more *authentic* Sierra game experience :P

Thanks again Kawa!

Here's the code in the Main script if any one needs it:
Code: [Select]
(method (newRoom roomNum picAni)
(DisposePrintDlg)
(Load rsFONT gDeadFont)
(Load rsFONT gDefaultFont)
(Load rsFONT gSaveRestoreFont)
(Load rsCURSOR gNormalCursor)
(Load rsCURSOR gLoadingCursor)
;(SaveGame (gGame name?) 0 "Autosave" gVersion)
(super newRoom: roomNum)
(if (< argc 2)
(= gDefaultPicAni (Random 0 5))
else
(= gDefaultPicAni picAni)
)
(SaveGame (gGame name?) 0 "Autosave" gVersion)

)
Title: Re: [SOLVED] SCI0 - Autosave
Post by: Collector on January 03, 2021, 01:04:15 PM
Can you call it a "more *authentic* Sierra game experience" when QfG4 had it?
Title: Re: [SOLVED] SCI0 - Autosave
Post by: Doan Sephim on January 04, 2021, 12:29:01 AM
Can you call it a "more *authentic* Sierra game experience" when QfG4 had it?
Showing my ignorance here. I never played QfG4! Watched my bro play it a million times, but never got familiar with it's save features.

My guess would be that "auto-save" and "Sierra adventure" are two terms not generally thought of together, outliers notwithstanding.
Title: Re: [SOLVED] SCI0 - Autosave
Post by: Charles on January 05, 2021, 09:10:08 AM
QfG3 had autosave, too... although they only used it like 2 or 3 times, if I recall right.
Title: Re: [SOLVED] SCI0 - Autosave
Post by: Kawa on January 05, 2021, 11:12:32 AM
QfG3 had autosave, too... although they only used it like 2 or 3 times, if I recall right.
Confirmed, looks about the same as in QfG4. Twelve hits for (gGame save: 1).