75e66075d0
make the wrapper `blockgame.register_node` make reasonable assumptions that make node registration more convenient. change other code to take advantage of that change. also remove the `blockgame.reg_simple_node` utility since it's now redundant.
45 lines
1 KiB
Lua
45 lines
1 KiB
Lua
local function create_plain_wrapper (function_name)
|
|
local wrapper = function (...)
|
|
--[[
|
|
local args = {...}
|
|
|
|
-- labels will be used later, probably.
|
|
local label = #args > 1 and args[1] or "unlabeled"
|
|
local callback = #args > 1 and args[2] or args[1]
|
|
|
|
minetest[function_name](callback)
|
|
]]--
|
|
minetest[function_name](...)
|
|
end
|
|
|
|
blockgame[function_name] = wrapper
|
|
end
|
|
|
|
for name in pairs({
|
|
register_abm = true,
|
|
register_lbm = true,
|
|
register_on_joinplayer = true,
|
|
register_item = true,
|
|
register_on_placenode = true,
|
|
register_on_dignode = true,
|
|
register_on_punchnode = true,
|
|
register_globalstep = true,
|
|
}) do
|
|
create_plain_wrapper(name)
|
|
end
|
|
|
|
local function capitalize (str)
|
|
return string.upper(string.sub(str, 1, 1)) .. string.sub(str, 2)
|
|
end
|
|
|
|
function blockgame.register_node (name, def)
|
|
local modname = minetest.get_current_modname()
|
|
local full_name = modname .. ":" .. name
|
|
|
|
def.description = def.description or capitalize(name)
|
|
def.tiles = def.tiles or {
|
|
modname .. "_" .. name .. ".png",
|
|
}
|
|
|
|
minetest.register_node(full_name, def)
|
|
end
|