Page 1 of 1
Is there a way to add attributes to items?
Posted: Sat Aug 15, 2015 1:32 am
by bigyihsuan
I'm working on making rocket fuel as a burnable fuel, worth 10x solid fuel, but I can't seem to be able to mod it in.
Code: Select all
--in rocket-fuel.lua
data:extend(
{
{
type = "item",
name = "rocket-fuel",
fuel_value = "250MJ"
}
}
)
Re: Is there a way to add attributes to items?
Posted: Sat Aug 15, 2015 1:50 am
by keyboardhack
This is the code for solid-fuel
Code: Select all
{
type = "item",
name = "solid-fuel",
icon = "__base__/graphics/icons/solid-fuel.png",
flags = {"goes-to-main-inventory"},
fuel_value = "25MJ",
subgroup = "raw-resource",
order = "c[solid-fuel]",
stack_size = 50
}
By using this as a template we can easily make rocket fuel by changing a few things.
Code: Select all
{
type = "item",
name = "rocket-fuel",
icon = "__YouMod__/path/to/icon.png", --change this to a path to your icon for the item.
flags = {"goes-to-main-inventory"},
fuel_value = "250MJ",
subgroup = "intermediate-product",
order = "c[solid-fuel]",
stack_size = 50
}
And that's it. you can find the code for all items, entities and much more in /factorio/data/base/prototypes
Re: Is there a way to add attributes to items?
Posted: Sat Aug 15, 2015 1:23 pm
by Rahjital
Or you can do this:
Code: Select all
data.raw.item["rocket-fuel"].fuel_value = "250MJ"
More elegant and doesn't overwrite any other properties of rocket fuel, ie it's more compatible with other mods.
Re: Is there a way to add attributes to items?
Posted: Sat Aug 15, 2015 7:29 pm
by bigyihsuan
Rahjital wrote:Or you can do this:
Code: Select all
data.raw.item["rocket-fuel"].fuel_value = "250MJ"
More elegant and doesn't overwrite any other properties of rocket fuel, ie it's more compatible with other mods.
I just tried this, and it doesn't seem to work.
Re: Is there a way to add attributes to items?
Posted: Sun Aug 16, 2015 5:57 am
by cpy
Code: Select all
table.insert(data.raw.item["rocket-fuel"],{fuel_value = "250MJ",})
It does not seem to work but it probably would look something like that.
Re: Is there a way to add attributes to items?
Posted: Sun Aug 16, 2015 10:13 pm
by Rahjital
bigyihsuan wrote:I just tried this, and it doesn't seem to work.
Then you've done something wrong because it worked perfectly fine for me.
You know what, here you go, I've made the mod for you: