[REQUEST] [DONE] train stats editor

This is the place to request new mods or give ideas about what could be done.
User avatar
thereaverofdarkness
Filter Inserter
Filter Inserter
Posts: 558
Joined: Wed Jun 01, 2016 5:07 am
Contact:

[REQUEST] [DONE] train stats editor

Post by thereaverofdarkness »

Could someone run up a simple mod that transfers train attributes into the mod? I want to be able to tweak the attributes of trains without changing the base game. Mostly I want to change weight, speed, power consumption rate, hit points, resistances, and production costs.

Thanks in advance!



edit: I have received information and have made the mod. Link to mod page: https://mods.factorio.com/mods/thereave ... /TrainEdit
Last edited by thereaverofdarkness on Wed Jan 18, 2017 9:42 am, edited 1 time in total.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: [REQUEST] [EASY] train stats editor

Post by Nexela »

thereaverofdarkness wrote: I want to be able to tweak the attributes of trains without changing the base game.
Not possible, Everything you want to change is only changeable by changing (or creating new copies of) prototypes in the data stage. Which means your game changes. Which means a full restart every time you want to change the value
User avatar
thereaverofdarkness
Filter Inserter
Filter Inserter
Posts: 558
Joined: Wed Jun 01, 2016 5:07 am
Contact:

Re: [REQUEST] [EASY] train stats editor

Post by thereaverofdarkness »

Nexela wrote:Everything you want to change is only changeable by changing (or creating new copies of) prototypes in the data stage. Which means your game changes. Which means a full restart every time you want to change the value
What I meant was I want the values to change, but I don't want to directly edit my copy of Factorio.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: [REQUEST] [EASY] train stats editor

Post by Nexela »

Not sure what you are trying to ask for.

You would need a mod. and for any changes to take affect you would have to restart the game every time.
User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: [REQUEST] [EASY] train stats editor

Post by Adil »

Just create these two files in a folder named "TrainEdit_0.0.1 and put that into mods folder.
info.json
data.lua
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: [REQUEST] [EASY] train stats editor

Post by daniel34 »

Adil wrote:
info.json
Have you tested this? I'm pretty sure a factorio_version line is mandatory since 0.13.

EDIT: It is. You'll have to add the following line somewhere in that file:

Code: Select all

  "factorio_version" : "0.14",
quick links: log file | graphical issues | wiki
User avatar
thereaverofdarkness
Filter Inserter
Filter Inserter
Posts: 558
Joined: Wed Jun 01, 2016 5:07 am
Contact:

Re: [REQUEST] [EASY] train stats editor

Post by thereaverofdarkness »

Adil wrote:Just create these two files in a folder named "TrainEdit_0.0.1 and put that into mods folder.
But how does that help me edit the train stats? It doesn't contain the existing stats (though I could find those in the game files myself). More importantly, the lines are all contained within a comment. What code format do I use to actually write in each attribute I want to change?
daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: [REQUEST] [EASY] train stats editor

Post by daniel34 »

thereaverofdarkness wrote:But how does that help me edit the train stats? It doesn't contain the existing stats (though I could find those in the game files myself). More importantly, the lines are all contained within a comment. What code format do I use to actually write in each attribute I want to change?
Use this data.lua, it is preseeded with vanilla values:

Code: Select all

local train=data.raw.locomotive['diesel-locomotive']
train.weight = 2000
train.max_speed = 1.2
train.max_power = "600kW"
train.reversing_power_modifier = 0.6
train.braking_force = 10
train.friction_force = 0.50
train.vertical_selection_shift = 0.5
train.air_resistance = 0.0075
train.connection_distance = 3
train.joint_distance = 4
train.energy_per_hit_point = 5
quick links: log file | graphical issues | wiki
User avatar
thereaverofdarkness
Filter Inserter
Filter Inserter
Posts: 558
Joined: Wed Jun 01, 2016 5:07 am
Contact:

Re: [REQUEST] [EASY] train stats editor

Post by thereaverofdarkness »

Thanks! It seems to be working!

I'm trying to expand the mod by adding more attributes. I put in some code and tried to match the format but something isn't working and I'm not sure what. I think I got the hit points working fine but when I tried to add a section for the cargo wagon it stopped working. I'm not sure what to put in for the local line up top so that's probably where the error is.

Code: Select all

local train=data.raw.locomotive['diesel-locomotive']
local cargo=data.raw.cargo-wagon['cargo-wagon']
train.max_health = 1000
train.weight = 2000
train.max_speed = 1.2
train.max_power = "600kW"
train.reversing_power_modifier = 0.6
train.braking_force = 10
train.friction_force = 0.50
train.vertical_selection_shift = 0.5
train.air_resistance = 0.0075
train.connection_distance = 3
train.joint_distance = 4
train.energy_per_hit_point = 5
cargo.inventory_size = 40
cargo.max_health = 600
cargo.weight = 1000
cargo.max_speed = 1.5
cargo.braking_force = 3
cargo.friction_force = 0.50
cargo.air_resistance = 0.01
cargo.connection_distance = 3
cargo.joint_distance = 4
cargo.energy_per_hit_point = 5
When I load it up, it says it's trying to access 'wagon' which is a nil value. If I switch it to "local cargo=data.raw.locomotive" then it says it's trying to access 'cargo' which is a nil value.

Also, how would I put in lines for resistances? They are indented from the other attributes.
User avatar
dandielo
Burner Inserter
Burner Inserter
Posts: 11
Joined: Wed Mar 30, 2016 9:25 pm
Contact:

Re: [REQUEST] [EASY] train stats editor

Post by dandielo »

It's stopped working because lua does recognize dashes (-) as a language construct in this case a minus sign. So your line says, "data.raw.cargo" (minus) "wagon['cargo-wagon']" which gives you an error.
However you can replace a 'field name' with a string in brackets, so the solution would be

Code: Select all

local cargo=data.raw['cargo-wagon']['cargo-wagon']
if you want to set resistances you can do this using the "resistances" field like this

Code: Select all

cargo.resistances = { -- this bracket opens a LIST of resistances
      {  -- this is a list element with resistance data
        type = "fire",
        decrease = 15,
        percent = 50
      },
      {
        type = "physical",
        decrease = 15,
        percent = 30
      },
      {
        type = "impact",
        decrease = 50,
        percent = 60
      },
      {
        type = "explosion",
        decrease = 15,
        percent = 30
      },
      {
        type = "acid",
        decrease = 10,
        percent = 20
      }
 }
Resurrecting DyTech's Mods, more about this Here!
User avatar
thereaverofdarkness
Filter Inserter
Filter Inserter
Posts: 558
Joined: Wed Jun 01, 2016 5:07 am
Contact:

Re: [REQUEST] [EASY] train stats editor

Post by thereaverofdarkness »

edit: never mind, I had an extra period in the code. It works now! Thanks everyone for all the help! I added in the recipe for crafting it so that the item costs can be changed. I noticed, however, that changing item costs for a recipe does not affect existing saves. Is there some way to change the existing save game's recipe cost?

Here's my mod page: https://mods.factorio.com/mods/thereave ... /TrainEdit

--------------------------------
dandielo wrote:

Code: Select all

local cargo=data.raw['cargo-wagon']['cargo-wagon']
Now it gives this error: "<name> expected near '['"

I figured in the line local train=data.raw.locomotive['diesel-locomotive'] the diesel-locomotive was connected to the name given in the entities file of the base mod, whereas its type was given by locomotive at the end of the data.raw.locomotive.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: [REQUEST] [EASY] train stats editor

Post by Nexela »

thereaverofdarkness wrote: Is there some way to change the existing save game's recipe cost?
If you change a technology/recipe without updating the version number of your mod you will need to run these commands

/c game.player.force.reset_recipes()
/c game.player.force.reset_technologies()
User avatar
thereaverofdarkness
Filter Inserter
Filter Inserter
Posts: 558
Joined: Wed Jun 01, 2016 5:07 am
Contact:

Re: [REQUEST] [DONE] train stats editor

Post by thereaverofdarkness »

Thanks, it worked! It said it'd disable my achievements if I reset it, but I saved the reset to a different save slot and the change affected my main game, so that seemed to work out well.


I tweaked the train stats for my game such that the train is far more massive and expensive, and burns through fuel much faster. It goes well with the Hard Storage mod, making trains able to carry large amounts of stuff if you're willing to pay the costs. I've also got Warehousing and I tweaked all of the inventory space values to match the same style of limited storage space. The large warehouses have a very comfortable amount of room inside, but they take up a lot of land and are costly to build. This actually has a very interesting effect on gameplay: rather than make the game more difficult, it seems to open up a lot of logistics options. The larger storage units can handle more inserters at once, so you can use them for increased throughput in your bins. Also, you can use a single large storage unit to make crafting simple: hook up assemblers on the sides with inserters pulling from the bin and putting back into it, and toss all of the raw materials into the bin. It's great for manufacturing a specific amount of a complex product.

Let me know if any of you are interested in my mods and settings.
Post Reply

Return to “Ideas and Requests For Mods”