Page 1 of 1

creating car prototype

Posted: Tue Aug 25, 2020 5:12 pm
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?

Re: creating car prototype

Posted: Tue Aug 25, 2020 5:31 pm
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})

Re: creating car prototype

Posted: Tue Aug 25, 2020 5:50 pm
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!".

Re: creating car prototype

Posted: Tue Aug 25, 2020 7:43 pm
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"})

Re: creating car prototype

Posted: Tue Aug 25, 2020 8:01 pm
by Mathradi
Makes perfect sense. Thanks for the help!