aboutsummaryrefslogtreecommitdiff
path: root/advtrains_trackmap
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2023-05-14 15:22:59 +0200
committerorwell96 <orwell@bleipb.de>2023-05-27 12:26:15 +0200
commit8371d8496a0423d992c29f38c59265a5d6f8517a (patch)
tree5cd742ebf2febac87d89df5664fb5e8975c1e5db /advtrains_trackmap
parentbc8c04d146cea83e6b7c6e63c1778abff6cd0b68 (diff)
downloadadvtrains-8371d8496a0423d992c29f38c59265a5d6f8517a.tar.gz
advtrains-8371d8496a0423d992c29f38c59265a5d6f8517a.tar.bz2
advtrains-8371d8496a0423d992c29f38c59265a5d6f8517a.zip
Fix map, fix train placing
Diffstat (limited to 'advtrains_trackmap')
-rw-r--r--advtrains_trackmap/grid.lua11
-rw-r--r--advtrains_trackmap/viewer.lua6
2 files changed, 8 insertions, 9 deletions
diff --git a/advtrains_trackmap/grid.lua b/advtrains_trackmap/grid.lua
index 9f367cb..d679bd6 100644
--- a/advtrains_trackmap/grid.lua
+++ b/advtrains_trackmap/grid.lua
@@ -10,9 +10,9 @@ local TS_MAX_SCAN = 1000
-- The characters will be chosen from the unicode frame set if appropriate
-- valid character classes -, =, |
local char_equiv = {
- ["-"] = {"│", "/", "─", "\\"}, -- single-line
- ["="] = {"║", "/", "═", "\\"}, -- double-line
- ["|"] = {"─", "\\", "│", "/"}, -- break (i.e. TCB, perpendicular to orientation)
+ ["-"] = {"│", "/", "─", "\\\\"}, -- single-line
+ ["="] = {"║", "/", "═", "\\\\"}, -- double-line
+ ["|"] = {"─", "\\\\", "│", "/"}, -- break (i.e. TCB, perpendicular to orientation)
}
local dir_to_charmap = {
[15] = 1,
@@ -33,6 +33,7 @@ local dir_to_charmap = {
[14] = 4,
}
function tm.rotate_char_class_by_conn(chr, conndir)
+ atdebug("rotatechar", chr, conndir, "dircharmap", dir_to_charmap[conndir], "charequiv", char_equiv[chr])
return char_equiv[chr][dir_to_charmap[conndir]]
end
@@ -62,14 +63,16 @@ function tm.generate_grid_map(start_pos, node_callback)
local ok, conns = advtrains.get_rail_info_at(pos)
local c = node_callback(pos, conns, connid)
local chr = c and c.char
+ atdebug("init",pos.x,pos.z,chr,"")
if not chr then
- chr = tm.rotate_char_class_by_conn("=", conns[connid])
+ chr = tm.rotate_char_class_by_conn("=", conns[connid].c)
end
-- add the char to the grid
if not grid[pos.x] then
grid[pos.x] = {}
end
+ atdebug("final",pos.x,pos.z,chr,"")
grid[pos.x][pos.z] = chr
gminx = math.min(gminx, pos.x)
diff --git a/advtrains_trackmap/viewer.lua b/advtrains_trackmap/viewer.lua
index d1921d8..7752991 100644
--- a/advtrains_trackmap/viewer.lua
+++ b/advtrains_trackmap/viewer.lua
@@ -15,7 +15,7 @@ local function node_left_click(pos, pname)
end
local gridtbl = tm.generate_grid_map(pos, node_callback)
- local fslabel = tm.render_grid(gridtbl.grid, gridtbl.min_pos, 100, 100)
+ local fslabel = tm.render_grid(gridtbl.grid, {x=pos.x-30, z=pos.z-25}, 60, 50)
minetest.show_formspec(pname, "advtrains_trackmap:test", "size[20,20]"..fslabel)
end
@@ -32,10 +32,6 @@ minetest.register_craftitem("advtrains_trackmap:tool",{
if not pname then
return
end
- if not minetest.check_player_privs(pname, {interlocking=true}) then
- minetest.chat_send_player(pname, "Insufficient privileges to use this!")
- return
- end
if pointed_thing.type=="node" then
local pos=pointed_thing.under
node_left_click(pos, pname)