Page 1 of 1

New Module - Trouble saving game

Posted: Fri Aug 03, 2018 4:52 pm
by Kemsha
Hi guys,

I'm trying to make a new module and it has been a rough ride.
The ideia is to have a guild with many adventurers available and be able to choose one to do stuff, mostly dungeon exploring.

I've realized that most of the stuff on the engine assume just one main character so that was one of the biggest problems

The first BIG decision was to choose a base to start. I think I've regret it already but I've used TOME as a base thinking that it would be easier to remove stuff than to add it. It's a BIG thing to chew on but I've made some progress and now, I think I've done too much to turn back.
A bit off-topic but I (humbly) think that there should be some kind of base module to help newcomers with stuff like inventory management, character sheet, simple dungeons and stuff like that. Wasn't there an "example module" a few years back?


So far I can manage several adventurers, create(hire) new ones and send them to their deaths. I can manage their status like travelling or healing and have some simple goals on each mission.

So what's missing to have at least a simple playable start? Saving and loading. All my data is in the "game" object but I can't load it. I'm not sure if the problem is in the saving or loading part. I've been trying to examine the save file but with no luck. For example, in my instance of "game" I have a table "advList" with a list of available adventurers (with the object "Player"), where should I see it in the save file? Do I need to change the save process or the engine manages it?
Basically I'm having trouble debugging this process and can't find out where the problem is.


Thanks and sorry for the long post.


P.S. I wanted to have some sort of "strategic layer" where I managed the adventurers and the guild. I used a new "wilderness" zone showing my screen on the "on_load" event. I'm not very convinced that is is the best way but it works so far, was there a better alternative?

Re: New Module - Trouble saving game

Posted: Sun Aug 05, 2018 8:24 pm
by Zizzo
Kemsha wrote:The first BIG decision was to choose a base to start. I think I've regret it already but I've used TOME as a base thinking that it would be easier to remove stuff than to add it.
:shock: *blink* …You're braver than I am. I started from the example module and… "borrowed" from the main module as necessary. :wink:
Kemsha wrote:I've realized that most of the stuff on the engine assume just one main character so that was one of the biggest problems
You might be able to bend mod.class.Party and related classes to your needs.
Kemsha wrote:Wasn't there an "example module" a few years back?
Still is. It may not be in the precompiled packages; if not, you'll need to get the source package from the download page. It's in the game/modules/example/ directory.
Kemsha wrote:All my data is in the "game" object but I can't load it.
You mean directly in the Game object? As in "game.advList = { dude1, dude2, … }"? That's likely your problem. Stuff like that traditionally lives in the GameState object. If you're bound and determined to put it in game, the engine.Game:defaultSavedFields() method controls which fields of game get saved to the savefile.
Kemsha wrote:I've been trying to examine the save file but with no luck.
Well, as you may know, the game.teag and zone-<zone-name>.teaz files are just renamed .zip files. In them, the file 'main' is basically Lua instructions for reassembling the relevant Game resp. Zone object; the other files are other contained objects with their own reassembly instructions. For instance, game.teag will probably contain a file 'mod.class.Player-0x<hex-digits>', describing game.player.

Re: New Module - Trouble saving game

Posted: Mon Aug 06, 2018 10:59 am
by Kemsha
Zizzo wrote::shock: *blink* …You're braver than I am. I started from the example module and… "borrowed" from the main module as necessary. :wink:
Yeah, not sure if it was the best way but now it will be harder to turn back, I think
Zizzo wrote:You might be able to bend mod.class.Party and related classes to your needs.
I've looked at it a few times but I've been managing without changing it to much

Zizzo wrote:You mean directly in the Game object? As in "game.advList = { dude1, dude2, … }"? That's likely your problem. Stuff like that traditionally lives in the GameState object. If you're bound and determined to put it in game, the engine.Game:defaultSavedFields() method controls which fields of game get saved to the savefile.
Yep, exactly like that. I have no real reason to do that, it just looked like the right place, so I can change it. You're saying that if I had "game.state.advList" the engine would be able to save it? I'm really trying not to change the engine itself
Zizzo wrote:Well, as you may know, the game.teag and zone-<zone-name>.teaz files are just renamed .zip files. In them, the file 'main' is basically Lua instructions for reassembling the relevant Game resp. Zone object; the other files are other contained objects with their own reassembly instructions. For instance, game.teag will probably contain a file 'mod.class.Player-0x<hex-digits>', describing game.player.
I knew they were zip files but I couldn't understand what each file was. I'll look at them again, thanks!

Re: New Module - Trouble saving game

Posted: Fri Aug 10, 2018 1:05 am
by Zizzo
Kemsha wrote:You're saying that if I had "game.state.advList" the engine would be able to save it?!
Yes, in my experience everything in game.state is saved to the savefile unless you specifically tell it otherwise.

Re: New Module - Trouble saving game

Posted: Mon Aug 20, 2018 9:41 am
by Kemsha
Zizzo wrote:Yes, in my experience everything in game.state is saved to the savefile unless you specifically tell it otherwise.
It worked! Many thanks!