Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Converting Time from ScenEdit_CurrentTime ()

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Converting Time from ScenEdit_CurrentTime () Page: [1]
Login
Message << Older Topic   Newer Topic >>
Converting Time from ScenEdit_CurrentTime () - 7/15/2016 8:02:45 PM   
wqc12345


Posts: 250
Joined: 12/7/2015
From: San Francisco, CA
Status: offline
Does anyone have a good function to convert time to something readable from ScenEdit_CurrentTime ()?

>> time=ScenEdit_CurrentTime ()
print(time)
1467403200

That above number could be converted using a lua lib, but you can't import this into CMANO?

Any ideas?
Post #: 1
RE: Converting Time from ScenEdit_CurrentTime () - 7/16/2016 4:53:35 AM   
michaelm75au


Posts: 13472
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
Try this.

(a) You can either load the contents and add to your LUA script.
To test, run this after copying the contents of the file:
local t=os.time()
local tt=gmtime(t)
print(string.format('%02.2d%02.2d%02.2dZ %s %02.2d', tt.hour, tt.minute, tt.seconds, monm[tt.month], tt.day))
t=ScenEdit_CurrentTime()
local tt=gmtime(t)
print(string.format('%02.2d%02.2d%02.2dZ %s %02.2d', tt.hour, tt.minute, tt.seconds, monm[tt.month], tt.day))


(b) Or set up the attachment as a loadable LUA function. By this I mean,
1. copy the attachment to the directory <command directory>/Lua.
2. add to some startup script (loads the function into current game)
ScenEdit_RunScript('lua date function.txt')
3. use the function 'gmtime()' at any time in your scripts.
local monm={
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
}
local t=os.time()
local tt=gmtime(t)
print(string.format('%02.2d%02.2d%02.2dZ %s %02.2d', tt.hour, tt.minute, tt.seconds, monm[tt.month], tt.day))
t=ScenEdit_CurrentTime()
local tt=gmtime(t)
print(string.format('%02.2d%02.2d%02.2dZ %s %02.2d', tt.hour, tt.minute, tt.seconds, monm[tt.month], tt.day))


Hope this is helpful

Attachment (1)

< Message edited by michaelm -- 7/16/2016 5:39:46 AM >


_____________________________

Michael

(in reply to wqc12345)
Post #: 2
RE: Converting Time from ScenEdit_CurrentTime () - 7/16/2016 5:39:44 AM   
michaelm75au


Posts: 13472
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
To test (b) in the Command's console, copy the attachment to the LUA directory mentioned and paste the following:
ScenEdit_RunScript('lua date function.txt')
local monm={
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
}
local t=os.time()
local tt=gmtime(t)
print(string.format('%02.2d%02.2d%02.2dZ %s %02.2d', tt.hour, tt.minute, tt.seconds, monm[tt.month], tt.day))
t=ScenEdit_CurrentTime()
local tt=gmtime(t)
print(string.format('%02.2d%02.2d%02.2dZ %s %02.2d', tt.hour, tt.minute, tt.seconds, monm[tt.month], tt.day))


The out put is the current date/time and the current game date/time as ZULU time
-------------------
044255Z Jul 16
043819Z Jul 16

< Message edited by michaelm -- 7/16/2016 5:45:10 AM >


_____________________________

Michael

(in reply to michaelm75au)
Post #: 3
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Converting Time from ScenEdit_CurrentTime () Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.190