Luaentityprototype doesnt contain key energy_source, even though it is filtered for craftingmachine

Place to get help with not working mods / modding interface.
Post Reply
hamgurmber
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Jan 28, 2023 5:27 pm
Contact:

Luaentityprototype doesnt contain key energy_source, even though it is filtered for craftingmachine

Post by hamgurmber »

Code: Select all

for _, entity in pairs(game.get_filtered_entity_prototypes({{filter = "crafting-machine"}})) do
	if entity.energy_source == "burner" and need_fuel(entity) == false then
		_fuel_list[entity.name] = _fuel
	end
	Kmachine[entity.name] = true
end
the above code causes the error "LuaEntityPrototype doesn't contain key energy_source" and i am not sure why

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2548
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Luaentityprototype doesnt contain key energy_source, even though it is filtered for craftingmachine

Post by FuryoftheStars »

Because LuaEntityPrototype, for any entity, does not have that key. Keys from prototypes in data stage do not always translate 1:1 to LuaEntityPrototype in control stage. Many aren't even available to read.

Search that page for "energy source" (note no underscore) and you'll get hits on what it has instead.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

hamgurmber
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Jan 28, 2023 5:27 pm
Contact:

Re: Luaentityprototype doesnt contain key energy_source, even though it is filtered for craftingmachine

Post by hamgurmber »

Yeah, but its filtered for crafting machine, which does have that key

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2548
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Luaentityprototype doesnt contain key energy_source, even though it is filtered for craftingmachine

Post by FuryoftheStars »

hamgurmber wrote:
Sat Jan 28, 2023 6:10 pm
Yeah, but its filtered for crafting machine, which does have that key
In data stage they do. Not in the control stage.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

Post Reply

Return to “Modding help”