Page 1 of 1
Luaentityprototype doesnt contain key energy_source, even though it is filtered for craftingmachine
Posted: Sat Jan 28, 2023 5:33 pm
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
Re: Luaentityprototype doesnt contain key energy_source, even though it is filtered for craftingmachine
Posted: Sat Jan 28, 2023 5:47 pm
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.
Re: Luaentityprototype doesnt contain key energy_source, even though it is filtered for craftingmachine
Posted: Sat Jan 28, 2023 6:10 pm
by hamgurmber
Yeah, but its filtered for crafting machine, which does have that key
Re: Luaentityprototype doesnt contain key energy_source, even though it is filtered for craftingmachine
Posted: Sat Jan 28, 2023 7:35 pm
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.