table not being populated
Posted: Tue Nov 14, 2023 11:52 am
Hi everyone, I have been working on a mod, as part of it I am trying to generate a table that contains only the entities that can be placed by a player and also be blueprinted, I have been running into issues of the game telling me that "minable" or "placeable_by" are not part of the LuaEntityPrototype, so I opted to check for a flag and only copy entities that do NOT have the flag "not_blueprintable" that seems to get me through the function but it is not actually copying any information and populating my table, Here is the code I am using, I am at a loss as to what is happening, so any advice would be most appreciated
I apologize if this is a noobie question, This is the second mod I have made for factorio, and the first one that has custom actions, the first one was just creating a new production chain. I am working on a fairly ambitious project and currently do not know Lua as well as I probably should, (i know python and java though), thanks for any input you can give me!
Code: Select all
-- Function to populate the placeableEntities table
local function populatePlaceableEntities()
for _, prototype in ipairs(game.entity_prototypes) do --I have tried pairs and ipairs here, ipairs seems to get through the function, but pairs errors out
-- Check if the entity is placeable and does not have the "not-blueprintable" flag
if not prototype.flags["not-blueprintable"] then
-- Create a copy of the entity with only necessary fields
local entityCopy = {
name = prototype.name,
selection_box = prototype.selection_box,
}
table.insert(placeableEntities, entityCopy) --This seems to be where pairs errors out at.
end
end
end