Skip to content

Commit 7f62b6c

Browse files
committed
get right turn track working
1 parent 0896503 commit 7f62b6c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

mods/fl_trains/engine.lua

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ minetest.register_entity("fl_trains:train_engine", {
130130
["fl_trains:crossing_track"] = true,
131131
["fl_trains:straight_45_track"] = true,
132132
["fl_trains:curve_left_track"] = true,
133-
--[[ ["fl_trains:curve_right_track"] = true, ]]
133+
["fl_trains:curve_right_track"] = true,
134134
}
135135

136136
if continue_rail_nodes[node.name] then
@@ -141,23 +141,29 @@ minetest.register_entity("fl_trains:train_engine", {
141141
else
142142
--works if straight headed in to curve left track param2 of 1
143143
--TODO: take into account param2 for rotation
144-
if currnode.name == "fl_trains:curve_left_track"--[[or currnode.name == "fl_trains:curve_right_track"]] then
144+
if currnode.name == "fl_trains:curve_left_track" or currnode.name == "fl_trains:curve_right_track" then
145145
--minetest.chat_send_all(dump(pos))
146-
--[[ local curvetype = currnode.name:split(":")[2]:split("_")[2] ]]
146+
local curvetype = currnode.name:split(":")[2]:split("_")[2]
147147
--minetest.chat_send_all(dump(curvetype))
148148
if is_centered(pos) then
149149
local currrotation = self.object:get_rotation()
150150
--minetest.chat_send_all("hiii")
151151

152-
--minetest.chat_send_all(math.floor(rad_to_deg(currrotation.y)))
153-
local rotation = math.floor(rad_to_deg(currrotation.y))
152+
--[[ minetest.chat_send_all(dump(
153+
{
154+
rad = currrotation.y,
155+
deg = rad_to_deg(currrotation.y),
156+
floor = math.floor(rad_to_deg(currrotation.y))
157+
}
158+
)) ]]
159+
local rotation = math.round(rad_to_deg(currrotation.y))
154160

155161
--is center can only determine if we are roughly center, so force center
156162
self.object:set_pos(vector.apply(pos, math.round))
157163

158164
local rotation_degrees = 0
159165
if rotation%90==0 then rotation_degrees = 45 elseif rotation%45==0 then rotation_degrees = -45 end
160-
--if curvetype=="right" then rotation_degrees = rotation_degrees*-1 end
166+
if curvetype=="right" then rotation_degrees = rotation_degrees*-1 end
161167

162168
self.object:set_rotation(
163169
vector.new(currrotation.x, currrotation.y + deg_to_rad(rotation_degrees), currrotation.z)

0 commit comments

Comments
 (0)