Page 1 of 1

How Can I Find This?

Posted: Sat Jan 10, 2015 3:49 am
by DoctorWho?
I want to make a mod which allows various things, such as better power armour, a personal robo-port that draws from your inventory, fluid tank wagons for trains, etc.
How would i be able to find the code for things like power armour, robo-ports, fluid tanks, etc?
Just started coding, and need an idea of where to base the code. :D
Edit: Do i have to simply base these off of descriptions in the game, as i can't find any code for items/entities at all.

Re: How Can I Find This?

Posted: Sat Jan 10, 2015 12:26 pm
by ForFoxAche
You Factorio directory contains /data/base. There you can find the base mod which contains a whole lot of things. If you want to create a custom item or entity this is a great place to start. Do you know how to add an item/entity into the game? If not you should read this to get started.

You can find the basic power armor item in /data/base/prototypes/item/armor.lua:

Code: Select all

{
    type = "armor",
    name = "power-armor",
    icon = "__base__/graphics/icons/power-armor.png",
    flags = {"goes-to-main-inventory"},
    resistances = 
    {
      {
        type = "physical",
        decrease = 8,
        percent = 30
      },
      {
        type = "acid",
        decrease = 7,
        percent = 30
      },
      {
        type = "explosion",
        decrease = 15,
        percent = 30
      }
    },
    durability = 15000,
    subgroup = "armor",
    order = "d[power-armor]",
    stack_size = 1,
    equipment_grid = {width = 7, height = 7}
  },
and then copy and paste that into your own mod to create your custom power armor. However, you can't see or modify most of the game's code/logic, so some things just can't be done in a sensible way at this time.

You can also find the locomotive/cargo wagons in /data/base/prototypes/entity/entities.lua. They're called "diesel-locomotive" and "cargo-wagon" respectively.

Another great resource is looking at other people's mods. Find a mod which is close to what you want to do, download it, extract it, and look at how the author created it and maybe you can figure out how to do what you want to do.

I recommend a text editor with the functionality to search through files (like Notepad++ if you're on windows) so you can search the whole /data/base directory for a certain item.

Re: How Can I Find This?

Posted: Sat Jan 10, 2015 2:33 pm
by DoctorWho?
Thanks for the help! I didn't realize the code would be in that folder, and thought that was just for generating the world, the title screen, etc. :D
Edit: Can't find the data folder, would it be in the Factorio folder inside of Roaming?
Also: I'm on windows, if that matters.

Re: How Can I Find This?

Posted: Sun Jan 11, 2015 12:39 am
by ForFoxAche
I'm on windows as well. I set it to not use the %appdata% directory though.

For me the folder is at D:/Win8/Spel/Factorio/data/ where Factorio is my install dir. If it's not there it ought to be in the %appdata% (roaming) directory

Re: How Can I Find This?

Posted: Sun Jan 11, 2015 4:38 am
by n9103
I find the zip versions much easier to edit, as all the files are contained within the one directory you extract.
As for modding, yes, there are *Many* mods on the forums, and I don't know if there's a single part of the game that hasn't been modded at some point. Look throughout this subforum for mods that sound like they're similar to what you want. Particularly, use the search box with a couple terms at a time.
Also useful is the Factorio wiki and it's documentation of the various variables, methods, and definitions. (Only partially documented now, as it's been awhile since it was updated, and several new entries are missing from most categories.)

Re: How Can I Find This?

Posted: Mon Jan 12, 2015 3:14 am
by DoctorWho?
ForFoxAche wrote:I'm on windows as well. I set it to not use the %appdata% directory though.

For me the folder is at D:/Win8/Spel/Factorio/data/ where Factorio is my install dir. If it's not there it ought to be in the %appdata% (roaming) directory
That's the problem. I can't find the data folder, and have even looked in any hidden folders, which apparently don't exist. I used Run (Win7), put in C:\Users\Us\AppData\Roaming\Factorio\data, and still nothing. I have no clue what is going on here.
If anyone can tell me how to insert an image, i will put my Factorio directory in the main post.

Re: How Can I Find This?

Posted: Mon Jan 12, 2015 1:16 pm
by ForFoxAche
DoctorWho? wrote:That's the problem. I can't find the data folder, and have even looked in any hidden folders, which apparently don't exist
Try searching through your entire HDD(s) for some of the files in the /data/ folder. Here are some examples that are all in /data/ or in one of its subfolders:

laser-turret-upgrades.lua
shotgun-shell-upgrades.lua
basic-electric-discharge-defense-equipment.png
express-transport-belt-to-ground.png
acid-projectile-purple-shadow.png
assembling-machine-t3-2.ogg
inserter-long-handed.ogg

I picked out a few that are probably unique to Factorio.

In case you don't know how to search, just open up the explorer and click "This PC", in the top right there's a search box. Make sure it says "Search This PC", and then type in something like "basic-electric-discharge-defense-equipment.png" without the quotes. Make sure to enable hidden folders. It could take a while to search through every single HDD.

When you find one of the files you can just right-click it and click "Open file location"

Good luck

Re: How Can I Find This?

Posted: Mon Jan 12, 2015 10:13 pm
by DoctorWho?
ForFoxAche wrote:
DoctorWho? wrote:That's the problem. I can't find the data folder, and have even looked in any hidden folders, which apparently don't exist
Try searching through your entire HDD(s) for some of the files in the /data/ folder. Here are some examples that are all in /data/ or in one of its subfolders:

laser-turret-upgrades.lua
shotgun-shell-upgrades.lua
basic-electric-discharge-defense-equipment.png
express-transport-belt-to-ground.png
acid-projectile-purple-shadow.png
assembling-machine-t3-2.ogg
inserter-long-handed.ogg

I picked out a few that are probably unique to Factorio.

In case you don't know how to search, just open up the explorer and click "This PC", in the top right there's a search box. Make sure it says "Search This PC", and then type in something like "basic-electric-discharge-defense-equipment.png" without the quotes. Make sure to enable hidden folders. It could take a while to search through every single HDD.

When you find one of the files you can just right-click it and click "Open file location"

Good luck
Thanks for the help!

Re: How Can I Find This?

Posted: Tue Jan 13, 2015 9:40 am
by JamesOFarrell
DoctorWho? wrote:I want to make a mod which allows various things, such as better power armour, a personal robo-port that draws from your inventory, fluid tank wagons for trains, etc.
How would i be able to find the code for things like power armour, robo-ports, fluid tanks, etc?
Just started coding, and need an idea of where to base the code. :D
Edit: Do i have to simply base these off of descriptions in the game, as i can't find any code for items/entities at all.
All these mods exist already so you probably want to just download them and read the code.

Advanced Equipment
Pocket Bots
Rail Tanker

Re: How Can I Find This?

Posted: Mon Mar 28, 2016 7:41 pm
by Austin5003
DoctorWho? wrote:
ForFoxAche wrote:I'm on windows as well. I set it to not use the %appdata% directory though.

For me the folder is at D:/Win8/Spel/Factorio/data/ where Factorio is my install dir. If it's not there it ought to be in the %appdata% (roaming) directory
That's the problem. I can't find the data folder, and have even looked in any hidden folders, which apparently don't exist. I used Run (Win7), put in C:\Users\Us\AppData\Roaming\Factorio\data, and still nothing. I have no clue what is going on here.
If anyone can tell me how to insert an image, i will put my Factorio directory in the main post.
I found my data folder in C:\Program Files\Factorio