Advertisement
Guest User

Factorio Set Max Train Speed Command

a guest
Mar 15th, 2017
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 KB | None | 0 0
  1. /c
  2. local trains = {}
  3. local surface = game.surfaces["nauvis"]
  4. for c in surface.get_chunks() do
  5.   for _, loco in pairs(surface.find_entities_filtered({area={{c.x * 32, c.y * 32}, {c.x * 32 + 32, c.y * 32 + 32}}, type="locomotive"})) do
  6.     local main_loco
  7.     local train = loco.train
  8.     local locos = train.locomotives
  9.     if train.valid and train.locomotives and (#locos.front_movers > 0 or #locos.back_movers > 0) then
  10.       main_loco = locos.front_movers and locos.front_movers[1] or locos.back_movers[1]
  11.     end
  12.     local id = main_loco and main_loco.unit_number
  13.     if id then
  14.       trains[id] = main_loco
  15.     end
  16.   end
  17. end
  18. for _, loco in pairs(trains) do
  19.   loco.train.speed = 1.2
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement