Page 1 of 1

How to revive ghosts from a blueprint

Posted: Sat Nov 21, 2020 10:45 pm
by Optymistyk
I want to modify a mod script that's placing a blueprint on a surface, so that instead of ghosts it would place real entities. I believe this is the part that's responsible for placing down the blueprint

Code: Select all

	local entitiesBuilt = blueprint.build_blueprint{
		surface=surface, force=entity.force, position=chunkMiddle, 
		force_build=true, skip_fog_of_war=false, direction=direction
	}
so I tried modifying it like this

Code: Select all

	local entitiesBuilt = blueprint.build_blueprint{
		surface=surface, force=entity.force, position=chunkMiddle, 
		force_build=true, skip_fog_of_war=false, direction=direction
	}
	for (k,v) in pairs(entitiesBuilt) do 
		if v~=nil then v.revive() end
	end
Doesn't work. I'm out of ideas at this point. The API documentation for Factorio also seems not very helpful, I have no idea how anyone could possibly find anything there. I was looking for the definition of build_blueprint for like an hour and couldn't find it, I have no clue which class I should be looking at. A search bar would do wonders

Re: How to revive ghosts from a blueprint

Posted: Sat Nov 21, 2020 11:01 pm
by Choumiko
Try removing the brackets around

Code: Select all

k,v
When i try it with brackets in the Factorio console i get an error. Seems like the mod you're editing does that function in a pcall and gives no information when an error occurs.

As for searching the API, if i don't know what a function belongs to i go to https://lua-api.factorio.com/latest/Classes.html and use the browser search.
https://lua-api.factorio.com/latest/Lua ... _blueprint

Re: How to revive ghosts from a blueprint

Posted: Sun Nov 22, 2020 11:28 am
by Optymistyk
Thank you, that tip on how to search the docs really helped and I was able to get it to work. Turns out the script expected these entities to still be ghosts down the line so I just changed that. And yeah the brackets were also a problem but they're there just cuz I was fiddling with the code and was like "I'm out of ideas,what if I put brackets there. Nope, still not working" and then I forgot to remove them before posting lol