2017-01-13 00:58:42 +02:00
|
|
|
-- register extra flavours of a base nodedef
|
2021-03-16 12:07:17 +02:00
|
|
|
|
|
|
|
local get_connected_players = minetest.get_connected_players
|
|
|
|
local get_node = minetest.get_node
|
|
|
|
local vector_add = vector.add
|
2021-03-16 12:22:13 +02:00
|
|
|
local ceil = math.ceil
|
2021-03-16 12:07:17 +02:00
|
|
|
|
2020-11-05 17:05:42 +02:00
|
|
|
walkover = {}
|
|
|
|
walkover.registered_globals = {}
|
|
|
|
|
|
|
|
function walkover.register_global(func)
|
|
|
|
table.insert(walkover.registered_globals, func)
|
|
|
|
end
|
|
|
|
|
2021-03-16 12:07:17 +02:00
|
|
|
local on_walk = {}
|
|
|
|
local registered_globals = {}
|
|
|
|
|
|
|
|
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
|
|
|
|
for _,func in ipairs(walkover.registered_globals) do --cache registered globals
|
|
|
|
table.insert(registered_globals, value)
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2017-01-13 00:58:42 +02:00
|
|
|
local timer = 0
|
|
|
|
minetest.register_globalstep(function(dtime)
|
|
|
|
timer = timer + dtime;
|
|
|
|
if timer >= 0.3 then
|
2021-03-16 12:07:17 +02:00
|
|
|
for _,player in ipairs(get_connected_players()) do
|
2019-02-01 07:33:07 +02:00
|
|
|
local pp = player:get_pos()
|
2021-03-16 12:22:13 +02:00
|
|
|
pp.y = ceil(pp.y)
|
2021-03-16 12:07:17 +02:00
|
|
|
local loc = vector_add(pp, {x=0,y=-1,z=0})
|
2017-01-13 00:58:42 +02:00
|
|
|
if loc ~= nil then
|
|
|
|
|
2021-03-16 12:07:17 +02:00
|
|
|
local nodeiamon = get_node(loc)
|
2020-11-05 17:05:42 +02:00
|
|
|
|
2017-01-13 00:58:42 +02:00
|
|
|
if nodeiamon ~= nil then
|
2021-03-16 12:07:17 +02:00
|
|
|
if on_walk[nodeiamon.name] then
|
|
|
|
on_walk[nodeiamon.name](loc, nodeiamon, player)
|
2017-01-13 00:58:42 +02:00
|
|
|
end
|
2021-03-16 12:22:13 +02:00
|
|
|
for i = 1, #registered_globals do
|
|
|
|
registered_globals[i](loc, nodeiamon, player)
|
2020-11-05 17:05:42 +02:00
|
|
|
end
|
2017-01-13 00:58:42 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
timer = 0
|
|
|
|
end
|
|
|
|
end)
|