SUBSIM Radio Room Forums

SUBSIM Radio Room Forums (https://www.subsim.com/radioroom/index.php)
-   Silent Hunter III (https://www.subsim.com/radioroom/forumdisplay.php?f=182)
-   -   SH3 and Stellarium script: Anyone using? (https://www.subsim.com/radioroom/showthread.php?t=248936)

Pilot_76 03-22-21 12:19 AM

SH3 and Stellarium script: Anyone using?
 
Hi.

Looking for anyone to provide a working script for SH3/Stellarium for celestial navigation. It seems that the latest Python and Stellarium versions make the old script unusable, and it must be updated. I tried myself but I am no programmer :wah:

FUBAR295 03-22-21 07:12 AM

Look at this and post 18, may help.

https://www.subsim.com/radioroom/showthr...=134816&page=2

Good hunting,
FUBAR295

Pilot_76 03-22-21 02:06 PM

Quote:

Originally Posted by FUBAR295 (Post 2737985)
Look at this and post 18, may help.

https://www.subsim.com/radioroom/sho...=134816&page=2

Good hunting,
FUBAR295

Fubar, I tried it and when running it from the script itself (shell IDLE) it goes ok until after typing in the wind and speed. After that it just stops and Stellarium is not loaded. If I run it from the script itself in Windows explorer a pop-up message appears (DOS like) with a quick error message that disappears. I could only read the word "error". I am even using Python v 2.5.2.

Below my copied script:

#Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32
#Type "copyright", "credits" or "license()" for more information.
#************************************************* ***************
#Personal firewall software may warn about the connection IDLE
#makes to its subprocess using this computer's internal loopback
#interface. This connection is not visible on any external
#interface and no data is sent to or received from the Internet.
#************************************************* ***************

#IDLE 1.2.2
#>>> #By Michael Jones, 01/01/2008.
#This program reads the latitude and longitude data for a
#sub in Silent Hunter IV and creates a startup script for
#Stellarium. This sets the Date, Time and Location of the
#sub in Stellarium, allowing players to use celestial navigation in the game.
#
#Modified by Castorp345 to include randomization, 03/24/2008.
import string
import random
random.seed()
#read savegame. Change the directory on the next line to point to SaveData.map in your saved game directory.
#NB you must have plotted waypoints in-game for this to work!
f=open("C:\\Users\\Yugo\\Documents\\SH3\\data\\cfg \\Careers\Yugo CEL\\0\\celnav.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)
#convert to dec deg
longitude = float(content[longst+4:longnd])/120000
latitude = float(content[longnd+1:latnd])/120000
#get date, time, wind speed, & boat speed (input)
date = raw_input('yyyy/mm/dd :')
time = raw_input('hh:mm :')
wind = float(raw_input('wind :'))
speed = float(raw_input('speed :'))
#perform randomization operations on location coordinates
wind1 = random.uniform(0,((wind + 1) * .0083125))
wind2 = random.uniform(0,((wind + 1) * .0083125))
speed1 = random.uniform(0,((speed + 1) * .0083125))
speed2 = random.uniform(0,((speed + 1) * .0083125))
longitude = longitude + wind1 - wind2 + speed1 - speed2
latitude = latitude + wind1 - wind2 + speed1 - speed2
#Write startup script. Change the next line to suit for your Stellarium startup script.
stella=open("C:\\Stellarium\\scripts\\startup.sts" ,'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

Jeff-Groves 03-22-21 04:07 PM

I'd do a batch file to call Stellarium
then add the redirect the outout to file command.
> myoutput.txt

So
Stellarium.exe > myoutput.txt
Pause

That will cause everything to be written to a text file so you can read it all.

Not saying this is wrong as I've never seen the program but

latitude + wind1 - wind2 + speed1 - speed2

In most programming is written in brackets ()

(((latitude + wind1) - (wind2 + speed1)) - speed2))

Or such. Depends on exactly how the math needs to be done and the programming language.

You can actually see an example in your script.
((speed + 1) * .0083125))

So
latitude + wind1 - wind2 + speed1 - speed2
throws an error in my mind just trying to figure out the correct math!
:haha:

No insults intended but the Devil is in the details!

Pilot_76 03-23-21 09:49 PM

Tks Jeff but even deleting those winds it still does not work. Actually it only gives some error for the real sub position.

I got a friend who is a programmer (amateur level) but he will give it a shot.


All times are GMT -5. The time now is 04:01 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 1995- 2024 Subsim®
"Subsim" is a registered trademark, all rights reserved.