Code: Select all
local rails = {
{"straight-rail", {x = -11, y = -7}, 7},
{"straight-rail", {x = -11, y = -9}, 3},
{"straight-rail", {x = -13, y = -5}, 7},
{"straight-rail", {x = -13, y = -7}, 3},
{"straight-rail", {x = 3, y = -3}, 0},
{"straight-rail", {x = 3, y = -1}, 0},
{"straight-rail", {x = 3, y = 1}, 0},
}
for _,rail in ipairs(rails) do
game.surfaces.nauvis.create_entity{name=rail[1],position=rail[2],direction=rail[3],force="player"}
end
local locos = {
{"locomotive", {x = -11.67578125, y = -7.3203125}, 1},
{"locomotive", {x = 3, y = -0.78125}, 0},
}
for _,loco in ipairs(locos) do
game.surfaces.nauvis.create_entity{name=loco[1],position=loco[2],direction=loco[3],force="player"}
end
Also, the train location coordinates seem to be rounded. The coordinates in the test case code above were produced by manually placing locomotives in game then checking their position attribute. After running the code on a fresh map, the produced locmotives' position attributes are rounded to five(?) decimal places.
PS: this does not happen with every non-orthogonal locomotive. In my experiments with my entity mirror mod only about 1 in 4 attempts to place a locomotive on a diagonal or curved track ends up pointed the wrong way.