How can i add new items?

Place to get help with not working mods / modding interface.
Jani25051
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sat Aug 03, 2013 11:15 pm
Contact:

How can i add new items?

Post by Jani25051 »

Hello Factorio players (:

I try to make a mod and the first item i want to add is a pulverizor.
It should work with electric and should use the gui from the normal stone-furnace.
I made the entity,the icon and some lua scripts but something went wrong.
I did read https://forums.factorio.com/forum/vie ... f=34&t=709 but i did not understand all because i´am from germany and read english is a little bit hard for me^^
And i looked into the treefarm mod to see how it works but that helped me only to understand the control.lua and some other things.

The mod is shown in the mod menu and it is active but i can´t see my item in the world editor.
I think i did everything very false but i can´t find my mistake.
And im a beginner in scripting lua. But i have experience in programming(AutoIt,C,Blitzbasic,Html)

Can you please help me?
I upload my mod folder here.

Iam very happy about every helpful answer (:
And please don´t ask me about the pictures :D Iam not good at drawing^^
Attachments
MoreItems.rar
(42.82 KiB) Downloaded 456 times
Last edited by Jani25051 on Sun Aug 04, 2013 12:06 pm, edited 2 times in total.

User avatar
zer0t3ch
Fast Inserter
Fast Inserter
Posts: 118
Joined: Fri Jul 26, 2013 6:06 am
Contact:

Re: How can i add new items?

Post by zer0t3ch »

Jani25051 wrote: I did read https://forums.factorio.com/forum/vie ... f=34&t=709 but i did not understand all because i´am from germany and read english is a little bit hard for me^^
And i looked into the treefarm mod to see how it works but that helped me only to understand the control.lua and some other things.
Are you using the Factorio version that matches the tutorial you were following? (v0.3/0.4 I think?) Or at least the Factorio version that matches the version of TreeFarm mod you were looking at?

**EDIT
Just looked at the RAR, and your folder structure looks wrong. Look at treefarm mod for reference.
"F**k thy hater"
-George Watsky

Feel free to contact me!
Skype: Zer0t3ch
Razer Comms: Zer0t3ch
Email: zer0t3ch@live.com

Image

Jani25051
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sat Aug 03, 2013 11:15 pm
Contact:

Re: How can i add new items?

Post by Jani25051 »

zer0t3ch wrote:
Are you using the Factorio version that matches the tutorial you were following? (v0.3/0.4 I think?) Or at least the Factorio version that matches the version of TreeFarm mod you were looking at?

**EDIT
Just looked at the RAR, and your folder structure looks wrong. Look at treefarm mod for reference.
I use Factorio version 0.5.3.
I can´t find a tutorial for modding in 0.5.3 so i used that tutorial with version 0.4...

I changed the Treefarm version to 0.5.3 to play it and it works fine (:

Thanks for your answer i change the folder structure like it is in the treefarm mod.

Edit://
I´ve changed the file structure and changed it in the .lua files too but the item is not in the game..
Is my "MoreItems\graphics\entity\MoreItems-Mod\electric-pulverizor.png" right?
I saw that in the "15Cyndaquil's electric furnace mod"..

ps.I´ve uploaded the new test mod files in my first comment.

User avatar
zer0t3ch
Fast Inserter
Fast Inserter
Posts: 118
Joined: Fri Jul 26, 2013 6:06 am
Contact:

Re: How can i add new items?

Post by zer0t3ch »

Jani25051 wrote:
zer0t3ch wrote:
Are you using the Factorio version that matches the tutorial you were following? (v0.3/0.4 I think?) Or at least the Factorio version that matches the version of TreeFarm mod you were looking at?

**EDIT
Just looked at the RAR, and your folder structure looks wrong. Look at treefarm mod for reference.
I use Factorio version 0.5.3.
I can´t find a tutorial for modding in 0.5.3 so i used that tutorial with version 0.4...

I changed the Treefarm version to 0.5.3 to play it and it works fine (:

Thanks for your answer i change the folder structure like it is in the treefarm mod.

Edit://
I´ve changed the file structure and changed it in the .lua files too but the item is not in the game..
Is my "MoreItems\graphics\entity\MoreItems-Mod\electric-pulverizor.png" right?
I saw that in the "15Cyndaquil's electric furnace mod"..

ps.I´ve uploaded the new test mod files in my first comment.
I see your problem, and I bet you can fix it in just a few seconds.

You need to have a data.lua in the root of your MoreItems folder that loads in all of the other files, because otherwise the game doesn't know what to load. For your folder structure, putting this into a data.lua should do the trick: (and make everything work, provided your code is good)

Code: Select all

require("prototypes.entity.moreitems-mod")
require("prototypes.item.moreitems-mod")
require("prototypes.recipe.moreitems-mod")
require("prototypes.recipe-category.moreitems-mod")
"F**k thy hater"
-George Watsky

Feel free to contact me!
Skype: Zer0t3ch
Razer Comms: Zer0t3ch
Email: zer0t3ch@live.com

Image

Jani25051
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sat Aug 03, 2013 11:15 pm
Contact:

Re: How can i add new items?

Post by Jani25051 »

zer0t3ch wrote:
Jani25051 wrote:
zer0t3ch wrote:
Are you using the Factorio version that matches the tutorial you were following? (v0.3/0.4 I think?) Or at least the Factorio version that matches the version of TreeFarm mod you were looking at?

**EDIT
Just looked at the RAR, and your folder structure looks wrong. Look at treefarm mod for reference.
I use Factorio version 0.5.3.
I can´t find a tutorial for modding in 0.5.3 so i used that tutorial with version 0.4...

I changed the Treefarm version to 0.5.3 to play it and it works fine (:

Thanks for your answer i change the folder structure like it is in the treefarm mod.

Edit://
I´ve changed the file structure and changed it in the .lua files too but the item is not in the game..
Is my "MoreItems\graphics\entity\MoreItems-Mod\electric-pulverizor.png" right?
I saw that in the "15Cyndaquil's electric furnace mod"..

ps.I´ve uploaded the new test mod files in my first comment.
I see your problem, and I bet you can fix it in just a few seconds.

You need to have a data.lua in the root of your MoreItems folder that loads in all of the other files, because otherwise the game doesn't know what to load. For your folder structure, putting this into a data.lua should do the trick: (and make everything work, provided your code is good)

Code: Select all

require("prototypes.entity.moreitems-mod")
require("prototypes.item.moreitems-mod")
require("prototypes.recipe.moreitems-mod")
require("prototypes.recipe-category.moreitems-mod")
Hey thanks. (:
This helped me to understand thr data.lua file but the problem is the same.
I think i did anything in the .lua files wrong. Maybe a { or so on...
I´ve changed my lua files like it is in the treefarm mod but this doesn´t help me.
I upload my new files in the first comment.

I know anyone here knows what my problem is. Please help me O:

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: How can i add new items?

Post by drs9999 »

Nice to see a new modder here.
For newbies I highly recommend to look into the data/base folder.
It is the perfect place to see how things can/have to be done and to become familiar with the data structure.

I had just a quick view, but there are several bugs in your files. E.g missing data:extend, wrong entity type, ...

P.S. I am not sure if this is still valid, but I believe that the modfolder name have to be the same than the mod-name in the info.json

Jani25051
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sat Aug 03, 2013 11:15 pm
Contact:

Re: How can i add new items?

Post by Jani25051 »

drs9999 wrote:Nice to see a new modder here.
For newbies I highly recommend to look into the data/base folder.
It is the perfect place to see how things can/have to be done and to become familiar with the data structure.

I had just a quick view, but there are several bugs in your files. E.g missing data:extend, wrong entity type, ...

P.S. I am not sure if this is still valid, but I believe that the modfolder name have to be the same than the mod-name in the info.json
Thanks for your tip with the data/base folder.
I will now look into it and i hope that i can fix the bugs.
And i will change the info.json (:

Edit://
I´ve made it and now i got errors if i start the game but i think i can fix them.
But the problem isn´t solved ):

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: How can i add new items?

Post by drs9999 »

As an example the *.lua file in the entity folder should look like this:

Code: Select all

data:extend(
{
	{
		type = "assembling-machine",
		name = "electric-pulverizor",
    	icon = "__Moreitems__/graphics/icons/electric-pulverizor.png",
		flags = {"placeable-neutral","player-creation"},
    	minable = {hardness = 0.2, mining_time = 0.5, result = "electric-pulverizor"},
		max_health = 100,
		collision_box =  {{-1.4, -1.4}, {1.4, 1.4}},
		selection_box = {{-1.5, -1.5}, {1.5, 1.5}},
		animation =
		{
			filename = "__MoreItems__/graphics/entity/MoreItems-Mod/electric-pulverizor.png",
			priority = "medium",
			frame_width = 132,
			frame_height = 116,
			frame_count = 32,
			line_length = 7,
			shift = {0.0, 0.0}
		},
		crafting_categories = {"pulverizing"},
		effectivity = 20,
		energy_source =
		{
			type = "electric",
			input_priority = "secondary"
		},
		energy_usage_per_tick = 0.5,
		ingredient_count = 1
	}

}
)

Jani25051
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sat Aug 03, 2013 11:15 pm
Contact:

Re: How can i add new items?

Post by Jani25051 »

drs9999 wrote:As an example the *.lua file in the entity folder should look like this:

Code: Select all

data:extend(
{
	{
		type = "assembling-machine",
		name = "electric-pulverizor",
    	icon = "__Moreitems__/graphics/icons/electric-pulverizor.png",
		flags = {"placeable-neutral","player-creation"},
    	minable = {hardness = 0.2, mining_time = 0.5, result = "electric-pulverizor"},
		max_health = 100,
		collision_box =  {{-1.4, -1.4}, {1.4, 1.4}},
		selection_box = {{-1.5, -1.5}, {1.5, 1.5}},
		animation =
		{
			filename = "__MoreItems__/graphics/entity/MoreItems-Mod/electric-pulverizor.png",
			priority = "medium",
			frame_width = 132,
			frame_height = 116,
			frame_count = 32,
			line_length = 7,
			shift = {0.0, 0.0}
		},
		crafting_categories = {"pulverizing"},
		effectivity = 20,
		energy_source =
		{
			type = "electric",
			input_priority = "secondary"
		},
		energy_usage_per_tick = 0.5,
		ingredient_count = 1
	}

}
)
Woah thanks for that! :D
That helped me very very good :D

But i have problems with the other .lua files..
All i can find in the base mod is hard to understand for me.
And if i copy that and change the path´s and other things, it doesn´t work..

I think i can learn from it if i have my first item ingame (:

Here are the not working lua files:

item.lua

Code: Select all

data:extend(
{
  {
    type = "item",
    name = "electric-pulverizor",
	icon = "__MoreItems__\graphics\icons\electric-pulverizor.png",
    flags = {"goes-to-quickbar"},
    group = "production",
    order = "h-b-a",
    place-result = "electric-pulverizor",
    stack-size = 64,
  }
}
)
And if i start the game it shows me that:

Code: Select all

Content Title

Cannot load lua script C:/Users\Jan\AppData\Roaming\Factorio\mods\MoreItems\data.lua. Error: error loading module 'prototypes.item.item' from file 'C:/Users\Jan\AppData\Roaming\Factorio\mods\MoreItems\prototypes\item\item.lua':
	...Roaming\Factorio\mods\MoreItems\prototypes\item\item.lua:6: invalid escape sequence near '\g'
But i don´t know what that means. If i turn that file off in the data.lua then it shows me a other error with the next .lua file.

recipe.lua

Code: Select all

data:extend(
{
  {
    type = "recipe",
    name = "electric-pulverizor",
    enabled = "true",
    ingredients = {
	{"stone-furnace",1},
	{"iron-plate",10},
	{ "iron-gear-wheel",10},
	{"electronic-circuit",4},
	},
	result = "electric-pulverizor"
  },
}
)
Please help me :(

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: How can i add new items?

Post by drs9999 »

Actually I think that the following is counterproductive in terms of learning how to mod, but you are lucky that I have to learn for exams, but do not want to ;)

So here is a working example:
MoreItems.zip
(45.63 KiB) Downloaded 278 times

Jani25051
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sat Aug 03, 2013 11:15 pm
Contact:

Re: How can i add new items?

Post by Jani25051 »

drs9999 wrote:Actually I think that the following is counterproductive in terms of learning how to mod, but you are lucky that I have to learn for exams, but do not want to ;)

So here is a working example:
MoreItems.zip
Thanks, Thanks, Thanks :D
And now i try the rest by myself (:

Post Reply

Return to “Modding help”