diff options
| author | orwell96 <orwell@bleipb.de> | 2018-08-12 13:23:36 +0200 |
|---|---|---|
| committer | orwell96 <orwell@bleipb.de> | 2018-08-12 13:23:36 +0200 |
| commit | 6cdb47edd231da08b32b8258eaa507ff312134cd (patch) | |
| tree | 27811fa34404a022b4ab8d8b9105be1a0b810868 /advtrains/helpers.lua | |
| parent | 0d130bb262f25f089d2633479afa0ecee24256e6 (diff) | |
Add routesetting callbacks.
Now, only the signal aspect setting is still missing
Diffstat (limited to 'advtrains/helpers.lua')
| -rw-r--r-- | advtrains/helpers.lua | 10 |
1 files changed, 10 insertions, 0 deletions
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
|
