Code Cleanup: Remove use of '_dict' for items due to Quality

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Barontox
Manual Inserter
Manual Inserter
Posts: 1
Joined: Sun Jun 29, 2025 5:07 pm
Contact:

Code Cleanup: Remove use of '_dict' for items due to Quality

Post by Barontox »

I am trying to create some mods for game startup on Freeplay.
There is an annoying requirement for item_dict in the insert and remove utilities.

remove dict so i can add or delete items based on quality.

for example:


util.insert_safe = function(entity, item_dict)
if not (entity and entity.valid and item_dict) then return end
local items = prototypes.item
local insert = entity.insert
for name, count in pairs (item_dict) do
if items[name] then
insert{name = name, count = count}
else
log("Item to insert not valid: "..name)
end
end
end

util.remove_safe = function(entity, item_dict)
if not (entity and entity.valid and item_dict) then return end
local items = prototypes.item
local remove = entity.remove_item
for name, count in pairs (item_dict) do
if items[name] then
remove{name = name, count = count}
else
log("Item to remove not valid: "..name)
end
end
end



Both of these functions remove quality as an attribute of the item.
Post Reply

Return to “Modding interface requests”