aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author1F616EMO <root@1f616emo.xyz>2024-08-31 22:58:38 +0800
committerorwell <orwell@bleipb.de>2024-09-03 00:04:04 +0200
commit882108e8bf714200348bed2bd79b7f01ab6ffe7f (patch)
treee4b1b17a57380e42788ef097798b9fbda7260332
parentfe7e25c9953dcb4b8bba3dc7bdc94dc232e05ce3 (diff)
downloadadvtrains-882108e8bf714200348bed2bd79b7f01ab6ffe7f.tar.gz
advtrains-882108e8bf714200348bed2bd79b7f01ab6ffe7f.tar.bz2
advtrains-882108e8bf714200348bed2bd79b7f01ab6ffe7f.zip
Alias for wagon typesrelease-2.4.6
-rw-r--r--advtrains/wagons.lua19
1 files changed, 18 insertions, 1 deletions
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index 14bb58a..536c8d4 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -13,7 +13,20 @@ local GETOFF_TP_DELAY = 0.5
local IGNORE_WORLD = advtrains.IGNORE_WORLD
advtrains.wagons = {}
-advtrains.wagon_prototypes = {}
+advtrains.wagon_alias = {}
+advtrains.wagon_prototypes = setmetatable({}, {
+ __index = function(t, k)
+ local rtn_val = rawget(t, k)
+ if rtn_val ~= nil then
+ return rtn_val
+ end
+ local alias = advtrains.wagon_alias[k]
+ if alias then
+ return rawget(t, alias)
+ end
+ return nil
+ end
+})
advtrains.wagon_objects = {}
local unload_wgn_range = advtrains.wagon_load_range + 32
@@ -1326,6 +1339,10 @@ function advtrains.get_wagon_prototype(data)
return wt, advtrains.wagon_prototypes[wt]
end
+function advtrains.register_wagon_alias(src, dst)
+ advtrains.wagon_alias[src] = dst
+end
+
function advtrains.standard_inventory_formspec(self, pname, invname)
--[[minetest.chat_send_player(pname, string.format("self=%s, pname=%s, invname=%s", self, pname, invname))
for k,v in pairs(self) do