forked from Mirrorlandia_minetest/mod-sneeker
Add some logging
This commit is contained in:
parent
aa6c19dd82
commit
94c22a5406
22
init.lua
22
init.lua
@ -3,6 +3,28 @@ sneeker = {}
|
||||
sneeker.modname = core.get_current_modname()
|
||||
sneeker.modpath = core.get_modpath(sneeker.modname)
|
||||
|
||||
local debugging = core.settings:get_bool("enable_debug_mods", false)
|
||||
sneeker.log = function(lvl, msg)
|
||||
if lvl == "debug" and not debugging then return end
|
||||
|
||||
if msg == nil then
|
||||
msg = lvl
|
||||
lvl = nil
|
||||
end
|
||||
|
||||
msg = "[" .. sneeker.modname .. "] " .. msg
|
||||
if lvl == "debug" then
|
||||
msg = "[DEBUG]" .. msg
|
||||
lvl = nil;
|
||||
end
|
||||
|
||||
if not lvl then
|
||||
core.log(msg)
|
||||
else
|
||||
core.log(lvl, msg)
|
||||
end
|
||||
end
|
||||
|
||||
local scripts = {
|
||||
"settings",
|
||||
"tnt_function",
|
||||
|
@ -1,4 +1,7 @@
|
||||
|
||||
# Extra debugging messages.
|
||||
enable_debug_mods (Mod debugging) bool false
|
||||
|
||||
# Sets possibility for spawn.
|
||||
#
|
||||
# Rate is the inverted value (e.g. 1/value).
|
||||
|
14
spawn.lua
14
spawn.lua
@ -10,6 +10,12 @@ if core.global_exists("nether") then
|
||||
table.insert(spawn_nodes, "nether:rack")
|
||||
end
|
||||
|
||||
for _, node_name in ipairs(spawn_nodes) do
|
||||
if not core.registered_nodes[node_name] then
|
||||
sneeker.log("warning", "Invalid node for spawn: " .. node_name)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
core.register_abm({
|
||||
nodenames = spawn_nodes,
|
||||
@ -40,6 +46,12 @@ core.register_abm({
|
||||
return
|
||||
end
|
||||
|
||||
core.add_entity(pos, "sneeker:sneeker")
|
||||
local spawned = core.add_entity(pos, "sneeker:sneeker")
|
||||
if not spawned then
|
||||
sneeker.log("warning", "Failed to spawn at: "
|
||||
.. tostring(math.floor(pos.x))
|
||||
.. "," .. tostring(math.floor(pos.y))
|
||||
.. "," .. tostring(math.floor(pos.z)))
|
||||
end
|
||||
end
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user