Skip to content

Commit

Permalink
tp tube api fix
Browse files Browse the repository at this point in the history
fixes #111
  • Loading branch information
BuckarooBanzay committed Jan 12, 2024
1 parent 686e335 commit f1a6529
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
4 changes: 1 addition & 3 deletions compat/compat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ jumpdrive.node_compat = function(name, source_pos, target_pos, source_pos1, sour
end

jumpdrive.commit_node_compat = function()
if has_pipeworks_mod then
jumpdrive.teleporttube_compat_commit()
end
-- Nothing to do here
end


Expand Down
32 changes: 11 additions & 21 deletions compat/teleporttube.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ if not pipeworks.tptube then
minetest.log("warning", "[jumpdrive] pipeworks teleport patch not applied, tp-tubes don't work as expected!")
end

local is_compatible = pipeworks.tptube and pipeworks.tptube.remove_tube
if not is_compatible then
minetest.log("warning", "[jumpdrive] tp-tube api not comptible, consider upgrading the pipeworks mod")
end

-- https://gitlab.com/VanessaE/pipeworks/blob/master/teleport_tube.lua
jumpdrive.teleporttube_compat = function(from, to)
if not pipeworks.tptube then
-- only works with the patch from "./patches/pipeworks.patch"
function jumpdrive.teleporttube_compat(from, to)
if not is_compatible then
return
end

Expand All @@ -32,22 +34,10 @@ jumpdrive.teleporttube_compat = function(from, to)
data.y = to.y
data.z = to.z

db[from_hash] = nil
db[to_hash] = data

end

jumpdrive.teleporttube_compat_commit = function()
if not pipeworks.tptube then
-- only works with the patch from "./patches/pipeworks.patch"
return
end
-- remove source-entry
pipeworks.tptube.remove_tube(from)

pipeworks.tptube.save_tube_db()
-- set target entry
db[to_hash] = data
pipeworks.tptube.save_tube(to_hash)
end


-- load tp tube on start, prevents crashes if the db isn't loaded yet
if pipeworks.tptube and pipeworks.tptube.get_db then
pipeworks.tptube.get_db()
end

0 comments on commit f1a6529

Please sign in to comment.