creating car prototype

Place to get help with not working mods / modding interface.
Mathradi
Manual Inserter
Manual Inserter
Posts: 2
Joined: Tue Aug 25, 2020 5:00 pm
Contact:

creating car prototype

Post by Mathradi »

Hello! I'm trying to make a car that detonates in an explosion when it hits something. First step: create a new car prototype. I've tried duplicating the original car with this in data.lua:

Code: Select all

local myCar = util.table.deepcopy(data.raw["car"]["car"])
myCar.name = "my-car"
myCar.minable.result = "my-car"
data:extend({myCar})
But I get an error: 'error in assignID: item with name "my-car" doesn't exist.'

If I take out the minable result then it works. If I try to create a recipe for it then I get the same error there.

I feel like I must be missing something simple. What am I doing wrong?
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: creating car prototype

Post by DaveMcW »

Like the error message said, you need an ITEM. Not a RECIPE or ENTITY.

Code: Select all

local myItem = util.table.deepcopy(data.raw["item-with-entity-data"]["car"])
myItem.name = "my-car"
myItem.place_result = "my-car"
data:extend({myItem})
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: creating car prototype

Post by eradicator »

DaveMcW wrote: Tue Aug 25, 2020 5:31 pm Like the error message said, you need an ITEM. Not a RECIPE or ENTITY.
Actually @OP needs all three of those. The error says "you're telling me that your new car should give a my-car item when mined, but you didn't tell me what a my-car item is!".
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: creating car prototype

Post by darkfrei »

Don't forget to unlock the recipe.

Code: Select all

local recipe = table.deepcopy(data.raw.recipe.car)
recipe.name= "my-car"
recipe.result= "my-car"
recipe.enabled = true
data:extend({recipe})
or add it to the tech

Code: Select all

local recipe = table.deepcopy(data.raw.recipe.car)
recipe.name= "my-car"
recipe.result= "my-car"
data:extend({recipe})
table.insert (data.raw.technology.automobilism.effects, {type = "unlock-recipe", recipe = "my-car"})
Mathradi
Manual Inserter
Manual Inserter
Posts: 2
Joined: Tue Aug 25, 2020 5:00 pm
Contact:

Re: creating car prototype

Post by Mathradi »

Makes perfect sense. Thanks for the help!
Post Reply

Return to “Modding help”