Gettime command

User avatar
ak399g
Member
 
Posts: 160
Joined: Tue Jul 30, 2013 02:36
In-game: SAFR

Gettime command

by ak399g » Mon Sep 09, 2013 03:25

This should be in the default chatcommands.lua:
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.
Last edited by ak399g on Mon Sep 09, 2013 03:27, edited 1 time in total.
aka SAFR
 

Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 12 guests

cron