From 882108e8bf714200348bed2bd79b7f01ab6ffe7f Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Sat, 31 Aug 2024 22:58:38 +0800 Subject: Alias for wagon types --- advtrains/wagons.lua | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3