Page 1 of 1
Recovering my character ?
Posted: Sat Mar 05, 2016 2:59 am
by binbinhfr
As I'm playing with mod and god mode, I sometimes have problem to switch back to human. In general, I record my player.character into a variable before going into god, but, for example, if I forgot to go back into human before saving, I save in god mode, and when I came back later, reloading the file, I lost my character variable...
So my question : is there a way to retrieve a character connected to a player and probably stored in the map file ?
EDIT : I suppose that I should look for an entity named "player". But I wonder in multiplayer, what would be the name of these character entities... And I don't know how to browse entities...

Re: Recovering my character ?
Posted: Sat Mar 05, 2016 5:07 pm
by binbinhfr
Well, after a few headaches, I found that this should do the trick in single player mode :
Code: Select all
function find_lost_character()
surf = game.get_surface(1)
for ch in surf.get_chunks() do
a = {{ch.x * 32, ch.y * 32}, {ch.x * 32 + 32, ch.y * 32 + 32}}
for k, entity in pairs(surf.find_entities_filtered({area=a, name= "player"})) do
return entity
end
end
end
But I wonder what name to search in multiplayer mode... But is there a god mode in multiplayer ?
Re: Recovering my character ?
Posted: Sat Mar 05, 2016 5:41 pm
by Choumiko
binbinhfr wrote:So my question : is there a way to retrieve a character connected to a player and probably stored in the map file ?
You are looking for global :
https://wiki.factorio.com/index.php?tit ... _Lifecycle
everything you add to global is stored in the save file, each mod has it's own global. I suggest indexing the table by player_index
Re: Recovering my character ?
Posted: Mon Aug 14, 2017 10:32 am
by Rotn240
binbinhfr wrote:Well, after a few headaches, I found that this should do the trick in single player mode :
Code: Select all
function find_lost_character()
surf = game.get_surface(1)
for ch in surf.get_chunks() do
a = {{ch.x * 32, ch.y * 32}, {ch.x * 32 + 32, ch.y * 32 + 32}}
for k, entity in pairs(surf.find_entities_filtered({area=a, name= "player"})) do
return entity
end
end
end
But I wonder what name to search in multiplayer mode... But is there a god mode in multiplayer ?
Hello i wunder how i can use this code? do i use it ingame or what? i could not find any infoation about how to use this on google so i trying to contact you insteed then
Yes i know the post is old but if i could get a answer it's worth it in my opinion