SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > Silent Hunter III
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 03-22-21, 12:19 AM   #1
Pilot_76
Chief
 
Join Date: Mar 2010
Location: São Paulo, Brazil
Posts: 311
Downloads: 427
Uploads: 0
Icon9 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
Pilot_76 is offline   Reply With Quote
Old 03-22-21, 07:12 AM   #2
FUBAR295
Krusty Krab
 
FUBAR295's Avatar
 
Join Date: Mar 2002
Location: Decks awash in the North Atlantic
Posts: 1,274
Downloads: 439
Uploads: 0
Default

Look at this and post 18, may help.

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

Good hunting,
FUBAR295
__________________
Good judgment comes from experience. Unfortunately, the experience usually comes from bad judgment.


FUBAR295 is offline   Reply With Quote
Old 03-22-21, 02:06 PM   #3
Pilot_76
Chief
 
Join Date: Mar 2010
Location: São Paulo, Brazil
Posts: 311
Downloads: 427
Uploads: 0
Default

Quote:
Originally Posted by FUBAR295 View Post
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
Pilot_76 is offline   Reply With Quote
Old 03-22-21, 04:07 PM   #4
Jeff-Groves
Village Idiot
 
Jeff-Groves's Avatar
 
Join Date: Sep 2014
Posts: 5,319
Downloads: 130
Uploads: 0


Default

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!


No insults intended but the Devil is in the details!
__________________
I don't do Stupid. So don't ask.

Last edited by Jeff-Groves; 03-22-21 at 05:07 PM.
Jeff-Groves is offline   Reply With Quote
Old 03-23-21, 09:49 PM   #5
Pilot_76
Chief
 
Join Date: Mar 2010
Location: São Paulo, Brazil
Posts: 311
Downloads: 427
Uploads: 0
Default

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.
Pilot_76 is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:19 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.