Jump to content

Stream:WriteLine not working properly?


Phodex Games
 Share

Recommended Posts

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))

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...