Modding without changing base files?

Place to get help with not working mods / modding interface.
caiophox
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Apr 09, 2016 9:36 pm
Contact:

Modding without changing base files?

Post by caiophox »

Had my first try at modding, and after 5 hours I finally got a wooden transport belt. The problem is the default files that are used. I can't make a 'modded' version of the 'transport-belt-pictures.lua', I keep getting an error about an unknown symbol on the code next to '='. When I changed that file on the base folder, everything worked. I just copied the code for fast transport belts and changed it to wood. I want to keep going into a more complex mod, but I feel that messing up with base files is not very healthy. Any tips, advice, suggestions?
Just to be clear, without changing the base files I either get an error or I lose the custom textures for the horizontal and vertical belts.
caiophox
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Apr 09, 2016 9:36 pm
Contact:

Re: Modding without changing base files?

Post by caiophox »

I had a clean install to organize my folders. Downloaded through steam, now nothing works -.- Says it's not recognizing the .png
IhanaMies
Inserter
Inserter
Posts: 36
Joined: Thu Mar 17, 2016 10:01 pm
Contact:

Re: Modding without changing base files?

Post by IhanaMies »

can you send me your mod so i can check the code out?
caiophox
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Apr 09, 2016 9:36 pm
Contact:

Re: Modding without changing base files?

Post by caiophox »

I uploaded to my drive> Wooden Transport Belt 0.1.0
IhanaMies
Inserter
Inserter
Posts: 36
Joined: Thu Mar 17, 2016 10:01 pm
Contact:

Re: Modding without changing base files?

Post by IhanaMies »

in entity.lua you should add
require ("prototypes.entity.wooden-transport-belt-pictures")
copy demo-transporter-belt-pictures to your mods prototype folder and rename it accordingly

inside it change every part of a line of __base__ into __wooden-transport-belt__/.../wooden-transport-belt.png (the __MODNAME__ part is a reference to mods name which you specify in info.json file)
------
and change

Code: Select all

icon = "__wooden-transport-belt_0.1.0__...",
(same in item.lua)

-->

Code: Select all

icon = "__wooden-transport-belt__...",
-------

Code: Select all

    animations =
    {
      filename = "__mods__/graphics/entity/wooden-transport-belt.png",
-->

Code: Select all

    animations =
    {
      filename = "__wooden-transport-belt__/graphics/entity/wooden-transport-belt.png",
-->

Code: Select all

    belt_horizontal = wooden_belt_horizontal,
    belt_vertical = wooden_belt_vertical,
    ending_top = wooden_belt_ending_top,
    ending_bottom = wooden_belt_ending_bottom,
    ending_side = wooden_belt_ending_side,
    starting_top = wooden_belt_starting_top,
    starting_bottom = wooden_belt_starting_bottom,
    starting_side = wooden_belt_starting_side,
(references to functions in wooden-transport-belt-pictures.lua)
-------
in wooden-transport-belt-pictures.lua you need to name the functions name like above basic_belt_horizontal --> wooden_belt_horizontal etc.


I attached fixed mod, but you should do the changes yourself to get a better hang of how modding works if you want to add/change more stuff. Feel free to ask any questions

Edit: Factorio mods has to be compressed in zip format. Compression into rar then renaming the extension to zip doesn't work
Attachments
wooden-transport-belt_0.1.0.zip
(144.17 KiB) Downloaded 146 times
caiophox
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Apr 09, 2016 9:36 pm
Contact:

Re: Modding without changing base files?

Post by caiophox »

First of all, thank you so much!
Seems like most of my problem was about the path names. Now I know about the hierarchy.
Also, I was in the right track about adding the .lua file to the mod folder (tried that a few times) and 'require' it, but I was doing it wrong :P

Now my problem is, since I want to change the game learning curve, how do I go about changing the existing belts, instead of creating a new one?
Should I create copies of them and make it switch them to mine, or can I just alter the properties of the 'base' belts from my mod folder, like an entity.lua?
Quantumtroll
Burner Inserter
Burner Inserter
Posts: 11
Joined: Mon Apr 11, 2016 12:10 pm
Contact:

Re: Modding without changing base files?

Post by Quantumtroll »

caiophox wrote:First of all, thank you so much!
Seems like most of my problem was about the path names. Now I know about the hierarchy.
Also, I was in the right track about adding the .lua file to the mod folder (tried that a few times) and 'require' it, but I was doing it wrong :P

Now my problem is, since I want to change the game learning curve, how do I go about changing the existing belts, instead of creating a new one?
Should I create copies of them and make it switch them to mine, or can I just alter the properties of the 'base' belts from my mod folder, like an entity.lua?
NB: I've only just started out, so don't take my word as gospel.

You can overwrite default behaviour by altering the values stored in data.raw.whatever.you.want.to.change. Download some mods and take a look at how they do it, you can learn lots (and probably even borrow some code!).

For instance, as one way of quickening the pace of the game I'm rebuilding the tech tree so it's shorter. Since so much of it needs to be revamped I'm tearing it out completely with the line data.raw.technology = {} before adding the techs I want back in. The items that now don't have a tech to unlock them will be unlocked with a bunch of

Code: Select all

data.raw.recipe["thing"].enabled="true"
.
IhanaMies
Inserter
Inserter
Posts: 36
Joined: Thu Mar 17, 2016 10:01 pm
Contact:

Re: Modding without changing base files?

Post by IhanaMies »

You can change existing entities with the form

Code: Select all

data.raw[transport-belt][basic-transport-belt].speed = 0.015
where the first bracket is the entity type (assembling-machine, cant remember what furnaces are called since im on phone, will explain better when i get on to computer) and the second one is the name of the entity.

The dot defines what attribute to change, like in the example, speed changes to 0.015 which is normally 0.01.

You can change existing icon by your own by

Code: Select all

data.raw[transpolt-belt][basic-transpolt-belt].icon = "__wooden-transpolt-belt__/graphics/icon/new-sprite.png"
And recipes like how long it takes to craft by

Code: Select all

data.raw.recipe[basic-transpolt-belt].energy_required = 5
Changing ingredients

Code: Select all

data.raw.recipe[basic-transpolt-belt].ingredients = {{type="item", name="iron-plate, amount=5}, {type="item", name="copper-wire", amount=2}}
Have fun :)

Edit: Changing existing recipies and entities should be done in data-updates.lua or data-final-fixes.lua. These has to be in the same folder as data.lua. Calling require("prototypes.basic-belt-changes") in data-updates.lua and making the changes there is a good example to keep your code organized, but is not a must.

https://wiki.factorio.com/index.php?title=Data.raw here you can find a list of entity families and their childrens name without scrolling through the code to find the right item you want to change. In the wiki you can also find what attributes different entities can hold.
Post Reply

Return to “Modding help”