How to start modding Factorio?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
TheYellowBush
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri May 19, 2017 6:05 am
Contact:

How to start modding Factorio?

Post by TheYellowBush »

Hello, beautiful peoples!

I want to start codding Factorio mods. I know that the language used is LUA but i don't understand how i am suposed to start because i'm French and 14 years old (true) and with my English level, my brain just don't allow me to understand this page: https://www.lua.org/download.html. So, i'll greatly appreciate if you just indicate what program i should use for compiling and the best IDE. I'll just find a LUA codding tutorial serie by myself and start codding using the Factorio's API.
So, thank in advance to help me.

PS: I'm on Windows 10 and i use an other PC with Windows 8
Aren't you exited? Aren't you happy?
You are going to be free.

Toby Fox, 2015

fiery_salmon
Fast Inserter
Fast Inserter
Posts: 128
Joined: Wed Dec 13, 2017 1:20 pm
Contact:

Re: How to start modding Factorio?

Post by fiery_salmon »

Lua is compiled by Factorio, what is invisible to user/modder (see any existing mods that you downloaded).

to be more exact
Lua programs are not interpreted directly from the textual Lua file, but are compiled into bytecode, which is then run on the Lua virtual machine. The compilation process is typically invisible to the user and is performed during run-time, but it can be done offline in order to increase loading performance or reduce the memory footprint of the host environment by leaving out the compiler.
https://en.wikipedia.org/wiki/Lua_(prog ... ementation
How to start modding Factorio?
Try googling for tutorials, see stickies like viewtopic.php?f=25&t=4858 .

User avatar
TheYellowBush
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri May 19, 2017 6:05 am
Contact:

Re: How to start modding Factorio?

Post by TheYellowBush »

Okay thank you verry much!
Aren't you exited? Aren't you happy?
You are going to be free.

Toby Fox, 2015

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

Re: How to start modding Factorio?

Post by darkfrei »

All is table!
http://tylerneylon.com/a/learn-lua/

Also please install Notepad++, it can be very helpful.

User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2124
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: How to start modding Factorio?

Post by Ranakastrasz »

Notepad++, and start downloading other mods. Find ones with as few files as possible, smaller mods, etc, and poke them (I suggest my mod Agent Orange, it is very simple). Alter things and experiment to learn how stuff works.

Work with data first, don't touch scripting until you understand how the game objects are put together. Make a few custom recipes first, and alter items.

That's pretty much how I learned to do it. Better to use functional examples and alter them until you understand enough to work from scratch.


Good Luck!
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: How to start modding Factorio?

Post by bobingabout »

when I first started modding, it was literally copy an existing entity's definition, it's item and recipe, and make a new technology. Most of my mods have this structure.

Then people started using table.deepcopy to copy existing entities to a variable, tweak a few values (changing name= is important) and then adding them to the data.

Personally, whenever I write a new mod, I like to use util.merge. I used it in bobclass, and I've used it in boblogistics for some of the new inserters. Here's what I think is a good example.

Code: Select all

data:extend(
{
  util.merge{
    data.raw.inserter["stack-inserter"],
    {
      name = "red-stack-inserter",
      icon = "__boblogistics__/graphics/icons/inserter/red-stack-inserter.png",
      minable = {hardness = 0.2, mining_time = 0.5, result = "red-stack-inserter"},
      extension_speed = 0.07,
      rotation_speed = 0.03,
      energy_per_movement = 17500,
      energy_per_rotation = 17500,
      energy_source =
      {
        type = "electric",
        usage_priority = "secondary-input",
        drain = "0.8kW"
      },
    }
  }
}
)
To note, this is just the entity, you'll still need all the supporting things, like item, recipe, and a method to unlock it (technology) to go with it.

The advantages of table.deepcopy or util.merge is that when the base game entity changes, yours changes along with it, and things still work, vs if you've copy and paste the original entity and things change, you end up with an entity that doesn't work as you intended at best, a mod that doesn't load at worst.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Helfima
Fast Inserter
Fast Inserter
Posts: 199
Joined: Tue Jun 28, 2016 11:40 am
Contact:

Re: How to start modding Factorio?

Post by Helfima »

1) choisi un editeur qui te conviens, pour ma part j'utilise eclipse
2) idéalement il vaut mieux utiliser un outil de versionning genre git, c'est pour pouvoir revenir en arriere ou ne pas tout perdre
3) avoir de la patience et de la persévérence :)

en dehors de cela comme dit avant y a pas de compilation à faire faut juste bien faire attention à mettre "Local" devant toutes tes variables évoluants pendant l'exécution du script sinon ca marchera pas en MP.
je ne peux que conseiller de faire des adaptateurs (module qui appel les attributs ou fonction des classes factorio, ex: https://github.com/Helfima/helmod/blob/ ... Player.lua) ca demande plus de boulot au début mais ou moins quand un truc change c'est bcp plus rapide et stable pour ton code.

pour info mon mod Helmod ne modifie pas le jeu c'est un assistant le plus chaud à été de rendre l'interface utilisable en toute circonstance.

Post Reply

Return to “Modding help”