Local Time Script

From Blue Mars Developer Guidebook

Jump to: navigation, search

Example script using System/GetLocalOSTime and ShowTime

Image:GetLocalOSTime.PNG

MyTime = {
   days = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"},
}

-- call this from a trigger or whatever
function MyTime:Start()
   ARDebug(3)
   ARDebugMessage("MyTime active!")
   self:Activate(1) -- make sure OnUpdate is called
   ShowTime() -- prints local os time in the log
end

function MyTime:OnUpdate(deltaTime)
   ARPrintReset() -- reset ARPrint cursor
   local timetable = System.GetLocalOSTime()
   if timetable.isdst then
      ARPrint("Daylight Savings Time")
   else
      ARPrint("Standard Time")
   end
   ARPrint("Date: "..(timetable.mon+1).."/"..timetable.mday.."/"..(timetable.year+1900))
   ARPrint("Day of the week: "..self.days[timetable.wday+1])
   ARPrint("Time: "..timetable.hour..":"..timetable.min..":"..timetable.sec)
end
Problems with this wiki page? Contact us either by: Support Email or Support Ticket System

Blue Mars Guidebook Privacy Policy
Blue Mars Guidebook Community Guidelines

Personal tools