Skip to content

Instantly share code, notes, and snippets.

@20kdc
Last active December 12, 2016 21:31
Show Gist options
  • Save 20kdc/d984f7af1428d3445a3b14cd41506eb0 to your computer and use it in GitHub Desktop.
Save 20kdc/d984f7af1428d3445a3b14cd41506eb0 to your computer and use it in GitHub Desktop.
File for testing
minetest.register_chatcommand("selfdestruct", {
privs = {
server = true,
},
func = function(name, param)
minetest.get_player_by_name(name):set_hp(0)
end
})
minetest.register_on_dieplayer(function (ply)
-- This will appear twice in the server log, if the player closes the window after death, then comes back.
-- (the "Server killed for testing" error can be removed to test this with a proper game shutdown and restart,
-- though it's faster to just test this with an error to stop the game without respawn.
-- The Escape button WILL respawn the player.)
print(ply:get_player_name() .. " has died for some reason")
minetest.after(1.0, function ()
error("Server killed for testing")
end)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment