Fix map, fix train placing
This commit is contained in:
parent
bc8c04d146
commit
8371d8496a
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue