timestamps - again

Posted by Tsunami on Tue 01 Aug 2006 06:11 PM — 3 posts, 16,602 views.

USA #0
I was looking at a way to retrieve the timestamp using Lua. You can obviously do it with the time() function in the os table, but since this is set to nil by default in the Lua sandbox, I was looking for another way. I looked through the world functions and searched the forums, but couldn't seen to find anything. At the moment the way I have solved this problem is to use the following functions:

world.GetLineInfo(world.GetLinesInBufferCount(),9)

this works fine for my purposes, but is there an easier way I've overlooked? Thanks -Tsunami
Australia Forum Administrator #1
The current Lua sandbox is more liberal:


  -- replace 'os' table with one containing only safe functions
  os = {
       date = os.date,
       time = os.time, 
       setlocale = os.setlocale,
       clock = os.clock, 
       difftime = os.difftime,
       }
 


Thus, you will have os.date and os.time available. However for people who used the earlier sandbox you will have problems.

You could try GetInfo (232) which doesn't give you the date exactly, but a timestamp which is all you need if you want to calculate elapsed time.
Australia Forum Administrator #2
Version 3.78 now has GetInfo (304) - this gives the current date/time.