aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/atc.lua2
-rw-r--r--advtrains/helpers.lua10
-rw-r--r--advtrains/init.lua2
3 files changed, 12 insertions, 2 deletions
diff --git a/advtrains/atc.lua b/advtrains/atc.lua
index 480c043..8e23205 100644
--- a/advtrains/atc.lua
+++ b/advtrains/atc.lua
@@ -194,7 +194,7 @@ local matchptn={
return #match+1
end,
["R"]=function(id, train)
- if train.velocity<=0 then
+ if train.velocity<=0 then --TODO this code still uses movedir
train.movedir=train.movedir*-1
train.atc_arrow = not train.atc_arrow
else
diff --git a/advtrains/helpers.lua b/advtrains/helpers.lua
index 2160444..c91af34 100644
--- a/advtrains/helpers.lua
+++ b/advtrains/helpers.lua
@@ -339,3 +339,13 @@ function advtrains.roundfloorpts(pos)
return minetest.pos_to_string(advtrains.round_vector_floor_y(pos))
end
+-- insert an element into a table if it does not yet exist there
+-- equalfunc is a function to compare equality, defaults to ==
+-- returns true if the element was inserted
+function advtrains.insert_once(tab, elem, equalfunc)
+ for _,e in pairs(tab) do
+ if equalfunc and equalfunc(elem, e) or e==elem then return false end
+ end
+ tab[#tab+1] = elem
+ return true
+end
diff --git a/advtrains/init.lua b/advtrains/init.lua
index 4559dfe..cf9d261 100644
--- a/advtrains/init.lua
+++ b/advtrains/init.lua
@@ -70,7 +70,7 @@ function advtrains.print_concat_table(a)
if t.x and t.y and t.z then
str=str..minetest.pos_to_string(t)
elseif t.p and t.s then -- interlocking sigd
- str=str.."("..t.p.."/"..t.s..")"
+ str=str.."("..minetest.pos_to_string(t.p).."/"..t.s..")"
else
str=str..dump(t)
end