Page 1 of 1

if data.raw

Posted: Sun Jan 19, 2014 10:30 pm
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

Re: if data.raw

Posted: Sun Jan 19, 2014 10:37 pm
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.

Re: if data.raw

Posted: Sun Jan 19, 2014 10:47 pm
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

Re: if data.raw

Posted: Sun Jan 19, 2014 10:49 pm
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

Re: if data.raw

Posted: Sun Jan 19, 2014 11:15 pm
by Dysoch
found it.

game.entityprototypes.quartz

is the correct call for it.
thx for your help ficolas