@@ -130,7 +130,7 @@ minetest.register_entity("fl_trains:train_engine", {
130
130
[" fl_trains:crossing_track" ] = true ,
131
131
[" fl_trains:straight_45_track" ] = true ,
132
132
[" fl_trains:curve_left_track" ] = true ,
133
- --[[ [ "fl_trains:curve_right_track"] = true, ]]
133
+ [ " fl_trains:curve_right_track" ] = true ,
134
134
}
135
135
136
136
if continue_rail_nodes [node .name ] then
@@ -141,23 +141,29 @@ minetest.register_entity("fl_trains:train_engine", {
141
141
else
142
142
-- works if straight headed in to curve left track param2 of 1
143
143
-- 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
145
145
-- minetest.chat_send_all(dump(pos))
146
- --[[ local curvetype = currnode.name:split(":")[2]:split("_")[2] ] ]
146
+ local curvetype = currnode .name :split (" :" )[2 ]:split (" _" )[2 ]
147
147
-- minetest.chat_send_all(dump(curvetype))
148
148
if is_centered (pos ) then
149
149
local currrotation = self .object :get_rotation ()
150
150
-- minetest.chat_send_all("hiii")
151
151
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 ))
154
160
155
161
-- is center can only determine if we are roughly center, so force center
156
162
self .object :set_pos (vector .apply (pos , math .round ))
157
163
158
164
local rotation_degrees = 0
159
165
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
161
167
162
168
self .object :set_rotation (
163
169
vector .new (currrotation .x , currrotation .y + deg_to_rad (rotation_degrees ), currrotation .z )
0 commit comments