if data.raw

Place to get help with not working mods / modding interface.
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

if data.raw

Post by Dysoch »

how to get

Code: Select all

if data.raw.resource["quartz"] then
to work in the control.lua???

it works just fine in the data.lua, but in control.lua it gives an nil error. i was kinda hoping they had access to the same tables xD (apparently not)

i want it in my control.lua because i want to add compatibility between other mods and my Dynamic System.

the entire code for the compatibility:

Code: Select all

game.onevent(defines.events.onplayermineditem, function(event)
if data.raw.resource["quartz"] then --[[Industrio Compatibility]]--
	if ds.mineitemsindustrio[event.itemstack.name] then
		for counter, ingredients in pairs(ds.mineitemsindustrio[event.itemstack.name]) do 
			glob.counter[counter]=glob.counter[counter]+(event.itemstack.count*ingredients)
		end
	end
end
end)
and yes, i already tried with

Code: Select all

require "dataloader"
at the top of the control.lua. it didnt help
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: if data.raw

Post by ficolas »

* Added lua object for entity/item prototype. All prototypes can be aquired by game.(entity/item)prototypes.
So I think it is game.entity.resource.quartz.
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: if data.raw

Post by Dysoch »

ficolas wrote:
* Added lua object for entity/item prototype. All prototypes can be aquired by game.(entity/item)prototypes.
So I think it is game.entity.resource.quartz.
tried it every possible way, always errors and quits the game. (to main menu)

tried it with:
  • game.item.prototype.quartz
  • game.entity.resource.quartz
  • game.item.quartz
  • game.item.resource["quartz"]
  • and all that matches it closely xD
none did the trick
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: if data.raw

Post by ficolas »

Try in the console.
Is game.item nil?
Is game.entity nil?
If those are not nil, then do a for loop

for i,d in pairs(game.entity) do game.getplayer().print(i) end

Edit: maybe game.prototype...
You can also do the for loop in game but that would give lots of results.
Gonna check the wiki
edit: https://forums.factorio.com/wiki/inde ... prototypes
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: if data.raw

Post by Dysoch »

found it.

game.entityprototypes.quartz

is the correct call for it.
thx for your help ficolas
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
Post Reply

Return to “Modding help”