aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--advtrains_interlocking/database.lua3
-rw-r--r--advtrains_interlocking/train_sections.lua4
-rw-r--r--advtrains_trackmap/grid.lua11
-rw-r--r--advtrains_trackmap/viewer.lua6
4 files changed, 12 insertions, 12 deletions
diff --git a/advtrains_interlocking/database.lua b/advtrains_interlocking/database.lua
index 35afc8d..551d21a 100644
--- a/advtrains_interlocking/database.lua
+++ b/advtrains_interlocking/database.lua
@@ -267,7 +267,8 @@ function ildb.check_and_repair_ts_at_pos(pos, tcb_connid)
if ildb.get_tcb(pos) then
if not tcb_connid then error("check_and_repair_ts_at_pos: Startpoint is TCB, must provide tcb_connid!") end
else
- if tcb_connid then error("check_and_repair_ts_at_pos: Startpoint is not TCB, must not provide tcb_connid!") end
+ --if tcb_connid then error("check_and_repair_ts_at_pos: Startpoint is not TCB, must not provide tcb_connid!") end
+ -- do not give error here, for some applications do not require it
end
-- STEP 1: Ensure that only one section is at this place
-- get all TCBs adjacent to this
diff --git a/advtrains_interlocking/train_sections.lua b/advtrains_interlocking/train_sections.lua
index 757f36a..47072dc 100644
--- a/advtrains_interlocking/train_sections.lua
+++ b/advtrains_interlocking/train_sections.lua
@@ -167,13 +167,13 @@ advtrains.te_register_on_create(function(id, train)
-- let's see what track sections we find here
local index = atround(train.index)
local pos = advtrains.path_get(train, index)
- local ts_id, origin = ildb.get_ts_at_pos(pos)
+ local ts_id = ildb.check_and_repair_ts_at_pos(pos, 1) -- passing connid 1 - that always exists
if ts_id then
local ts = ildb.get_ts(ts_id)
if ts then
setsection(id, train, ts_id, ts, origin)
else
- atwarn("ILDB corruption: TCB",origin," has invalid TS reference")
+ atwarn("While placing train, TS didnt exist ",ts_id)
end
-- Make train a shunt move
train.is_shunt = true
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)