From b78748e49ff29285bcb4f4aacdb1e86300648108 Mon Sep 17 00:00:00 2001 From: ak399 Date: Mon, 9 Sep 2013 17:04:00 -0400 Subject: [PATCH] add loose_code file --- loose_code.lua | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 loose_code.lua diff --git a/loose_code.lua b/loose_code.lua new file mode 100644 index 0000000..f10eda2 --- /dev/null +++ b/loose_code.lua @@ -0,0 +1,40 @@ +--Code in here will have notes as to it's implementation. DO NOT USE THIS AS A STANDALONE FILE. + +-- +-- CHAT COMMANDS: +-- Put these in minetest/builtin/chatcommands.lua. +-- + +--add gettime +function round(num, idp) + local mult = 10^(idp or 0) + return math.floor(num * mult + 0.5) / mult +end + +minetest.register_chatcommand("gettime", { + params = "", + description = "print current time of day", + privs = {shout=true}, + func = function(name, param) + minetest.chat_send_player(name, "It is " .. (round(minetest.env:get_timeofday() * 24,2)) .. " o'clock") + end, +}) +--end addition + +--add respawn +minetest.register_chatcommand("respawn", { + params = "", + privs = {}, + description = "Respawn", + func = function(name, param) + local player = minetest.env:get_player_by_name(name) + if not player then + return + else + minetest.chat_send_all(name.." respawned.") + player:set_hp(0) + end + end +}) + +--end addition