Realistic Electric Trains 1.1 fix balance K2

by Keysivi

This fork of Realistic Electric Trains is an attempt to balance it with the features of Krastorio 2

Content
2 years ago
1.1
1.89K
Trains

g Compatibility with Multiple Unit Train Control

2 years ago

I added a dependency to this fork so it will not crash anymore.

For MUTC to actually work with it, you need to fix a legacy bug by adding a line in function register_locomotive_type(loco_name, fuel_item):

global.electric_loco_registry[loco_name] = fuel_item

So that the new electric locomotives are actually added to the list of types to be electrically refueld.

And there seems to be a mismatch between the locomotive power setting and the dummy fuel item fuel value (at least for the standard loco). You need to increase the fuel value so that the locomotive does not run out of energy before the next update cycle, at its maximum consumption rate. (you can tell this is happening because the out-of-fuel warning flashing while driving normally/manually).

2 years ago

Good afternoon! I will try to change the code a little later, as you suggest.

The rest is more difficult, because I'm not a programmer. And even those changes that I made in this fork were very difficult for me. Therefore, I just do not understand what I need to do to solve the problem of "matching the power of the locomotive and the value of fictitious fuel"


In fact, this mod does not make sense to use without https://mods.factorio.com/mod/Train_balanced_K2_plus. Because this fork itself is a stripped down version of https://mods.factorio.com/mod/Realistic_Electric_Trains

I just wanted to add Krastorio 2 equipment mesh to these locomotives and bring their specifications in line with Krastorio 2, as well as keep the original sprites that I really liked...

I did this solely because, apart from me, it turned out to be useless to anyone. If someone more capable would support this fork or solve this problem in a better way, I would accept it with great pleasure and relief.

2 years ago
(updated 2 years ago)

Well, at least one other person wants to use your fork, so good job! You also stripped out the modular locomotive, right? I always thought those were annoying anyways.

I can take a look again and point out what item needs to change. The electric loco works by "burning" a dummy fuel item that the mod inserts when the loco is near power lines. So that fuel item has a fuel value that is too small compared to the loco power, and it finishes burning before the mod inserts the next one.

2 years ago
(updated 2 years ago)

I made an insert in the file: remotes.lua

Here is the code:

function register_locomotive_type(loco_name, fuel_item)
if remote.interfaces["FuelTrainStop"] then
remote.call("FuelTrainStop", "exclude_from_fuel_schedule", loco_name)
global.electric_loco_registry[loco_name] = fuel_item
end
end

-- Returns the fuel item this locomotive type was registered with.
function get_locomotive_fuel(loco_name)
return global.electric_loco_registry[loco_name]
end

remote.add_interface("realistic_electric_trains",
{
["register_locomotive_type"] = register_locomotive_type,
["get_locomotive_fuel"] = get_locomotive_fuel
})

Please clarify did I do it right?

2 years ago

Regarding the error with the "locomotive power" - I will be very happy if you tell me a solution.

Thank you!

2 years ago
(updated 2 years ago)

The line you added should be between the two "end" statements, so that it runs even if FuelTrainStop is not installed:

function register_locomotive_type(loco_name, fuel_item)
if remote.interfaces["FuelTrainStop"] then
remote.call("FuelTrainStop", "exclude_from_fuel_schedule", loco_name)
end
global.electric_loco_registry[loco_name] = fuel_item
end

-- Returns the fuel item this locomotive type was registered with.
function get_locomotive_fuel(loco_name)
return global.electric_loco_registry[loco_name]
end

remote.add_interface("realistic_electric_trains",
{
["register_locomotive_type"] = register_locomotive_type,
["get_locomotive_fuel"] = get_locomotive_fuel
})
2 years ago

I made corrections - everything seems to work. Thank you!

I cut out the modular locomotives as I wasn't sure they would work correctly with the Krastorio 2 equipment grid. And without the modules, they are no different from regular locomotives.

Thanks for the hints! I'm only able to work a little with jQuery. And with lua I was able to do something, because they are a bit similar to javascript. And even then, I acted almost by touch ...

New response