This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Luca_S's profile picture

Get real time in CC

Started by Luca_S, 22 November 2015 - 10:45 AM
Luca_S #1
Posted 22 November 2015 - 11:45 AM
Hello there,

I created a little PHP script and a little CC API to get the real time. It is really simple.

Downloads:
The API (Pastebin: UW2Pf1UW)
An example (Pastebin: TXWzqCbv)

Here's how to use it(Assuming it is loaded in as "timeapi")
Spoiler

--get UTC time
local hours,minutes,seconds = timeapi.getTime()
--get UTC + 4 time
local hours,minutes,seconds = timeapi.getTime(4)
--get UTC - 1 time
local hours,minutes,seconds = timeapi.getTime(-1)
--get UTC 9 1/4 time
local hours,minutes,seconds = timeapi.getTime(9,15)
--get UTC -3 1/2 time
local hours,minutes,seconds = timeapi.getTime(-3,-30)
If you take a look at the output of the web PHP script you will see that it also gives back the date, if you want you can code your own API which also contains getting the date.

If you want I will publish the source code of the PHP script.

If you think this is useful or you have something I could improve, tell me!

Luca_S
Creator #2
Posted 22 November 2015 - 11:59 AM
Probably the shortest API on the forums. Still pretty useful.
Luca_S #3
Posted 04 December 2015 - 04:29 PM
Probably the shortest API on the forums. Still pretty useful.
Thanks, but it is not the shortest :P/>
http://www.computercraft.info/forums2/index.php?/topic/24726-cc-sound-not-a-mod-mp3s-in-cc/page__hl__music__fromsearch__1