Add some logging

This commit is contained in:
Jordan Irwin 2021-05-08 14:46:27 -07:00
parent aa6c19dd82
commit 94c22a5406
3 changed files with 38 additions and 1 deletions

@ -3,6 +3,28 @@ sneeker = {}
sneeker.modname = core.get_current_modname() sneeker.modname = core.get_current_modname()
sneeker.modpath = core.get_modpath(sneeker.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 = { local scripts = {
"settings", "settings",
"tnt_function", "tnt_function",

@ -1,4 +1,7 @@
# Extra debugging messages.
enable_debug_mods (Mod debugging) bool false
# Sets possibility for spawn. # Sets possibility for spawn.
# #
# Rate is the inverted value (e.g. 1/value). # Rate is the inverted value (e.g. 1/value).

@ -10,6 +10,12 @@ if core.global_exists("nether") then
table.insert(spawn_nodes, "nether:rack") table.insert(spawn_nodes, "nether:rack")
end 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({ core.register_abm({
nodenames = spawn_nodes, nodenames = spawn_nodes,
@ -40,6 +46,12 @@ core.register_abm({
return return
end 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 end
}) })