aboutsummaryrefslogtreecommitdiff
path: root/trackplacer.lua
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2016-07-04 13:08:25 +0200
committerorwell96 <mono96.mml@gmail.com>2016-07-04 13:08:25 +0200
commit0e869927299ccd9f720d0144c20dbde6a1054fe0 (patch)
treee002731dc3227fc136e77ce6c59eb07991e9d2d7 /trackplacer.lua
parenta6e19b76518000bae9ca163ce6855e56ee784267 (diff)
downloadadvtrains-0e869927299ccd9f720d0144c20dbde6a1054fe0.tar.gz
advtrains-0e869927299ccd9f720d0144c20dbde6a1054fe0.tar.bz2
advtrains-0e869927299ccd9f720d0144c20dbde6a1054fe0.zip
Screwing everything up in order to extend to 16 possible directions with 1/8 precision
Diffstat (limited to 'trackplacer.lua')
-rw-r--r--trackplacer.lua30
1 files changed, 15 insertions, 15 deletions
diff --git a/trackplacer.lua b/trackplacer.lua
index b1e57a5..2bba2ad 100644
--- a/trackplacer.lua
+++ b/trackplacer.lua
@@ -39,18 +39,18 @@ function advtrains.placetrack(pos)
elseif conn1 and not conn2 then
local node1=minetest.get_node(advtrains.dirCoordSet(pos, conn1))
local node1_conn1, node1_conn2=advtrains.get_track_connections(node1.name, node1.param2)
- local node1_backconnects=(conn1+4)%8==node1_conn1 or (conn1+4)%8==node1_conn2
+ local node1_backconnects=(conn1+8)%16==node1_conn1 or (conn1+8)%16==node1_conn2
if not node1_backconnects and advtrains.trackplacer_modified_rails[node1.name] then
--check if this rail has a dangling connection
--TODO possible problems on |- situation
if not advtrains.is_track_and_drives_on(minetest.get_node(advtrains.dirCoordSet(pos, node1_conn1)).name, advtrains.all_tracktypes) then
- if advtrains.trackplacer_dir_to_node_mapping[node1_conn1.."_"..((conn1+4)%8)] then
- minetest.set_node(advtrains.dirCoordSet(pos, conn1), advtrains.trackplacer_dir_to_node_mapping[node1_conn1.."_"..((conn1+4)%8)])
+ if advtrains.trackplacer_dir_to_node_mapping[node1_conn1.."_"..((conn1+8)%16)] then
+ minetest.set_node(advtrains.dirCoordSet(pos, conn1), advtrains.trackplacer_dir_to_node_mapping[node1_conn1.."_"..((conn1+8)%16)])
end
elseif not advtrains.is_track_and_drives_on(minetest.get_node(advtrains.dirCoordSet(pos, node1_conn2)).name, advtrains.all_tracktypes) then
- if advtrains.trackplacer_dir_to_node_mapping[node1_conn2.."_"..((conn1+4)%8)] then
- minetest.set_node(advtrains.dirCoordSet(pos, conn1), advtrains.trackplacer_dir_to_node_mapping[node1_conn2.."_"..((conn1+4)%8)])
+ if advtrains.trackplacer_dir_to_node_mapping[node1_conn2.."_"..((conn1+8)%16)] then
+ minetest.set_node(advtrains.dirCoordSet(pos, conn1), advtrains.trackplacer_dir_to_node_mapping[node1_conn2.."_"..((conn1+8)%16)])
end
end
end
@@ -67,34 +67,34 @@ function advtrains.placetrack(pos)
end
local node1=minetest.get_node(advtrains.dirCoordSet(pos, conn1))
local node1_conn1, node1_conn2=advtrains.get_track_connections(node1.name, node1.param2)
- local node1_backconnects=(conn1+4)%8==node1_conn1 or (conn1+4)%8==node1_conn2
+ local node1_backconnects=(conn1+8)%16==node1_conn1 or (conn1+8)%16==node1_conn2
if not node1_backconnects and advtrains.trackplacer_modified_rails[node1.name] then
--check if this rail has a dangling connection
--TODO possible problems on |- situation
if not advtrains.is_track_and_drives_on(minetest.get_node(advtrains.dirCoordSet(pos, node1_conn1)).name, advtrains.all_tracktypes) then
- if advtrains.trackplacer_dir_to_node_mapping[node1_conn1.."_"..((conn1+4)%8)] then
- minetest.set_node(advtrains.dirCoordSet(pos, conn1), advtrains.trackplacer_dir_to_node_mapping[node1_conn1.."_"..((conn1+4)%8)])
+ if advtrains.trackplacer_dir_to_node_mapping[node1_conn1.."_"..((conn1+8)%16)] then
+ minetest.set_node(advtrains.dirCoordSet(pos, conn1), advtrains.trackplacer_dir_to_node_mapping[node1_conn1.."_"..((conn1+8)%16)])
end
elseif not advtrains.is_track_and_drives_on(minetest.get_node(advtrains.dirCoordSet(pos, node1_conn2)).name, advtrains.all_tracktypes) then
- if advtrains.trackplacer_dir_to_node_mapping[node1_conn2.."_"..((conn1+4)%8)] then
- minetest.set_node(advtrains.dirCoordSet(pos, conn1), advtrains.trackplacer_dir_to_node_mapping[node1_conn2.."_"..((conn1+4)%8)])
+ if advtrains.trackplacer_dir_to_node_mapping[node1_conn2.."_"..((conn1+8)%16)] then
+ minetest.set_node(advtrains.dirCoordSet(pos, conn1), advtrains.trackplacer_dir_to_node_mapping[node1_conn2.."_"..((conn1+8)%16)])
end
end
end
local node2=minetest.get_node(advtrains.dirCoordSet(pos, conn2))
local node2_conn1, node2_conn2=advtrains.get_track_connections(node2.name, node2.param2)
- local node2_backconnects=(conn2+4)%8==node2_conn1 or (conn2+4)%8==node2_conn2
+ local node2_backconnects=(conn2+8)%16==node2_conn1 or (conn2+8)%16==node2_conn2
if not node2_backconnects and advtrains.trackplacer_modified_rails[node2.name] then
--check if this rail has a dangling connection
--TODO possible problems on |- situation
if not advtrains.is_track_and_drives_on(minetest.get_node(advtrains.dirCoordSet(pos, node2_conn1)).name, advtrains.all_tracktypes) then
- if advtrains.trackplacer_dir_to_node_mapping[node2_conn1.."_"..((conn2+4)%8)] then
- minetest.set_node(advtrains.dirCoordSet(pos, conn2), advtrains.trackplacer_dir_to_node_mapping[node2_conn1.."_"..((conn2+4)%8)])
+ if advtrains.trackplacer_dir_to_node_mapping[node2_conn1.."_"..((conn2+8)%16)] then
+ minetest.set_node(advtrains.dirCoordSet(pos, conn2), advtrains.trackplacer_dir_to_node_mapping[node2_conn1.."_"..((conn2+8)%16)])
end
elseif not advtrains.is_track_and_drives_on(minetest.get_node(advtrains.dirCoordSet(pos, node2_conn2)).name, advtrains.all_tracktypes) then
- if advtrains.trackplacer_dir_to_node_mapping[node2_conn2.."_"..((conn1+4)%8)] then
- minetest.set_node(advtrains.dirCoordSet(pos, conn2), advtrains.trackplacer_dir_to_node_mapping[node2_conn2.."_"..((conn2+4)%8)])
+ if advtrains.trackplacer_dir_to_node_mapping[node2_conn2.."_"..((conn1+8)%16)] then
+ minetest.set_node(advtrains.dirCoordSet(pos, conn2), advtrains.trackplacer_dir_to_node_mapping[node2_conn2.."_"..((conn2+8)%16)])
end
end
end