Jump to content
The simFlight Network Forums

Recommended Posts

Posted

I'm trying to make a lua script that checks the FSX time against the current UTC time and then sets the FSX time to the real UTC time if it isn't already there. So, for example, if I load the default flight and set the time to "dusk" and that UTC time is not accurate, it will update the time to the current UTC time. 

 

This is the first time I have ever touched LUA, so I don't know what I am doing. The only programming I have done is in PHP. I came up with this after some googling, but it isn't working, so I am trying to figure out what I am doing wrong. Any help is appreciated!

-- FSX UTC Time Synch
-- Novbember 2015
-- V 1.0

-- ## Sets FSX Time to UTC ###############

while 1 do

   simHour = ipc.readUB("023B")
   simMinute = ipc.readUB("023c")

   Hour = os.date("!%H")
   Minute = os.date("!%M")

if simHour ~= Hour
	then  
	ipc.writeUB("023B", Hour)
end

if simMinute ~= Minute
	then
    ipc.writeUB("023c", Minute)
end

ipc.sleep(120)
end
  • 4 weeks later...
Posted

What actually happens, then? Have you tried sing the Lua debug/trace option (in the FSUIPC Logging tab). That should show what is happening.

 

Generally, though, to change the time in FS reliably (keeping the correct difference between UTC and Local Time), I suspect you may need to write the local time, either instead or as well, and maybe also even the difference (offset 0246), even if it isn't changed.

 

Note that any time change which does affect anything other than the seconds will cause the sim to reload scenery texturing and so on, so produce a noticeable stutter. If FS's time is running slightly slower or faster than you PCs clock this will happen regularly.

 

Pete

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.