Jump to content

Save Game Menu


z3roram
 Share

Recommended Posts

Hello,

I'll get straight to the point, looking to create UI that incorporates Save/Load functionality. I did see Piller's download for save load and saying it should be attached to Pivot, however wish to further extend that whole thing by creating custom UI with Save Load and options... Any advice on how to accomplish this?

Thank you, 

Link to comment
Share on other sites

  • 2 weeks later...

@z3roram

The idea with the script Thirsty pointed out that I created, a long time ago, is that in each of your entity scripts you would have a SaveData() function and LoadData(data) function. Inside each entity scripts SaveData() you return a lua table of what you want that entity to save and in the LoadData(data) that same table is passed in as the data parameter for you to use. So it's a generic way of loading and saving data for entities that have scripts because as Josh said each game varies on it's needs. So this is just a framework that is flexible enough for the needs of most all games in Leadwerks.

SaveData() and LoadData() can be called from the flowgraph as they are exposed to the flowgraph because they have the --in after their names. So you could have a trigger somewhere that fires an onEnter output from the flowgraph (for example) that hooks up to the SaveData() of this script to save the data.

Note that entities are identified by their name so each one you want to be saved should be unique.

Note that if an entity is dynamic (it's not found in the map but exists in the saved file) it's expected that when you saved the data you set a property of the lua table named Prefab to the string of where the prefab exists and this will dynamically load that prefab and then call it's scripts LoadData(data) for you to set it's position/rotation/whatever variable you want.

To use this add the SaveGame.lua script to a pivot in each scene so that you can call it's SaveData()/LoadData() functions whenever you want to.

  • Like 1
Link to comment
Share on other sites

One idea I have for version 5 is the ability to save the game state down to every variable in Lua. I don't know if this is feasible, but it would be awesome to just be able to save the entire state and then restore it from a file.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...