[GUIDE] Furnace Mod 101

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

[GUIDE] Furnace Mod 101

Post by FreeER »

Creating a furnace 101
This is a quick tutorial on how I created an iron furnace in factorio.
I'm on windows 7 64-bit so my data folder is inside of C:\Program Files\Factorio\data\
if you have a different OS your data folder will probably be somewhere else (i don't know where but you should be able to look it up, or ask on here)

First on windows systems make sure that you can actually see file extensions (if not open a folder and find the 'organize' button click it and then 'folder and serach options' when that is open there are three tabs 'general', 'view', and 'search'. click on 'view' and you'll see a bunch of options with checkboxes next to them, without scrolling at the bottom of the list should be 'hide extensions for known file types' UNcheck this box and then click ok) otherwise when you use notepad to create a json file it will mostly likely save as a .json.txt file and you probably wouldn't notice until you tried to start factorio and it acted as if your mod didn't exist (because factorio would not read the .txt files)

next create an iron-furnace.json file inside of data\prototype-definitions\entity (you can open the folder and right click>new>'text document' just be sure that you change the .txt extension to .json
then open up the demo-entities.json file and copy+paste the entry for the stone-furnace make sure you include everything from the { above "type": "furnace", to the }.

Now change the values to what you want them to be. Most of the names are self-explanatory, if you can't figure it out by the name, then edit the values by a large fraction (like from .001 to .5 and see what the result is. in my iron-furnace I made it cook 2x as fast but only be 65% as efficient. As well as setting the health to 50 (it's made of iron not stone after all). Play around with the values and see what you like (and what feels balanced)
For example, i made mine:

Code: Select all

          "heat-loss": 0.006,
          "heat-transport-speed": 0.03,
          "burning-speed": 0.002,
          "effectivity": 650,
make sure you change the name from stone-furnace to iron-furnace, the same with the "minable" result and the png files for picture (I usually use ctrl+h to open the 'find and repace' menu and simply change all references at the same time)

You can create the images now (they are saved in the data\resources\entity folder), all i did was copy the stone-furnace image and increase it's brightness so it was more white than gray (or you could simply copy the stone-furnace image and without modifying it as a placeholder, just remember to change it's name to iron-furnace). Now it is not referenced in this file but you will also need an icon picture in data\resources\icon (again i copied the stone-furnace in the icons folder and made it brighter)
You could also wait until later to create the images, if you forget, well you'll be told when you go to start factorio :)

next you will need to create an iron-furnace.json file inside of \prototype-definitions\item
inside you could either copy and paste the stone-furnace info from demo-item.json or copy and paste this:

Code: Select all

[
  {
    "type": "item",
    "name": "iron-furnace",
    "place-result": "iron-furnace",
    "order": "h-b-a",
    "stack-size": 64,
    "flags": [ "goes-to-quickbar" ]
  }
]
You will then need another iron-furnace.json file inside of \prototype-definitions\recipe
the format is:

Code: Select all

[
  {
    "result": "iron-furnace",
    "ingredients": { "stone-furnace": 1, "iron-plate": 8 },
    "enabled": "false"
  }
]
now you need a way to unlock the recipe, I initially added it to the techonology.json file inside of prototype-definitions\technology\technology.json
under iron-working there is an "effects" block, copy and paste:

Code: Select all

       {
        "type" : "unlock-recipe",
        "recipe" : "iron-furnace"
       }
to be underneath the iron-chest. now when iron-working is researched it unlocks your iron-furnace recipe.
Or (as i eventually did) you could create your own research branch by simply copying the entire iron-working block to a new .json file (from the [ to }) and changing the name and inserting your unlock-recipes in there (remember to add a closing ] at the end of the file and you'll need to remove the comma on the next to last line or you'll get an 'expected value' error. (note if you do create a research branch you will also need a technology icon under data\resources\technology\icons)


The last thing you need to do is open the data\locale\[your language]\entity-names.cfg add

Code: Select all

iron-furnace=Iron Furnace
If you created your own research branch you will also need to name it in technology-names.cfg (ex.

Code: Select all

iron-furnace=Furnace Upgrades
)

If you skip the locale steps then in the game your furnaces gui will show up as Unknown Key:"entity.iron-furnace" and (if you made one) your technology name will be Unknown key:"technology-name.iron-furnace" (not exactly what we want now is it?)

That's it, you have now created your own furnace that does whatever you want.


if you want you can download the mod i made for myself (it took about 5-7 hours for me to figure all of this out) and look it all over to see what exactly i did and how i did it. Hope it helps someone out. http://www.freewebs.com/hjp1993/Factori ... urnace.zip


P.S. I know this is not a great tutorial, mainly because I did not even try to cover what everything meant however it's about midnight for me right now and I don't even know if people will find this particuarly useful. If it turns out that people like this I'll probably rewrite it and try to make it more of an actual tutorial than a technical 'do this to achieve this' post like it is right now.
Last edited by rymn on Thu Mar 07, 2013 4:29 pm, edited 1 time in total.
Reason: naming convention
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

I_IBlackI_I
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Wed Feb 20, 2013 6:57 pm
Contact:

Re: Furnace Mod 101

Post by I_IBlackI_I »

One little problem with this mod you can only install 1 mod at the time using the (en/entity-names....) since they wont add theire names but overwrite the names.
I know you can do it manually

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Furnace Mod 101

Post by FreeER »

Yeah wasn't sure how I could solve that, since I'd assumed that I couldn't simply create another file like i had the others (and i just tried it before posting this replay, didn't work :) ) If you know of a better way, please let me know. I suppose I could use a script file (i've made one for install now but i've not tested it yet) and just append to the locale files, not sure how an uninstall would work since i'd been planning on simply backing up their original but if i consider other mods then i'd have to consider them adding mods after this one so i couldn't just try and delete the last lines from the file. :)

Perhaps i should look into how the modloaders that have been posted work lol, haven't really bothered to since there aren't that many mods yet.
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Furnace Mod 101

Post by kovarex »

Hi, this is nice explenation.

Btw I started to do the json definition documentation yesterday:
https://forums.factorio.com/wiki/inde ... efinitions

About the locale, It is a problem indeed and we need to solve it somehow (So you can make separate files).
We will also probably add mechanism, that the game uses English translation as fallback if it can't find the key in the current language, so the mod will work ok in other languages.

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Furnace Mod 101

Post by FreeER »

YAY documentation! After I started looking there I noticed that the lua pages had been worked on since i'd last checked...lol now i'm going to need more time to work on learning that :) Good thing it's nearly the weekend.

As for the locale problem could you allow the game to parse any folder that begins with the language code? That way the main language files are there but if a mod added 'en_iron-furnace' or something under locale it would append the en_* files to the main en files? Or perhaps allow something similar inside of the actual langugae folder, where the game appends other cfgs with similar names (ex. entity-names-iron-furnace would be appended to entity-names). I don't really have any experience with coding so I'm not sure what is easily done :)

The mechanism sounds like a good idea too (admitedly us english is the only language I know)
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

Post Reply

Return to “Modding discussion”