Some questions from a beginner

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
cicatrix
Burner Inserter
Burner Inserter
Posts: 14
Joined: Mon Feb 27, 2017 9:43 am
Contact:

Some questions from a beginner

Post by cicatrix »

Hello, I'm currently trying to create my own mod and since I have zero experience in mod-making I want some things to get clear.

My mod is nothing special, all I want is to create a building that produces some stuff using several recipes. I read several tutorials and all of them went like:
1) create item.lua,
2) create entity.lua
3) write the stuff
4) Profit

Obviously, I'm interested in the part 3) :) Well, to specifics:

1) Am I right to assume that in entity.lua I declare a 'prototype' that will be used by the items defined in item.lua?
I want to extend 'assembling-machine' by giving it new type name and new graphics. Do I specify it in the entity.lua or in item.lua?
In-game machines will be tiered (MK1, MK2 and MK3, for example) can they all use the same prototype?

2) When I specify the type in entity.lua - am I right to give it new name, ie

Code: Select all

-- entity.lua
data:extend({
	{
	type = "assembling-machine",
	name = "newtypename",
	},
})
3) Where and how do I specify the graphics for my machine and in which format?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Some questions from a beginner

Post by DaveMcW »

1. File names don't matter, as long as it is included in data.lua you can put the code anywhere. It is nice to keep things organized by file though.

2. I recommend cloning an existing entity to get started. The only field you must edit is the name, everything else is optional.

Code: Select all

local machine = table.deepcopy(data.raw["assembling-machine"]["assembling-machine-2"])
machine.name = "new-assembling-machine-1"
data:extend{machine}
3. If you edit the existing assembling machine image and keep the same dimensions, you can put it in your mod folder and update the filename.

Code: Select all

local machine = table.deepcopy(data.raw["assembling-machine"]["assembling-machine-2"])
machine.name = "new-assembling-machine-1"
machine.animation.layers[1].filename = "__my-mod__/graphics/assembling-machine-2.png"
machine.animation.layers[1].hr_version.filename = "__my-mod__/graphics/hr-assembling-machine-2.png"
data:extend{machine}
To see all your graphics options look at https://wiki.factorio.com/Data.raw

cicatrix
Burner Inserter
Burner Inserter
Posts: 14
Joined: Mon Feb 27, 2017 9:43 am
Contact:

Re: Some questions from a beginner

Post by cicatrix »

And what if I want to use my own graphics, is there any guidelines?

Hiladdar
Fast Inserter
Fast Inserter
Posts: 214
Joined: Mon May 14, 2018 6:47 pm
Contact:

Re: Some questions from a beginner

Post by Hiladdar »

Then you will need to make the graphics / animations and include that as part of your deliverable.

Normally graphics will go in a folder called graphics, with separate folders for each entity. The icon graphics go into their own folder as do the technology graphics.

Although deepcopy is great, another technique is to go into the appropriate entity / item / recipe / technology file located in the ../data/ base/prototype folder, find the right file, and copy and paste the correct entity and then edit it. That technique is harder to maintain, but easier to code on the front end.

Specifically for graphics I recommend sticking to 32x32 bits for icons, 128x128 bit for technology, and also try to stick with 128x128 for entity, with high resolution being around 256x256 or so. One thing you will need to do is make sure your graphic file defined correctly in size and matches what the actual dimensions of the graphic file are.

One recommendation is to download a number of mods which deal things you are trying to write and look at what other mod developers have done. The mod files are distributed within a .zip file, which you can open up and take a look at.

FYI I like DaveMcW's recommendation of using deepcopy, and use of the assembly machine as an example, since that is a very easy to understand and example, with straight forward example of a graphic with animation.

Hiladdar

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Some questions from a beginner

Post by darkfrei »

cicatrix wrote:
Thu Feb 28, 2019 6:37 am
And what if I want to use my own graphics, is there any guidelines?
You are need to make new graphics or ask it here viewforum.php?f=15
You can make your own graphics for example with blender 3d. viewtopic.php?t=5336

Post Reply

Return to “Modding discussion”