View Single Post
Old 09-06-12, 05:30 PM   #4
dottore
Seaman
 
Join Date: Mar 2010
Location: Hungary
Posts: 32
Downloads: 138
Uploads: 0
1. phase

Progress:

Code:
import fileinput,string,sys,csv
def MakeFile(file_name):

     """
        MakeFile(file_name): makes a file.
     """

    temp_path = 'C:\\Python27\\' + file_name
    file = open(temp_path, 'w')
    file.write('')
    file.close()
    print 'Execution completed.'
MakeFile('my.active.uboat.data.txt')
                       #YourUsername                              #Your.ingame.name, Your Campaign date -> You need to modify this onetime per new patrol(working on an automated latest file copy paste)
f=open("C:\\Users\\*.*.*\\Documents\\SH5\\data\\Users\\*.*.*\\Campaign-2012-09-02_1721\\CampaignMission.mis",'r')
lookup = 'Name=U-'                                                              #changes here too
with open("C:\\Users\\*.*.*\\Documents\\SH5\\data\\Users\\*.*.*\\Campaign-2012-09-02_1721\\CampaignMission.mis",'r') as f:
    for num, line in enumerate(f, 1):
        if lookup in line:
                print 'found at line:', num
                nu=num
f.close()                                                                     #changes here too
with open("C:\\Users\\*.*.*\\Documents\\SH5\\data\\Users\\*.*.*\\Campaign-2012-09-02_1721\\CampaignMission.mis",'r') as f:
        g=open("c:\\Python27\\my.active.uboat.data.txt",'w')
        lines=f.readlines()
        for i in range(nu-1,nu+45):
                line = lines[i]
                line2 = g.writelines(line)
f.close()
g.close()
# longitude grab
lookup2 = 'Long='
with open("c:\\Python27\\my.active.uboat.data.txt",'r') as h:
        for long, line in enumerate(h, 1):
                if lookup2 in line:
                        long2=line
h.close()                        
long2.split('=')
longitude = long2.split('=')[1]
print longitude
# latitude grab
lookup3 = 'Lat='
with open("c:\\Python27\\my.active.uboat.data.txt",'r') as h:
        for long, line in enumerate(h, 1):
                if lookup3 in line:
                        lat2=line
h.close()                        
lat2.split('=')
latitude = lat2.split('=')[1]
print latitude

#stella=open("C:\\Program Files\\Stellarium\\scripts\\startup.ssc" ,'w') 
#stella.write("date utc "+date+"T"+time+":00\n")
#stella.write("moveto lon "+str(longi2)+"\n")
#stella.write("moveto lat "+str(lati2)+"\n")
#stella.write("script action end\n")
#stella.close()
With this initiation we can reduce our big CampaignMission.mis to show only the U-** data. This is essential, because we get rid of needless navigational data.

Everybody can use this script, because it finds the Uboat data ergo the Unit 1.

Results:

my.active.uboat.data.txt content:

Code:
Name=U-33
Class=SSTypeVIIA
Type=200
Origin=German
LayerOperation=0
Side=2
Commander=1
CargoExt=-1
CargoInt=-1
Doctrine=0
CfgDate=19400313
MainEquipment=1
SecondaryEquipment=1
DeleteOnLastWaypoint=false
DockedShip=false
IsEscort=false
GameEntryDate=19380101
GameEntryTime=0
GameExitDate=19451231
GameExitTime=0
EvolveFromEntryDate=false
Long=1322261.310968
Lat=6550443.292625
Height=-3.870683
IsFromSingleMis=true
Heading=69.006813
Speed=0.000000
CrewRating=3
DelayMin=0
ReportPosMin=-1
ReportPosProbability=100
SecondsUntilReport=-40100.000000
HighPrioContact=false
RandStartRadius=0.000000
In3D=true
TacticalUnit=false
AvailStartDate=19380101
AvailEndDate=19451231
TempHeading=0.000000
TempNextWP=0
CombatSubmarine2D=false
CombatRadius2D=30.000000
CommandedSpeed2D=0.000000
Num2DCombatKills=0
Intercept2DCooldown=6.000000
NextWP=1000000
Yes, I know we can grab the important data without this step, but this is double proof safety. You don't want to get an another unit's position only your boat.

Changes:
.Added code snippet so we have our latitude and longitude in decimal using the my.active.uboat.data.txt file.

Last edited by dottore; 09-06-12 at 07:26 PM. Reason: changes 1.2
dottore is offline   Reply With Quote