From 2e3fcebd0ed4e9d18bab169a0f80af8317a79b76 Mon Sep 17 00:00:00 2001 From: OgelGames Date: Wed, 13 Jan 2021 21:48:08 +1100 Subject: [PATCH] fix travelnet compat --- compat/travelnet.lua | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/compat/travelnet.lua b/compat/travelnet.lua index 660bf3b..78e45fd 100644 --- a/compat/travelnet.lua +++ b/compat/travelnet.lua @@ -1,20 +1,26 @@ -minetest.override_item("travelnet:travelnet", { - on_movenode = function(from_pos, to_pos) - local meta = minetest.get_meta(to_pos); - minetest.log("action", "[jumpdrive] Restoring travelnet @ " .. to_pos.x .. "/" .. to_pos.y .. "/" .. to_pos.z) +minetest.register_on_mods_loaded(function() + for node, def in pairs(minetest.registered_nodes) do + if def.groups and def.groups.travelnet == 1 then + minetest.override_item(node, { + on_movenode = function(from_pos, to_pos) + local meta = minetest.get_meta(to_pos); + minetest.log("action", "[jumpdrive] Restoring travelnet @ " .. to_pos.x .. "/" .. to_pos.y .. "/" .. to_pos.z) - local owner_name = meta:get_string( "owner" ); - local station_name = meta:get_string( "station_name" ); - local station_network = meta:get_string( "station_network" ); + local owner_name = meta:get_string( "owner" ); + local station_name = meta:get_string( "station_name" ); + local station_network = meta:get_string( "station_network" ); - if (travelnet.targets[owner_name] - and travelnet.targets[owner_name][station_network] - and travelnet.targets[owner_name][station_network][station_name]) then - travelnet.targets[owner_name][station_network][station_name].pos = to_pos + if (travelnet.targets[owner_name] + and travelnet.targets[owner_name][station_network] + and travelnet.targets[owner_name][station_network][station_name]) then + travelnet.targets[owner_name][station_network][station_name].pos = to_pos + end + end + }) end end -}) +end) jumpdrive.register_after_jump(function() if travelnet.save_data ~= nil then