z3roram Posted December 15, 2017 Share Posted December 15, 2017 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, Quote Link to comment Share on other sites More sharing options...
Josh Posted December 15, 2017 Share Posted December 15, 2017 https://www.leadwerks.com/learn?page=API-Reference_Object_Widget Quote 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 More sharing options...
z3roram Posted December 29, 2017 Author Share Posted December 29, 2017 Thank you for pointing to the API reference, hoowever still not able to accomplish saving and loading feature. Anyone out there have more insight on this topic? Quote Link to comment Share on other sites More sharing options...
Josh Posted December 29, 2017 Share Posted December 29, 2017 This will vary with each game depending on what info your game needs to save. Quote 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 More sharing options...
Thirsty Panther Posted December 29, 2017 Share Posted December 29, 2017 Rick has a load/save game script in the workshop that may help. Quote Link to comment Share on other sites More sharing options...
Rick Posted December 30, 2017 Share Posted December 30, 2017 @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. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted December 31, 2017 Share Posted December 31, 2017 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. Quote 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 More sharing options...
Recommended Posts
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.