Page 1 of 1

Deleted Resource Help

Posted: Sat Oct 06, 2018 2:42 am
by hyspeed
Hi,

I have a mod (Factorio World) that spawns basic resources when a player is teleported to a location:

Code: Select all

surface.create_entity({name="crude-oil", amount=START_OIL_AMOUNT, position={oil_patch_x, oil_patch_y}})
(This is done in a script called from control.lua.)

However, I have learned that at least one mod deletes the resource "crude-oil", which causes my mod to fail.

Code: Select all

data.raw.resource["crude-oil"] = nil
(This is done in a script \prototypes\generation\ez-override.lua.)

I tried adding a simple check in my script:

Code: Select all

if data.raw.resource["crude-oil"] then
but this doesn't have access to 'data'. I am not sure of the scope of the data object, so I don't know where to put code that will perform the needed check.

Perhaps I am missing something obvious.
Any suggestions?

thanks,
jon

Re: Deleted Resource Help

Posted: Sat Oct 06, 2018 2:57 am
by DaveMcW
data.raw does not exist in control.lua. There a bunch of game.* tables you can use instead. https://lua-api.factorio.com/latest/Lua ... prototypes

Code: Select all

if game.entity_prototypes["crude-oil"] then

Re: Deleted Resource Help

Posted: Sat Oct 06, 2018 4:01 am
by hyspeed
Thank you.

(I would love to be smart enough to figure that out by reading the API docs.) :)

jon

Re: Deleted Resource Help

Posted: Sat Oct 06, 2018 8:43 am
by eradicator
Just out of curiosity, which idiot (mod) is running around deleting base prototypes like that instead of removing the autoplace?

Re: Deleted Resource Help

Posted: Sat Oct 06, 2018 9:19 am
by darkfrei
eradicator wrote:
Sat Oct 06, 2018 8:43 am
Just out of curiosity, which idiot (mod) is running around deleting base prototypes like that instead of removing the autoplace?
It looks like we are need another correction mod, where will be checked all vanilla prototypes and add placeholder if they are missing.

Re: Deleted Resource Help

Posted: Sat Oct 06, 2018 10:56 pm
by hyspeed
eradicator wrote:
Sat Oct 06, 2018 8:43 am
Just out of curiosity, which idiot (mod) is running around deleting base prototypes like that instead of removing the autoplace?
Omnimatter. And it removes the autoplace too:

Code: Select all

	data.raw.resource["crude-oil"] = nil
	data.raw["autoplace-control"]["crude-oil"] = nil
	data.raw.resource["iron"] = nil
	data.raw["autoplace-control"]["iron"] = nil
	data.raw.resource["copper"] = nil
	data.raw["autoplace-control"]["copper"] = nil
	data.raw.resource["coal"] = nil
	data.raw["autoplace-control"]["coal"] = nil

Re: Deleted Resource Help

Posted: Sun Oct 07, 2018 8:32 am
by eradicator
@hyspeed: Thanks. Let's see if the author cares to be a good guy.