Is there a way to add attributes to items?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
bigyihsuan
Filter Inserter
Filter Inserter
Posts: 299
Joined: Thu Jan 01, 2015 12:57 pm
Contact:

Is there a way to add attributes to items?

Post 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"
	}
}
)

keyboardhack
Filter Inserter
Filter Inserter
Posts: 478
Joined: Sat Aug 23, 2014 11:43 pm
Contact:

Re: Is there a way to add attributes to items?

Post 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
Last edited by keyboardhack on Sun Aug 16, 2015 6:07 am, edited 1 time in total.
Waste of bytes : P

Rahjital
Filter Inserter
Filter Inserter
Posts: 435
Joined: Thu May 29, 2014 10:44 am
Contact:

Re: Is there a way to add attributes to items?

Post 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.

User avatar
bigyihsuan
Filter Inserter
Filter Inserter
Posts: 299
Joined: Thu Jan 01, 2015 12:57 pm
Contact:

Re: Is there a way to add attributes to items?

Post 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.

User avatar
cpy
Filter Inserter
Filter Inserter
Posts: 839
Joined: Thu Jul 31, 2014 5:34 am
Contact:

Re: Is there a way to add attributes to items?

Post 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.

Rahjital
Filter Inserter
Filter Inserter
Posts: 435
Joined: Thu May 29, 2014 10:44 am
Contact:

Re: Is there a way to add attributes to items?

Post 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:
Attachments
RocketFuelMod_0.0.1.zip
(603 Bytes) Downloaded 92 times

Post Reply

Return to “Modding help”