mirror of
https://github.com/joe7575/tubelib2.git
synced 2024-10-05 17:33:11 +02:00
v2.1, Add API functions 'register_on_tube_update2'
This commit is contained in:
parent
27cd9ce11e
commit
bb15c122f1
@ -88,5 +88,6 @@ Textures: CC0
|
|||||||
- 2020-02-02 v1.8 * 'special nodes' as alternative to 'secondary nodes' introduced
|
- 2020-02-02 v1.8 * 'special nodes' as alternative to 'secondary nodes' introduced
|
||||||
- 2020-05-31 v1.9 * Generator function 'get_tube_line' added, storage improvements
|
- 2020-05-31 v1.9 * Generator function 'get_tube_line' added, storage improvements
|
||||||
- 2021-01-23 v2.0 * Add functions for easy & fast 'valid side' checking (PR #8)
|
- 2021-01-23 v2.0 * Add functions for easy & fast 'valid side' checking (PR #8)
|
||||||
|
- 2021-05-24 v2.1 * Add API functions 'register_on_tube_update2'
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,8 +102,12 @@ function Tube:update_secondary_node(pos1, dir1, pos2, dir2)
|
|||||||
local node,_ = self:get_secondary_node(pos1)
|
local node,_ = self:get_secondary_node(pos1)
|
||||||
if node then
|
if node then
|
||||||
local ndef = minetest.registered_nodes[node.name] or {}
|
local ndef = minetest.registered_nodes[node.name] or {}
|
||||||
|
-- New functions
|
||||||
if ndef.tubelib2_on_update2 then
|
if ndef.tubelib2_on_update2 then
|
||||||
ndef.tubelib2_on_update2(pos1, dir1, self, node)
|
ndef.tubelib2_on_update2(pos1, dir1, self, node)
|
||||||
|
elseif self.clbk_update_secondary_node2 then
|
||||||
|
self.clbk_update_secondary_node2(pos1, dir1, self, node)
|
||||||
|
-- Legacy functions
|
||||||
elseif ndef.tubelib2_on_update then
|
elseif ndef.tubelib2_on_update then
|
||||||
ndef.tubelib2_on_update(node, pos1, dir1, pos2, Turn180Deg[dir2])
|
ndef.tubelib2_on_update(node, pos1, dir1, pos2, Turn180Deg[dir2])
|
||||||
elseif self.clbk_update_secondary_node then
|
elseif self.clbk_update_secondary_node then
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
]]--
|
]]--
|
||||||
|
|
||||||
-- Version for compatibility checks, see readme.md/history
|
-- Version for compatibility checks, see readme.md/history
|
||||||
tubelib2.version = 2.0
|
tubelib2.version = 2.1
|
||||||
|
|
||||||
-- for lazy programmers
|
-- for lazy programmers
|
||||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||||
@ -320,6 +320,12 @@ function Tube:register_on_tube_update(update_secondary_node)
|
|||||||
self.clbk_update_secondary_node = update_secondary_node
|
self.clbk_update_secondary_node = update_secondary_node
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Called for each connected node when the tube connection has been changed.
|
||||||
|
-- func(pos1, out_dir, self, node)
|
||||||
|
function Tube:register_on_tube_update2(update_secondary_node2)
|
||||||
|
self.clbk_update_secondary_node2 = update_secondary_node2
|
||||||
|
end
|
||||||
|
|
||||||
function Tube:get_pos(pos, dir)
|
function Tube:get_pos(pos, dir)
|
||||||
return vector.add(pos, Dir6dToVector[dir or 0])
|
return vector.add(pos, Dir6dToVector[dir or 0])
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user