Search the Community
Showing results for tags 'Data'.
-
Hello, Because I made myself some thoughts about a saving mechanic for my current project, I searched the web and especially the Leadwerks site for how to save simple game data, like the players health or position. The only kind of useful thing I found which works for LUA was this: http://www.leadwerks.com/werkspace/topic/2103-save-data-to-lua-syntax-as-textcompressed/page__hl__save+data and this: http://www.leadwerks.com/werkspace/topic/1853-howto-using-lua-script-as-data-file/ I actually was able to create a data file and read it into my code with "dofile". However I didnt find out how to create/save a file with lua yet. I searched the Leadwerks API and found the Stream and FileSystem Class. So I tried the following code: function Script:Start() local gamedata = FileSystem:WriteFile("Test.txt") end It didnt work, and I also dont know how it works. Where has the file been created? I searched my PC and the Projectsfolder but couldnt find such a file and I also dont get any kind of error message. I guess this is completely wrong, but I was just playing around, because I don't have that much experience with Lua and Leadwerks. The file you can download in the first thread I posted ("TStoreData.lua") doesnt work anymore and I cant find where he saves data. That you clearly undersand what I want. I would like to do something like this: function Script:Start() local gamedata = {} gamedata.playerHealth = 100 gamedata.playerWeapon = "Sword" gamedata.playerPos = Vec3(10, 100, 53) FileSystem:WriteFile("gamedata.lua", gamedata) end This is just some code that you know what I mean. I know this doesnt work xD. So could you please help me out a little bit . PS.: I kind of understood what AndyGFX wrote in his post, I just couldnt find anything how to save a file.