Add missing mcl_util functions
parent
a8d451c1b0
commit
c8ac243589
|
@ -22,6 +22,13 @@ function table.update_nil(t, ...)
|
|||
return t
|
||||
end
|
||||
|
||||
-- Copies the table then updates
|
||||
function table.merge(t, ...)
|
||||
local t2 = table.copy(t)
|
||||
return table.update(t2, ...)
|
||||
end
|
||||
|
||||
|
||||
---Works the same as `pairs`, but order returned by keys
|
||||
---
|
||||
---Taken from https://www.lua.org/pil/19.3.html
|
||||
|
@ -630,6 +637,21 @@ function mcl_util.replace_mob(obj, mob)
|
|||
return obj
|
||||
end
|
||||
|
||||
|
||||
function mcl_util.traverse_tower(pos, dir, callback)
|
||||
local node = minetest.get_node(pos)
|
||||
local i = 0
|
||||
while minetest.get_node(pos).name == node.name do
|
||||
if callback and callback(pos, dir, node) then
|
||||
return pos,i,true
|
||||
end
|
||||
i = i + 1
|
||||
pos = vector.offset(pos, 0, dir, 0)
|
||||
end
|
||||
return vector.offset(pos, 0, -dir, 0), i
|
||||
end
|
||||
|
||||
|
||||
function mcl_util.get_pointed_thing(player, liquid)
|
||||
local pos = vector.offset(player:get_pos(), 0, player:get_properties().eye_height, 0)
|
||||
local look_dir = vector.multiply(player:get_look_dir(), 5)
|
||||
|
|
Loading…
Reference in New Issue