[REQUEST] [DONE] train stats editor
- thereaverofdarkness
- Filter Inserter
- Posts: 558
- Joined: Wed Jun 01, 2016 5:07 am
- Contact:
[REQUEST] [DONE] train stats editor
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
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.
Re: [REQUEST] [EASY] train stats editor
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 valuethereaverofdarkness wrote: I want to be able to tweak the attributes of trains without changing the base game.
- thereaverofdarkness
- Filter Inserter
- Posts: 558
- Joined: Wed Jun 01, 2016 5:07 am
- Contact:
Re: [REQUEST] [EASY] train stats editor
What I meant was I want the values to change, but I don't want to directly edit my copy of Factorio.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
Re: [REQUEST] [EASY] train stats editor
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.
You would need a mod. and for any changes to take affect you would have to restart the game every time.
Re: [REQUEST] [EASY] train stats editor
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.
I also update mods, some of them even work.
Recently I did a mod tutorial.
Re: [REQUEST] [EASY] train stats editor
Have you tested this? I'm pretty sure a factorio_version line is mandatory since 0.13.Adil wrote:info.json
EDIT: It is. You'll have to add the following line somewhere in that file:
Code: Select all
"factorio_version" : "0.14",
- thereaverofdarkness
- Filter Inserter
- Posts: 558
- Joined: Wed Jun 01, 2016 5:07 am
- Contact:
Re: [REQUEST] [EASY] train stats editor
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?Adil wrote:Just create these two files in a folder named "TrainEdit_0.0.1 and put that into mods folder.
Re: [REQUEST] [EASY] train stats editor
Use this data.lua, it is preseeded with vanilla values: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?
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
- thereaverofdarkness
- Filter Inserter
- Posts: 558
- Joined: Wed Jun 01, 2016 5:07 am
- Contact:
Re: [REQUEST] [EASY] train stats editor
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.
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.
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
Also, how would I put in lines for resistances? They are indented from the other attributes.
Re: [REQUEST] [EASY] train stats editor
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
if you want to set resistances you can do this using the "resistances" field like this
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']
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!
- thereaverofdarkness
- Filter Inserter
- Posts: 558
- Joined: Wed Jun 01, 2016 5:07 am
- Contact:
Re: [REQUEST] [EASY] train stats editor
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
--------------------------------
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.
Here's my mod page: https://mods.factorio.com/mods/thereave ... /TrainEdit
--------------------------------
Now it gives this error: "<name> expected near '['"dandielo wrote:Code: Select all
local cargo=data.raw['cargo-wagon']['cargo-wagon']
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.
Re: [REQUEST] [EASY] train stats editor
If you change a technology/recipe without updating the version number of your mod you will need to run these commandsthereaverofdarkness wrote: Is there some way to change the existing save game's recipe cost?
/c game.player.force.reset_recipes()
/c game.player.force.reset_technologies()
- thereaverofdarkness
- Filter Inserter
- Posts: 558
- Joined: Wed Jun 01, 2016 5:07 am
- Contact:
Re: [REQUEST] [DONE] train stats editor
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.
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.