Search the Community
Showing results for tags 'Stream'.
Found 2 results
Hi there, I have a problem, maybe you guys can help me. I will make it quick. Following is what I have (just an example): function Script:Start() FileSystem:CreateFile("Data/Save Data/someData.lua") self.stream = FileSystem:WriteFile("Data/Save Data/someData.lua") end function Script:UpdateWorld() --I created this to find the error and to test it out if window:KeyHit(Key.K) then self.stream:WriteLine("Some text goes here") System:Print("It should work!") end end So I get printed "It should work!" AND the file gets created, but I can click "K" as often as I want, the text which should be written does not show up in the file. I need this to save data for my game. Whats the mistake. I noticed, that sometimes it gets written, after I close the application, but sometimes is has also been written while "ingame", but mostly it doesnt, especially with the scenario you can see above. Anyways this stream:WriteLine() seams to behave very akward. Further then solving my problem, what are your solutions for saving massive, or not so massive data (object positions, player position, npc states etc)? Thanks for your answers! EDIT: Just checked the data file again, and now the data is written a hundred times??? But I triple check if it gets written after I pressed "K". The problem is I need the file to be written immediately, because I grab the file again with dofile (I normally write code into the file that gets called (a simple "return" and some data))
Hi Leadwerks fellows, I run into some trouble creating an save system. I noticed that when I saved I couldnt immediatly reload my save, to load it I had to restart the "game". I will make it simple. To exclude other errors, I wrote this short line of code: if window:KeyHit(Key.F1) then self.test = FileSystem:WriteFile("test.lua") self.test:WriteLine("Test") System:Print("executing") end And again I noticed that while I am executing the programm and hit F1 (put a print function there to double check) and alt+tab the game and check the file, its empty. I use notepad++ to watch the file, and if I hit F1 it detectes a change and after reloading the file still nothing. Even if I close the application now, still empty. I need to close the whole file and open it again then I can see the text, but its not only a matter of visibility, I also tried to read the written text after saving it in the same session, doesnt work. So I guess the stream:WriteLine() operation gets executed on exit? Is there any way of how to work around this or am I missing something. Maybe its possible to refresh the scene/word/app etc? I dont know, but I remember loading and saving in the same session was possible once... However I would be very glad if someone would help me out P.S.: Lua sandbox is DISABLED!