How to revive ghosts from a blueprint

Place to get help with not working mods / modding interface.
Post Reply
Optymistyk
Long Handed Inserter
Long Handed Inserter
Posts: 52
Joined: Sun Jun 14, 2020 9:41 pm
Contact:

How to revive ghosts from a blueprint

Post 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

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: How to revive ghosts from a blueprint

Post 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

Optymistyk
Long Handed Inserter
Long Handed Inserter
Posts: 52
Joined: Sun Jun 14, 2020 9:41 pm
Contact:

Re: How to revive ghosts from a blueprint

Post 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

Post Reply

Return to “Modding help”