Galactic Time and Scripting

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Post Reply
User avatar
PhantorGorth
---- E L I T E ----
---- E L I T E ----
Posts: 647
Joined: Wed May 20, 2009 6:48 pm
Location: Somewhere off the top left of Galaxy 1 map

Galactic Time and Scripting

Post by PhantorGorth »

Is there a way to get the current Galactic Mean Time via Javascript?

I have searched both the wiki and the board and can not find anything on this. (This maybe because the appropriate search terms are bringing up too many false hits for me to wade through though.)
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

Yes, there is a set of JS functions and properties to access the clock both as full string format and as its individual elements. Here is an example of how to use it:

Code: Select all

this.clockReport = function()
{
	log("clockReport.begin","---------------------------------------------------");
	log("clockReport.absoluteSeconds", clock.absoluteSeconds);
	log("clockReport.seconds", clock.seconds);
	log("clockReport.minutes", clock.minutes);
	log("clockReport.hours", clock.hours);
	log("clockReport.days", clock.days);
	log("clockReport.secondsComponent", clock.secondsComponent);
	log("clockReport.minutesComponent", clock.minutesComponent);
	log("clockReport.hoursComponent", clock.hoursComponent);
	log("clockReport.daysComponent", clock.daysComponent);
	log("clockReport.clockString", clock.clockString);
	log("clockReport.isAdjusting", clock.isAdjusting);
	log("clockReport.end", "-----------------------------------------------------");
}
This produces the following output in the log:
Latest.log wrote:
[clockReport.begin]: ---------------------------------------------------
[clockReport.absoluteSeconds]: 5.822000026702881
[clockReport.seconds]: 180058011442.82214
[clockReport.minutes]: 3000966857
[clockReport.hours]: 50016114
[clockReport.days]: 2084004
[clockReport.secondsComponent]: 22
[clockReport.minutesComponent]: 17
[clockReport.hoursComponent]: 18
[clockReport.daysComponent]: 2084004
[clockReport.clockString]: 2084004:18:17:22
[clockReport.isAdjusting]: false
[clockReport.end]: -----------------------------------------------------
User avatar
PhantorGorth
---- E L I T E ----
---- E L I T E ----
Posts: 647
Joined: Wed May 20, 2009 6:48 pm
Location: Somewhere off the top left of Galaxy 1 map

Post by PhantorGorth »

Thanks, precisely what I need.

Now I know what it is called I can see it is in the wiki.

Regards,

PhantorGorth
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

And before anybody else asks: Look no further than

http://wiki.alioth.net/index.php/Oolite ... nce:_Clock
Post Reply