2017-01-12 23:58:42 +01:00
|
|
|
-- register extra flavours of a base nodedef
|
2021-03-16 11:07:17 +01:00
|
|
|
|
|
|
|
local get_connected_players = minetest.get_connected_players
|
|
|
|
local get_node = minetest.get_node
|
2022-01-20 22:55:36 +01:00
|
|
|
local vector = vector
|
2021-03-16 11:22:13 +01:00
|
|
|
local ceil = math.ceil
|
2021-05-29 16:12:33 +02:00
|
|
|
local pairs = pairs
|
2021-03-16 11:07:17 +01:00
|
|
|
|
2020-11-05 16:05:42 +01:00
|
|
|
walkover = {}
|
|
|
|
|
2021-03-16 11:07:17 +01:00
|
|
|
local on_walk = {}
|
|
|
|
local registered_globals = {}
|
|
|
|
|
2022-01-20 22:55:36 +01:00
|
|
|
walkover.registered_globals = registered_globals
|
|
|
|
|
|
|
|
function walkover.register_global(func)
|
|
|
|
table.insert(registered_globals, func)
|
|
|
|
end
|
|
|
|
|
2021-03-16 11:07:17 +01:00
|
|
|
minetest.register_on_mods_loaded(function()
|
|
|
|
for name,def in pairs(minetest.registered_nodes) do
|
|
|
|
if def.on_walk_over then
|
|
|
|
on_walk[name] = def.on_walk_over
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2017-01-12 23:58:42 +01:00
|
|
|
local timer = 0
|
|
|
|
minetest.register_globalstep(function(dtime)
|
2022-01-20 22:55:36 +01:00
|
|
|
timer = timer + dtime
|
2022-07-26 15:21:56 +02:00
|
|
|
if timer >= 0.6 then
|
2022-01-20 22:55:36 +01:00
|
|
|
for _, player in pairs(get_connected_players()) do
|
|
|
|
local ppos = player:get_pos()
|
2022-07-26 15:16:14 +02:00
|
|
|
local npos = vector.add(ppos, vector.new(0, -0.1, 0))
|
2022-01-20 22:55:36 +01:00
|
|
|
if npos then
|
|
|
|
local node = get_node(npos)
|
|
|
|
if node then
|
|
|
|
if on_walk[node.name] then
|
|
|
|
on_walk[node.name](npos, node, player)
|
2021-05-25 00:55:14 +02:00
|
|
|
end
|
|
|
|
for i = 1, #registered_globals do
|
2022-01-20 22:55:36 +01:00
|
|
|
registered_globals[i](npos, node, player)
|
2021-05-25 00:55:14 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-01-12 23:58:42 +01:00
|
|
|
timer = 0
|
|
|
|
end
|
|
|
|
end)
|