Yes, I realize the paths, names, and syntax must be correct.
This is the script I used before:
import string
#read savegame. Change the directory on the next line to point to SaveData.map in your saved game directory.
f=open("C:\\Users\\Owner\\Documents\\SH4\\data\\cf g\\SaveGames\\0000000d\\SaveData.map",'r')
content= f.read()
f.close()
#find lat & Lon in the file
start = content.find("Waypoint")
longst = content.find("Pt0=",start)
longnd = content.find(",",longst)
latnd = content.find(",",longnd+1)
print start
print longst
print longnd
print latnd
#convert to dec deg
longitude = float(content[longst+4:longnd])/120000
latitude = float(content[longnd+1:latnd])/120000
#get date&time (input)
date = raw_input('GMT yyyy/mm/dd :')
time = raw_input('GMT hh:mm :')
#Write startup script. Change the next line to suit for your Stellarium startup script.
stella=open("C:\\Games\\Stellarium\\scripts\\start up.ssc",'w')
stella.write("date utc "+date+"T"+time+":00\n")
stella.write("moveto lon "+str(longitude)+"\n")
stella.write("moveto lat "+str(latitude)+"\n")
stella.write("script action end\n")
stella.close()
#now open stellarium and take your star sights
....it wrote to startup.ssc file:
date utc 2001/01/01T23:59:00
moveto lon 120.01051
moveto lat 14.5458591667
script action end
The problem was Stellarium program did not use the values in the file. It is a new version, 10.6.1 and I have no way of knowing what the correct format and such.
I also tried another Python script based on what you posted:
#read savegame. Change the directory on the next line to point to SaveData.map in your saved game directory.
savedgame = "C:\\Users\\Owner\\Documents\\SH4\\data\\cfg\\Save Games\\0000000d\\SaveData.map"
# read savegame.
f=open(savedgame,'r')
content= f.read()
f.close()
#Set the Stellarium directory
stellocation = "C:\\Games\\Stellarium"
#find lat & Lon in the file
start = content.find("Waypoint")
longst = content.find("Pt0=",start)
longnd = content.find(",",longst)
latnd = content.find(",",longnd+1)
print start
print longst
print longnd
print latnd
#convert to dec deg
longitude = float(content[longst+4:longnd])/120000
latitude = float(content[longnd+1:latnd])/120000
#get date&time (input)
date = raw_input('GMT yyyy/mm/dd :')
time = raw_input('GMT hh:mm :')
# set the ocean label
if (-90 < longitude <= 30):
ocean = "Atlantic Ocean"
elif (30 < longitude <= 105):
ocean = "Indian Ocean"
elif (longitude <= -90 or longitude > 105):
ocean = "Pacific Ocean"
#Write startup script. Change the next line to suit for your Stellarium startup script.
date = date.replace('/', ':')
longitude = str(longitude)
latitude = str(latitude)
stella=open(stellocation + "
\\scripts\\sh4.ssc",'w')
stella.write("core.setDate(\""+date+"T"+time+":00\ ")\n")
stella.write("core.setObserverLocation("+longitude +", "+latitude+", 2, 0, \"SH4 Navigation Point, "+ ocean +"\", \"earth\")");
stella.close()
#now open stellarium and take your star sights
prog = "start /d \""+ stellocation +"\" stellarium.exe --startup-script sh4.ssc"
os.system(prog)
sys.exit()
.....it doesn't request inputs for date and time, doesn't start Stellarium, and doesn't write to sh4.ssc.
I don't know what else to try at this point.