Home Game Development How so as to add a save/load sport perform to a Lua/C++ sport engine

How so as to add a save/load sport perform to a Lua/C++ sport engine

0
How so as to add a save/load sport perform to a Lua/C++ sport engine

[ad_1]

I’m curious what one of the best method can be to avoid wasting the present state of my sport.
The lua scripts include the gamestate, but additionally some gameplay associated data that does not should be saved as a part of a savegame.

Should I break up my lua scripts right into a ‘saveable state’ half and pure gameplay stuff like dialogs?

What would you suggest for a retailer/restore mechanic? I might serialize the data to JSON and simply retailer it as a textfile, and on load set all of the values within the lua state I suppose?

A different may very well be to have C++ load all related data from the Lua state, and retailer it in some format..however that appears extra work than simply serializing some lua tables.

As an instance, right here is one object inside a stage that comprises each gameplay logic (onOpen) and state data (opened):

cranium = {
            opened = false,
            rect = { 64, 29, 14, 16 },
            sprite = "entrance_door_skull",
            dialogs = {
                look = "It's the cranium of some creature. Its that means appears fairly clear: dying lurks inside.",
            },
            onOpen = perform(self, scene)
                if not self.opened then
                    addMove("cranium", 1000, 0, -12, perform ()
                        SceneGameEntrance.motionItems.skullKey.isVisible = true
                    finish)
                    addDialog("As if by magic, the cranium rises.")
                    self.opened = true
                else
                    addDialog("It is already open.")
                finish
            finish
        }

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here