Is there any way I can get the directory of the save, with the onsave function or something?
I need to manage a list of entities placed by the player, I made the code, and it stores it in a table, until the game calls the onsave event, when this event is called, the code edits a txt file, but the directory of the txt file is... the desktop .-.
So I need to know the directory where the save is to be able to have more than one save at the same time.
onsave function, getting the directory?
Re: onsave function, getting the directory?
Code: Select all
-- function called before game is saved
game.onsave = function()
end
Code: Select all
-- function called after game was loaded
game.onload = function()
end
glob is special global variable and all of its contents are saved/loaded automatically.
So as long as you store your table this way:
Code: Select all
glob.mytable = {}
glob.mytable["hello] = 15
Re: onsave function, getting the directory?
So I can trash the code...
but anyways, is a much easier way of doing it
but anyways, is a much easier way of doing it
Re: onsave function, getting the directory?
Actually I have a similar problem.
And I cant confirm that it is solved by using glob.*
For example my treefarm-mod uses a glob.field {} to store the overall placed treefarm- entities. After restarting factorio and loading the savefile, the treefarms wont work anymore because the glob.field{} is empty ...
And I cant confirm that it is solved by using glob.*
For example my treefarm-mod uses a glob.field {} to store the overall placed treefarm- entities. After restarting factorio and loading the savefile, the treefarms wont work anymore because the glob.field{} is empty ...
Re: onsave function, getting the directory?
I just checked you freegame.luadrs9999 wrote:Actually I have a similar problem.
And I cant confirm that it is solved by using glob.*
For example my treefarm-mod uses a glob.field {} to store the overall placed treefarm- entities. After restarting factorio and loading the savefile, the treefarms wont work anymore because the glob.field{} is empty ...
Its empty because onload sets it to empty.
Code: Select all
...
game.onload = function()
glob.player = game.getplayer()
glob.field = {}
glob.fieldcount = 0
glob.tickCount = 0
end...
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela
Re: onsave function, getting the directory?
oh boy...
I had to insert this stuff into the onloadfunction because otherwise my game crashes.
But it turns out that I used a 0.2.10-build that was released before it 0.2.10 becomes the actual stable build.
Now everything works fine as far as I can see (if I delete the onload function).
How embarrassing....
Thank you very much, its the first time I am using LUA so I am not very familar with it and if you have more suggestions please post it into the specific thread, that will help me a lot.
I had to insert this stuff into the onloadfunction because otherwise my game crashes.
But it turns out that I used a 0.2.10-build that was released before it 0.2.10 becomes the actual stable build.
Now everything works fine as far as I can see (if I delete the onload function).
How embarrassing....
Thank you very much, its the first time I am using LUA so I am not very familar with it and if you have more suggestions please post it into the specific thread, that will help me a lot.