Jump to content

Recommended Posts

Posted (edited)

I'm writing my own custom flight logger that includes total flight time, total flight distance, and number of successful landings. It all works perfectly fine except for that fact that tracks also write to my log file.

 

Does anyone have an idea how I could be able to distinguish between tracks and SP/MP live missions?

 

One idea I had was to detect any attempt to speed up the track's time and prevent the export from writing to the log, but there are 2 issues with this: 1) SP can also be sped up; and 2) low framerates could be identical to checking frames per game second.

Edited by SilentEagle
Posted (edited)

for anyone that's interested in telling the difference between tracks/singleplayer and multiplayer, the best way i found is this:

 

**EDIT**DOES NOT WORK!!** Apparently, tracks can't be sped up or slowed down using LoSetCommands, only keyboard inputs...

--initializations
u=0  
is_mp=true

function LuaExportStart()
   initial_model_time=LoGetModelTime()
end

function LuaExportAfterNextFrame()
   time = LoGetModelTime()
   if time>initial_model_time+1.0 then
if time<initial_model_time+1.10 then
    LoSetCommand(191) --slows down time every frame
	u=u+1 --frame counter for 1.00 < t < 1.10
end
   end
   if time>initial_model_time+1.10 then
if time<initial_model_time+1.12 then
    LoSetCommand(246) --resumes normal speed
end
   end
   if u>13 then is_mp=false end  --checks whether time was slowed down
end

 

Here, time is monetarily decelerated (if possible) at 1.0 seconds model time, but it is resumed very quickly.

This works because time in multiplayer cannot be accelerated or decelerated, so this checks the number of frames that elapse in a given time period. There is some buffer built into the checks.

Edited by SilentEagle
Posted (edited)

Since the above method didn't work, I came up with a new method that is fail-safe. Will post shortly.

 

**EDIT** Here it is

 

function LuaExportStart()

-------------------------------------
---SP/MP/Track Determination START---
-------------------------------------

file_set=false
is_mp=false
is_sp=false
is_track=false

Year=os.date("%Y")
Month=os.date("%m")
Day=os.date("%d")
Hour=os.date("%H")
Minute=os.date("%M")

Minutes={}
Hours={}
Days={}
Months={}
Years={}

for i=1, 10, 1 do -- allows up to 10 minutes of loading time (10 minutes between mission start and file creation)
Minutes[i]=Minute-i+1
Hours[i]=Hour
Days[i]=Day
Months[i]=Month
Years[i]=Year

--this section backtracks through mins, hours, days, months, and years in case you cross a boundary while loading
if Minutes[i]>-1 and Minutes[i]<10 then  
	Minutes[i]="0"..Minutes[i]			 --lines like this recreate the file name formatting that requires 2 digits for mins, hours, days, and months
elseif Minutes[i]<0 then 
	Minutes[i]=Minutes[i]+60
	Hours[i]=Hour-1
	if Hours[i]>-1 and Hours[i]<10 then
		Hours[i]="0"..Hours[i]
	elseif Hours[i]<0 then
		Hours[i]=23
		Days[i]=Day-1
		if Days[i]>0 and Days[i]<10 then
			Days[i]="0"..Days[i]
		elseif Days[i]<1 then
			if Month == 1 or 2 or 4 or 6 or 9 or 11 then
				Days[i]=31
			elseif Month == 3 then
				Days[i]=28
			else
				Days[i]=30
			end
			Months[i]=Month-1
			if Months[i]>0 and Months[i]<10 then
				Months[i]="0"..Months[i]
			elseif Months[i]<1 then
				Months[i]=12
				Years[i]=Year-1
			end
		end
	end	
end
	
end

file_names = {}
network_files = {}

--this section finds the right network file by checking nearest opening status.  when found, it sets that file as input file
for i=1, 10, 1 do

file_names[i] = "network-"..Years[i]..Months[i]..Days[i].."-"..Hours[i]..Minutes[i].."."

network_files[i] = io.open("./Temp/"..file_names[i].."log", "r")

if file_set==false then
	if network_files[i] then
		io.input(network_files[i])
		file_set=true
	end
end	

end

--this section reads in the first 10 lines of the network file, just to see if it can be done
local lines = {}
for i=1, 10, 1 do
lines[i]=io.read("*line")
end

if lines[10] then  --MP missions always have at least 10 lines in the network-... files
is_mp=true
elseif lines[6] then  --Track missions always have 5 lines in the network-... files, while SP missions always have 9 lines
is_track=true
else
is_sp=true
end
io.close()
-----------------------------------
---SP/MP/Track Determination END---
-----------------------------------

end

Edited by SilentEagle
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...