Hello,
I've just started out trying to make a Factorio mod and already beating my head against the wall
Im trying to create a new item, in data.lua I have:
local myItem = table.deepcopy(data.raw["item"]["iron-plate"])
myItem.name = "my-item"
local recipe = {
type = "recipe",
name = "my-item",
enabled = true,
energy_required = 1,
ingredients = {{"iron-plate", 100}},
result = "my-item"
}
data:extend{myItem, recipe}
This works fine as long as the thing in the copy field is an item like iron plate, but as soon as I try anything else like data.raw["container"]["wooden-chest"] or data.raw["transport-belt"]["transport-belt"], I get the error:
Failed to load mods: Error in assignID: item with name 'my-item' does not exist.
Source: my-item (recipe).
Does anyone know what I'm doing wrong?
First mod help
Re: First mod help
If you don't create the item "my-item", it won't exist. data.raw["transport-belt"]["transport-belt"] is an entity of type "transport-belt".Gridbug wrote: ↑Sat Mar 09, 2024 12:59 pmThis works fine as long as the thing in the copy field is an item like iron plate, but as soon as I try anything else like data.raw["container"]["wooden-chest"] or data.raw["transport-belt"]["transport-belt"], I get the error:
Failed to load mods: Error in assignID: item with name 'my-item' does not exist.
Source: my-item (recipe).
As the docs say:
items are things you have in inventories, entities are placed on the ground. You can't have a recipe that produces an entity.https://lua-api.factorio.com/latest/prototypes/TransportBeltPrototype.html wrote: Inherits from TransportBeltConnectablePrototype « EntityWithOwnerPrototype « EntityWithHealthPrototype « EntityPrototype « PrototypeBase
You could copy the item "transport-belt" from from data.raw["item"]["transport-belt"] if you want the icon and stack size etc similar to it.
Items and entities are connected with "place_result" (item in hand, place on ground) in the item prototype and with "minable" (what you get when you mine the entity) in the entity prototype. This isn't automatic and you aren't forced to have a 2-cycle of item->entity->same item again, you could get anything from mining the entity and place anything when building with the item. like item transport-belt placed -> builds assembler -> mined iron-plate -> iron plate when built places a laser turret etc. And I think you can get 3 steel plate and 5 rocket silo items when mining something as well...
Re: First mod help
That works! Thank you so much