I’m stuck trying to figure out a good method for saving the building progression in an action game I’m working on. Progression will be linear and work like this:
- Build a home
- Collect resources
- Build a market
- etc.
I’m using Defsave for saving/loading.
What I can’t quite figure out is how to have the player pick up where they left off. There are many buildings and levels of buildings to consider.
One idea is to have a table with all possible buildings. This table would have various values such as:
“name” = { active = false, level = 1 }
So if I were to use Defsave, it would look something like this:
defsave.set(“buildings”, “house” , { active = false, level = 1 })
While it works, I can see myself running into issues later when I have multiple houses and or other buildings that have been leveled up. I’m using collectionfactories to load the buildings, so I would have to figure out the logic for this during the init.
Something like this
function init(self)
if defsave.get("buildings", "house").active then
msg.post(".", "activate") -- turns 'on' the building
else
msg.post(".", "disable")
end
end
Another idea is to load ALL of the game objects for the level initially, but disable the ones that aren’t yet active. This could be better since once a game object is enabled through gameplay, I could save and set it as permanently active the next time the game loads. I could also break up the full game into multiple proxies depending on the progression.
For example, “Level 1” would consist of about 8 buildings. Once they’re completed, they move onto level 2 that has level 1’s buildings activated and several new buildings to activate. As I write this out, this makes the most sense.
Open to ideas. I know this type of thing in a game has been done many times in the past - but it’s the first time for me, so I’m not sure how to go about it.