Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
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,
})
It prints:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
It is ##.## o'clock
So instead of looking at the sun or moon, considering we're underground/indoors a lot, knowing the time might be a useful feature. I've implemented it, it works. Removing the "shout=true" would enable it for all users, I'm just too lazy to change that. It'd work without it.