[Solved]How to get started /w modding? (small graphical mod)

Place to get help with not working mods / modding interface.
Post Reply
Mendel
Filter Inserter
Filter Inserter
Posts: 267
Joined: Mon Aug 17, 2015 1:51 pm
Contact:

[Solved]How to get started /w modding? (small graphical mod)

Post by Mendel »

Okay, so I have 0 experience with factorio modding. How do I get started?

Seeing as I have no experience with this, I wanted to do a very limited, simple mod... or fail and be very humble about it.

What I want to do?

I want to actually make this underground belt change so it looks visually different and doesn´t block the view of one side of the belt.
viewtopic.php?f=80&t=32665

The behavior of the belts would not change so Im hoping I could do this mostly by just editing sprites.

What do I need to know:

What file contains the graphical elements of underground belts?
what format are the pictures and how to edit these files?
How does the game handle transparency of sprites?
Are the files compressed in some container file that needs to be processed before it can be edited and how to compress them back after editing?
Is there some factorio-specific tools that I will need?



general mod questions
How to implement a dummy mod in simplest way that just changes a few sprites, no behavior/functional changes to the game whatsoever?
Do I just make a new directory and where and put files there?
How do I make the game know that this mod is there?
Do I need to include files other than the edited pictures of the underground belts?
Am I too stupid to do this?
Last edited by Mendel on Mon Sep 19, 2016 4:23 am, edited 1 time in total.

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: How to get started with modding? (small graphical mod)

Post by aubergine18 »

You'll need a mod with a `data.lua` that changes the underground belts to use different sprites.

To do that access the relevant underground belt via `data.raw`, for example:

Code: Select all

-- in your data.lua
local belts = data.raw['underground-belt']

local normal = belts['underground-belt']
local express = belts['express-underground-belt']
local fast = belts['fast-underground-belt']
They are all similar structure, this is what the normal belt settings look like:

Code: Select all

    {
      animation_speed_coefficient = 32,
      belt_horizontal = nil,
      belt_vertical = nil,
      collision_box = {
        {
          -0.40000000000000002,
          -0.40000000000000002
        },
        {
          0.40000000000000002,
          0.40000000000000002
        }
      },
      corpse = "small-remnants",
      ending_bottom = nil,
      ending_patch = nil,
      ending_side = nil,
      ending_top = nil,
      fast_replaceable_group = "underground-belt",
      flags = {
        "placeable-neutral",
        "player-creation",
        "fast-replaceable-no-build-while-moving"
      },
      icon = "__base__/graphics/icons/underground-belt.png",
      max_distance = 5,
      max_health = 60,
      minable = {
        hardness = 0.20000000000000001,
        mining_time = 0.5,
        result = "underground-belt"
      },
      name = "underground-belt",
      resistances = {
        {
          percent = 60,
          type = "fire"
        }
      },
      selection_box = {
        {
          -0.5,
          -0.5
        },
        {
          0.5,
          0.5
        }
      },
      speed = 0.03125,
      starting_bottom = nil,
      starting_side = nil,
      starting_top = nil,
      structure = {
        direction_in = {
          sheet = {
            filename = "__base__/graphics/entity/underground-belt/underground-belt-structure.png",
            height = 43,
            priority = "extra-high",
            shift = {
              0.26000000000000001,
              0
            },
            width = 57,
            y = 43
          }
        },
        direction_out = {
          sheet = {
            filename = "__base__/graphics/entity/underground-belt/underground-belt-structure.png",
            height = 43,
            priority = "extra-high",
            shift = {
              0.26000000000000001,
              0
            },
            width = 57
          }
        }
      },
      type = "underground-belt",
      underground_sprite = {
        filename = "__core__/graphics/arrows/underground-lines.png",
        height = 64,
        priority = "high",
        scale = 0.5,
        width = 64,
        x = 64
      }
    }
So you could change the path to the graphics file like so:

Code: Select all

-- in your data.lua
normal.structure.direction_out.sheet.filename = '__YourModName__/graphics/underground-belt-structure.png'
Then just provide the revised graphic in that folder. Hope that helps.
Last edited by aubergine18 on Sun Sep 18, 2016 7:49 pm, edited 1 time in total.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: How to get started with modding? (small graphical mod)

Post by aubergine18 »

There's a modding tutorial here that shows the folder structure, files, etc. All you really need is the info.json, the data.lua and your custom graphic.

Code: Select all

YourMod_0.0.1/
  |
  +- info.json
  +- data.lua
  |
  +- graphics/
      |
      +- underground-belt-structure.png
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Mendel
Filter Inserter
Filter Inserter
Posts: 267
Joined: Mon Aug 17, 2015 1:51 pm
Contact:

Re: How to get started with modding? (small graphical mod)

Post by Mendel »

Thank you so much so far!

However, it just struck me that belts are of course animated. So this is a bit of an added complexity. (animated png makes me scratch head)

That said, if I can even make some kind of visible change, that will be a good start, I will return with more questions once I have any kind of progress :)

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: How to get started with modding? (small graphical mod)

Post by aubergine18 »

Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Mendel
Filter Inserter
Filter Inserter
Posts: 267
Joined: Mon Aug 17, 2015 1:51 pm
Contact:

Re: How to get started with modding? (small graphical mod)

Post by Mendel »

well I encountered an error I cant seem to figure out:

contents of my data.lua

Code: Select all

local belts = data.raw['underground-belt']

local normal = belts['underground-belt']
local express = belts['express-underground-belt']
local fast = belts['fast-underground-belt']

normal.structure.direction_out.sheet.filename = '__ubeltmagic_0.1.1__/Graphics/underground-belt/ubeltmagic.png'
contents of my info.json

Code: Select all


{
"name": "ubeltmagic",
  "version": "0.1.1",
  "factorio_version": "0.14",
  "title": "Underground belt graphical mod",
  "author": "Mendel",
  "contact": "https://forums.factorio.com/forum/",
  "homepage": "https://forums.factorio.com/forum/",
  "description": "Mod that makes underground belt visible on one belt side"
}
also there is a file C:\Users\Mendel\AppData\Roaming\Factorio\mods\ubeltmagic_0.1.1\Graphics\underground-belt\ubeltmagic.png

Upon trying to start the game I get this: "path __ubeltmagic_0.1.1__/Graphics/underground-belt/ubeltmagic.png does not match any mod"

Maybe I understood this wrong and I need to add that whole belt settings part somewhere too?

Zeblote
Filter Inserter
Filter Inserter
Posts: 973
Joined: Fri Oct 31, 2014 11:55 am
Contact:

Re: How to get started with modding? (small graphical mod)

Post by Zeblote »

Based on that error message, I guess you need to use

Code: Select all

'__ubeltmagic__/Graphics/underground-belt/ubeltmagic.png'
(without 0.1.1)

Mendel
Filter Inserter
Filter Inserter
Posts: 267
Joined: Mon Aug 17, 2015 1:51 pm
Contact:

Re: How to get started with modding? (small graphical mod)

Post by Mendel »

That did the trick!
And to my amazement it actually works like intended! the game somehow automatically adds the belt parts under the transparent parts of the underground belt entity. :D

http://images.akamai.steamusercontent.c ... 458EB5308/


todo:
repeat edit for fast and express belt
release in workshop (how?)

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: How to get started with modding? (small graphical mod)

Post by aubergine18 »

To release in mod portal, you just log in to mods.factorio.com (login link in top-right corner of that page - note: different login to your forum login, it think mods site uses the account you bought game with) and then upload your mod.

I did very short tutorial with some infos that might be of help: viewtopic.php?f=189&t=32664
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Mendel
Filter Inserter
Filter Inserter
Posts: 267
Joined: Mon Aug 17, 2015 1:51 pm
Contact:

Re: How to get started with modding? (small graphical mod)

Post by Mendel »

edit out: (didnt find all the necessary files)
actually no, wait, Im an idiot. just found the other files under their respective folders :D

Zeblote
Filter Inserter
Filter Inserter
Posts: 973
Joined: Fri Oct 31, 2014 11:55 am
Contact:

Re: How to get started with modding? (small graphical mod)

Post by Zeblote »

The grass shines through on one of them, it's not ready yet :D

Image
Last edited by Zeblote on Sun Sep 18, 2016 9:48 pm, edited 1 time in total.

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: How to get started with modding? (small graphical mod)

Post by aubergine18 »

They are in different folders in the base mod:

__base__/graphics/entity/fast-underground-belt/fast-underground-belt-structure.png

__base__/graphics/entity/express-underground-belt/express-underground-belt-structure.png

__base__/graphics/entity/underground-belt/underground-belt-structure.png

You could just have 3 files in your graphics folder, one for each of the belts.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Mendel
Filter Inserter
Filter Inserter
Posts: 267
Joined: Mon Aug 17, 2015 1:51 pm
Contact:

Re: How to get started with modding? (small graphical mod)

Post by Mendel »

zeblote: true! Small tweaking to commence!

Mendel
Filter Inserter
Filter Inserter
Posts: 267
Joined: Mon Aug 17, 2015 1:51 pm
Contact:

Re: How to get started with modding? (small graphical mod)

Post by Mendel »

aaaand its released!

https://mods.factorio.com/mods/Mendeli/ubeltmagic

Well, first version anyways!

Thanks for the help!

I would appreciate if someone tested this too :)

Post Reply

Return to “Modding help”