summaryrefslogtreecommitdiff
path: root/src/util/pointedthing.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/pointedthing.cpp')
0 files changed, 0 insertions, 0 deletions
='#n58'>58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
-- Minetest: builtin/misc.lua

--
-- Misc. API functions
--

core.timers_to_add = {}
core.timers = {}
core.register_globalstep(function(dtime)
	for _, timer in ipairs(core.timers_to_add) do
		table.insert(core.timers, timer)
	end
	core.timers_to_add = {}
	local index = 1
	while index <= #core.timers do
		local timer = core.timers[index]
		timer.time = timer.time - dtime
		if timer.time <= 0 then
			timer.func(unpack(timer.args or {}))
			table.remove(core.timers,index)
		else
			index = index + 1
		end
	end
end)

function core.after(time, func, ...)
	assert(tonumber(time) and type(func) == "function",
			"Invalid core.after invocation")
	table.insert(core.timers_to_add, {time=time, func=func, args={...}})
end

function core.check_player_privs(name, privs)
	local player_privs = core.get_player_privs(name)
	local missing_privileges = {}
	for priv, val in pairs(privs) do
		if val then
			if not player_privs[priv] then