Original Post — Direct link

This question is a follow up question after my question of yesterday in which I was looking for a way to teleport a train from one rail to another (for the development phase of a challenge). After looking into a few mods available and their source code, it seems more complex than I was hoping, so I thought about alternative solutions, and this is why I would like to ask anyone with mod-making knowledge:

Would it be possible to create a mod giving a special type of rails that instantly set the speed of any train on them to a set value.

Instead of teleporting, I could simply set the speed to something ludicrously high, which would almost be a teleportation.

After reading the introductory tutorials it seems like I could proceed as follows:

  • Create another type of rail with a different colour to be easily identified, let's call it "Fast Rail"
  • Each tick, iterate through every train, and call LuaTrain's get_rails()
  • If the current train is on a "Fast rails", set speed of train to something insanely high with LuaTrain's speed to something ludicrously high and save previous speed
  • If the train was on "Fast rails" but now isn't, set the speed back to its speed from when it entered the "Fast rails"

Modifying the speed of a train might result in problems as it uses this value to calculate when it should start braking to stop, but I accept this risk.

Can someone confirm that my logic works? If you have any better idea please let me know how you'd proceed.

Thank you so much.

External link →
over 1 year ago - /u/Klonan - Direct link

Its possible, the code wouldn't look so complicated apart from the 'return to previous speed' part.






Recent Factorio Posts