So, about the /time command...

User avatar
bdjnk
Member
 
Posts: 104
Joined: Wed Mar 20, 2013 21:03
GitHub: bdjnk

So, about the /time command...

by bdjnk » Thu Jun 20, 2013 12:54

I was talking to PilzAdam in IRC about the /time command. I found it unintuitive and he was arguing its merits.

Anyway, it got me thinking, how do other people feel about the /time command? If you haven't used it, give it a try. If you have trouble figuring it, maybe read the server commands documentation and try again.

Now that you've experienced it, how do you feel?
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Thu Jun 20, 2013 13:02

It is basically entering 24 hour clock.time.

Ie noon is 12000 (notice extra zero)
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

by Sokomine » Thu Jun 20, 2013 18:22

Most of the time, I just do /time 6000 to get day again. I usually forget to stop the time in my worlds. I'd say the /time command works pretty well, while the setting of the length of a day is not intuitive.
A list of my mods can be found here.
 

User avatar
bdjnk
Member
 
Posts: 104
Joined: Wed Mar 20, 2013 21:03
GitHub: bdjnk

by bdjnk » Thu Jun 20, 2013 20:26

Hm, I guess, based on the results so far, that my feelings about it are mostly not shared by others.

I felt like the expected behavior was that the hour should be the most significant data entered. Thus if I entered a 21, it should consider that as 21:00. Minutes would be next in significance, so if I entered 1245 it would translate directly to 12:45.

In fact, I thought this made so much sense that I wrote a line to make it work. I thought maybe it should made the default, but if most people are happy I'll just post the line so the few who aren't can use it.

If you want to try it, change chatcommands.lua (found in the builtin directory) to look like this:

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
minetest.register_chatcommand("time", {
...
    else
      newtime = newtime * 10 ^ (5 - #string.match(param, "%S.*%S"))
      minetest.set_timeofday((newtime % 24000) / 24000)
...


The added line takes the number and pads it with zeros on the right to make it 5 digits.

p.s. This change means a leading zero is required for times < 10:00. For instance setting the time to 6:00 requires an 06.
 

User avatar
bdjnk
Member
 
Posts: 104
Joined: Wed Mar 20, 2013 21:03
GitHub: bdjnk

by bdjnk » Sat Jun 29, 2013 03:55

I've made /time even more intuitive (at least for me) by using even / odd number length to determine whether I've received a single or double digit hour. This obviates the need to include a leading zero (unless you're setting the time to 0:xx).

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
minetest.register_chatcommand("time", {
        ...
        if newtime == nil or newtime < 0 or newtime > 24000 then
            minetest.chat_send_player(name, "Invalid time")
        else
            local length = #string.match(param, "^%s*(.-)%s*$")
            local exponent = length % 2 == 0 and 5 - length or 4 - length
            newtime = newtime * 10 ^ exponent
            minetest.set_timeofday((newtime % 24000) / 24000)
            ...
        end
    end,
})
 


Return to Minetest General

Who is online

Users browsing this forum: Bing [Bot] and 6 guests