Tutorial:Inspecting a live mod: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(Created page with "== Introduction == Welcome to the Inspecting-a-live-mod tutorial! In this tutorial I will take you on an annotated tour of my mod ''Eradicator's Hand Crank Generator Deluxe...")
 
(minor cleanup, added see also links)
Line 5: Line 5:
''Eradicator's Hand Crank Generator Deluxe''. That's a rather
''Eradicator's Hand Crank Generator Deluxe''. That's a rather
long name so I'll often call it just HCG hereafter.
long name so I'll often call it just HCG hereafter.
Hand Crank Generator is a fully functional mod that you can
HCG is a fully functional mod that you can
download and play with right now! It has extensive
download from [https://mods.factorio.com/mod/eradicators-hand-crank-generator Factorio Mod Portal] and play with right now! It has extensive
comments in the code to explain how and why it works.
comments in the code to explain how and why it works.


This tutorial assumes that you already know how LUA works and that
This is an advanced tutorial that assumes that you already know how Lua works and that
you have have familiarized yourself with at least the basic concepts
you have have familiarized yourself with at least the basic concepts
of Factorio modding. On that basis it aims to provide a rough overview
of Factorio modding. If you are not familiar with the basics,
on how real-life mods work. And shows you how to assemble the
[[Tutorial:Modding tutorial/Gangsir|Gangsir's modding tutorial]] is a good starting point for learning them.
On that basis the tutorial aims to provide a rough overview
on how real-life mods work and shows you how to assemble the
theoretical concepts you have learned so far into a working whole.
theoretical concepts you have learned so far into a working whole.
If you want to give yourself a real challenge you can of course try to
read this without any prior knowledge and try to learn on-the-go.


First <code>settings.lua</code> shows creation of some basic setting prototypes. Then <code>data.lua</code> covers most basic operations like creating new item,
First <code>settings.lua</code> shows creation of some basic setting prototypes.
Then <code>data.lua</code> covers most basic operations like creating new item,
recipe, building and technology prototypes. And how to interact with  
recipe, building and technology prototypes. And how to interact with  
prototypes of other mods. Finally in <code>control.lua</code> I explain how
prototypes of other mods. Finally in <code>control.lua</code> I explain how
Line 23: Line 24:
Hand Crank Generator produce power when the player presses a key on the keyboard.
Hand Crank Generator produce power when the player presses a key on the keyboard.


You can read the files on the web on GitHub or download and extract
You can read the files on the web on [https://github.com/lossycrypt/eradicators-hand-crank-generator GitHub] or download and extract
the mod locally to your harddrive.
the mod locally to your hard-drive.


== Tutorial ==
== Tutorial ==
Line 30: Line 31:
I recommend reading in the order that the files are loaded by the game. Have fun!
I recommend reading in the order that the files are loaded by the game. Have fun!


  Chapter 1    : [https://github.com/lossycrypt/eradicators-hand-crank-generator/blob/master/settings.lua settings.lua]
# Chapter 1    : [https://github.com/lossycrypt/eradicators-hand-crank-generator/blob/master/settings.lua settings.lua]
  Chapter 2    : [https://github.com/lossycrypt/eradicators-hand-crank-generator/blob/master/data.lua data.lua]
# Chapter 2    : [https://github.com/lossycrypt/eradicators-hand-crank-generator/blob/master/data.lua data.lua]
  Bonus Chapter : [https://github.com/lossycrypt/eradicators-hand-crank-generator/blob/master/migrations/2020-08-28_HCG_2.0.0.json migration.json]
# Bonus Chapter : [https://github.com/lossycrypt/eradicators-hand-crank-generator/blob/master/migrations/2020-08-28_HCG_2.0.0.json migration.json]
  Chapter 3    : [https://github.com/lossycrypt/eradicators-hand-crank-generator/blob/master/control.lua control.lua]
# Chapter 3    : [https://github.com/lossycrypt/eradicators-hand-crank-generator/blob/master/control.lua control.lua]


== Links ==  
== See also ==
 
* [[Tutorial:Modding tutorial|Modding tutorial overview]]
HCG is available in full on
* [[Prototype definitions|Prototype documentation]]
[https://github.com/lossycrypt/eradicators-hand-crank-generator GitHub]
* [http://lua-api.factorio.com/latest/ Factorio runtime API documentation]
or on the
[https://mods.factorio.com/mod/eradicators-hand-crank-generator Factorio Mod Portal].
 
== Abstract Draft ==
(''For later use in [[Tutorial:Modding_tutorial]]'')
 
[[Tutorial:Inspecting a live mod|Inspecting a live mod]] — An annotated tour of a mod that is live on the mod portal right now.

Revision as of 11:03, 4 September 2020

Introduction

Welcome to the Inspecting-a-live-mod tutorial!

In this tutorial I will take you on an annotated tour of my mod Eradicator's Hand Crank Generator Deluxe. That's a rather long name so I'll often call it just HCG hereafter. HCG is a fully functional mod that you can download from Factorio Mod Portal and play with right now! It has extensive comments in the code to explain how and why it works.

This is an advanced tutorial that assumes that you already know how Lua works and that you have have familiarized yourself with at least the basic concepts of Factorio modding. If you are not familiar with the basics, Gangsir's modding tutorial is a good starting point for learning them. On that basis the tutorial aims to provide a rough overview on how real-life mods work and shows you how to assemble the theoretical concepts you have learned so far into a working whole.

First settings.lua shows creation of some basic setting prototypes. Then data.lua covers most basic operations like creating new item, recipe, building and technology prototypes. And how to interact with prototypes of other mods. Finally in control.lua I explain how to make custom behavior for buildings - namely how to make the Hand Crank Generator produce power when the player presses a key on the keyboard.

You can read the files on the web on GitHub or download and extract the mod locally to your hard-drive.

Tutorial

I recommend reading in the order that the files are loaded by the game. Have fun!

  1. Chapter 1  : settings.lua
  2. Chapter 2  : data.lua
  3. Bonus Chapter : migration.json
  4. Chapter 3  : control.lua

See also