Deleted Resource Help

Place to get help with not working mods / modding interface.
Post Reply
hyspeed
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Sun Jun 05, 2016 10:18 pm
Contact:

Deleted Resource Help

Post 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

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3699
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Deleted Resource Help

Post 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

hyspeed
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Sun Jun 05, 2016 10:18 pm
Contact:

Re: Deleted Resource Help

Post by hyspeed »

Thank you.

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

jon

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Deleted Resource Help

Post by eradicator »

Just out of curiosity, which idiot (mod) is running around deleting base prototypes like that instead of removing the autoplace?
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Deleted Resource Help

Post 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.

hyspeed
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Sun Jun 05, 2016 10:18 pm
Contact:

Re: Deleted Resource Help

Post 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

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Deleted Resource Help

Post by eradicator »

@hyspeed: Thanks. Let's see if the author cares to be a good guy.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding help”