Page 1 of 1
Getting system time in gadgets (unsynced)
Posted: 01 Mar 2010, 14:21
by Tribulex
I need to get the system time in an unsynced gadget. System.time doesnt work so how can i do it?
Re: Getting system time in gadgets (unsynced)
Posted: 01 Mar 2010, 15:40
by slogic
Try os.date(), os.time().
Re: Getting system time in gadgets (unsynced)
Posted: 01 Mar 2010, 15:54
by zwzsg
Keep in mind that due to the limited precision of Lua numbers, os.time() is rounded to the nearest dozen seconds.
Use Spring.GetTimer() and Spring.DiffTimers(timer,timer) if you need precision.
Use os.date(..) if you need a formatted string showing current time.
Re: Getting system time in gadgets (unsynced)
Posted: 01 Mar 2010, 18:21
by Tribulex
yeah thats what i mean os.time throws errors in gadgets.
Re: Getting system time in gadgets (unsynced)
Posted: 01 Mar 2010, 18:32
by zwzsg
In synced gadget, that's normal: The clocks of all the computers aren't synced, so os.time is disabled so you don't cause desyncs by using it. In unsynced gadget, I don't know if I ever tried, but that's still not what I meant.
Re: Getting system time in gadgets (unsynced)
Posted: 01 Mar 2010, 20:33
by Tribulex
unsynced gadget. Yes synced makes sense, but why not unsynced. I dont really want to make this a widget.
Re: Getting system time in gadgets (unsynced)
Posted: 03 Mar 2010, 17:44
by lurker
Either get somebody to add some of the widget calls to unsynced or possibly make a widget do it.
I think the game ID has a timestamp embedded in it, and there might be other functions that can return a timestamp.
Re: Getting system time in gadgets (unsynced)
Posted: 05 Mar 2010, 04:43
by Tribulex
ya i forgot about this. Ill have to check what i did in my music gadget