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 > SH5 Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 03-21-10, 04:47 PM   #1
reaper7
sim2reality
 
Join Date: Jun 2007
Location: AM 82
Posts: 2,288
Downloads: 262
Uploads: 31
Default New Page in Editor

Ok, I have been trying to create a new Page into the editor with not much luck, and need some advice.

I have created a Copy basically of the TDC page and Called it Page TDC2 in the editor as a test.
This creates the relevant ini page in the Pages Folder (Page TDC2.ini). Ok.

I then Create a new script called Page TDC2.py
And edit it like the following : (My tabs are not showing up in the scripts when I paste them into forum)

def InitializeScript():
pass
def StartGame():
pass
def EndGame():
pass
def UnloadScript():
pass

Now as I want the Periscope to bring this page up in the game I edit the Page attack periscope.py file like this:

#Page attack periscope.py
from menu import *
def InitializeScript():
Menu.PageActivated += Menu_PageActivated
Menu.PageDeactivated += Menu_PageDeactivated
def StartGame():
pass
def Menu_PageActivated( page ):
if page == Pageattackperiscope:
from PageTDC2 import PageTDC2
PageTDC2.Visible = True
def Menu_PageDeactivated( page ):
if page == Pageattackperiscope:
from PageTDC2 import PageTDC2
PageTDC2.Visible = False
def UnloadScript():
Menu.PageActivated -= Menu_PageActivated
Menu.PageDeactivated -= Menu_PageDeactivated
def EndGame():
pass

These are placed into the correct folders and the game is launched.
Game loads ok, but when I activate the periscope the game freezes with the following script error.



Can anyone tell me what I'm doing wrong. I've no scripting experience but this appears to be the method as shown earlier in this thread.
The no module named TDC2 is baffling me, how do you create a module?
reaper7 is offline   Reply With Quote
Old 03-21-10, 05:48 PM   #2
Woodybcn
Watch
 
Join Date: Feb 2010
Location: Barcelona, SPAIN
Posts: 27
Downloads: 38
Uploads: 0
Default

Please, I've been sailing a few days on SH5 but I haven't heard any song from the radio because I don't know how it works! Please, let me know what button I must press.

Thank you.
__________________
https://flic.kr/p/BzjrTv
My new toy!
Woodybcn is offline   Reply With Quote
Old 03-21-10, 06:33 PM   #3
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,959
Downloads: 147
Uploads: 5


Default

Quote:
Originally Posted by reaper7 View Post
Ok, I have been trying to create a new Page into the editor with not much luck, and need some advice.

I have created a Copy basically of the TDC page and Called it Page TDC2 in the editor as a test.
This creates the relevant ini page in the Pages Folder (Page TDC2.ini). Ok.

I then Create a new script called Page TDC2.py
And edit it like the following : (My tabs are not showing up in the scripts when I paste them into forum)

def InitializeScript():
pass
def StartGame():
pass
def EndGame():
pass
def UnloadScript():
pass

Now as I want the Periscope to bring this page up in the game I edit the Page attack periscope.py file like this:

#Page attack periscope.py
from menu import *
def InitializeScript():
Menu.PageActivated += Menu_PageActivated
Menu.PageDeactivated += Menu_PageDeactivated
def StartGame():
pass
def Menu_PageActivated( page ):
if page == Pageattackperiscope:
from PageTDC2 import PageTDC2
PageTDC2.Visible = True
def Menu_PageDeactivated( page ):
if page == Pageattackperiscope:
from PageTDC2 import PageTDC2
PageTDC2.Visible = False
def UnloadScript():
Menu.PageActivated -= Menu_PageActivated
Menu.PageDeactivated -= Menu_PageDeactivated
def EndGame():
pass

These are placed into the correct folders and the game is launched.
Game loads ok, but when I activate the periscope the game freezes with the following script error.



Can anyone tell me what I'm doing wrong. I've no scripting experience but this appears to be the method as shown earlier in this thread.
The no module named TDC2 is baffling me, how do you create a module?
I see what you're trying to do and it won't work. The C++ code only allows dials on pages that already had dials on them. Sure you can add a dial to Page Default Hud but when you try to tie it to the the dial in the file dials.cfg it won't work. The game will not update the dial. It will be just a static bitmap. If you want to do TDC stuff then you have to keep the dials on PageTDC or use another page that already has dials on them.

Last edited by TheDarkWraith; 03-21-10 at 07:07 PM.
TheDarkWraith is offline   Reply With Quote
Old 03-21-10, 07:48 PM   #4
Heretic
Commodore
 
Join Date: Mar 2005
Location: Nebraska
Posts: 617
Downloads: 240
Uploads: 2


Default

Hey DarkWraith, given what you've seen so far, what do you think the prospect of passing sim data to the AI scripts is? The menu stuff seemingly has all the depth, course, etc, info. There are python files that look to be an interface to the AI scripting in scripts folder. If that were possible, many cool things could be done.
Heretic is offline   Reply With Quote
Old 03-21-10, 08:06 PM   #5
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,959
Downloads: 147
Uploads: 5


Default

Quote:
Originally Posted by Heretic View Post
Hey DarkWraith, given what you've seen so far, what do you think the prospect of passing sim data to the AI scripts is? The menu stuff seemingly has all the depth, course, etc, info. There are python files that look to be an interface to the AI scripting in scripts folder. If that were possible, many cool things could be done.
if it's a python file and it's scripted should be fairly easy. I haven't looked into AI yet. Concentrating on UI. Have you researched the Script editor's included 'information'? You can see all classes and what properties, events, etc. are exposed to us. That is a gold mine
TheDarkWraith is offline   Reply With Quote
Old 03-21-10, 08:46 PM   #6
Arclight
Navy Seal
 
Join Date: Jun 2008
Location: Land of windmills, tulips, wooden shoes and cheese. Lots of cheese.
Posts: 8,373
Downloads: 53
Uploads: 10
Default

No kidding.

I don't even understand python, but I definitely see the potential there.

See if I can make a battleship surrender to my u-boat.


Seriously, those tools are a godsend. That debugger gives a look under the hood, see the AI operating. Goblin is much appreciated since I don't have 3D editor, working with the .zon files would be impossible without it.

__________________

Contritium praecedit superbia.
Arclight is offline   Reply With Quote
Old 03-22-10, 07:13 AM   #7
reaper7
sim2reality
 
Join Date: Jun 2007
Location: AM 82
Posts: 2,288
Downloads: 262
Uploads: 31
Default

Quote:
Originally Posted by TheDarkWraith View Post
I see what you're trying to do and it won't work. The C++ code only allows dials on pages that already had dials on them. Sure you can add a dial to Page Default Hud but when you try to tie it to the the dial in the file dials.cfg it won't work. The game will not update the dial. It will be just a static bitmap. If you want to do TDC stuff then you have to keep the dials on PageTDC or use another page that already has dials on them.

Ah Ok, so I will have to use the original TDC page then. Thanks.

Have PM'ed this to maerean_m. But will post here in case anyone else could uptake.

"Hi maerean_m, can you tell me if there are any plans to do some simple tutorials on modding SH5.
This would be great for us newcomers to modding that are completly lost, even trying to understand what others have done with there mods is impossible as you cant tell whats been altered in some of the files.

For example a simple tutorial on how to introduce a single working dial eg the AOB dial into the User Interface.
This would show how to access the Editor, where to place the holders for the graphics, what .ini files are created and what scripts are required to introduce them into the game.
Just been able to see one solid example of how thing are done, would help people to go on from that and experiment."

Last edited by reaper7; 03-22-10 at 07:48 AM. Reason: Tutorial requirments
reaper7 is offline   Reply With Quote
Old 03-22-10, 10:19 AM   #8
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,959
Downloads: 147
Uploads: 5


Default

adding a single dial is a very simple evolution. If you want to teach yourself how do this:

using the menu editor:

we want to add the heading/rudder dial to PageTDC.

in Page layout find the Heading group (it's under Group feedback) and copy it's entire tree over to PageTDC. Now when I say the entire tree I'm talking about it's anchor group. What denotes an anchor group? The big 'G' in the box. For heading it's 'Heading'. Now if you just copy over heading and think you got a dial you are wrong. The 'whole' dial consists of 'Heading' - a Group, 'Rudder' - a Group, 'Toggle Rudder Heading Around' - a button, and 'Toggle Rudder Heading' - a button. How do I know this? Two ways. One is that when I click on each one I get a yellow outline box on the editor that shows me graphically that it's part of the whole dial. Two, as I click on each one in the menu editor and I look in the zone section I see that the anchor refers to some part of the dial (it doesn't have to but doing so keeps the coherency of the object). You'll notice that the button 'Toggle Rudder Heading' anchor is 'Bkgr'.
Now after you've copied all those items over to PageTDC you need to check their anchors. You'll notice that 'Toggle Rudder Heading' anchor is set to Null now. Why? Well before it referenced an item in Page layout but we're now in PageTDC so obviously that page doesn't exist here. I would set the 'Toggle Rudder Heading' anchor to the object on PageTDC that you want this dial to be anchored to. Best thing to do is set the anchors of all the copied objects to reflect the values of the object you copied from in the other page. After setting all the anchors to the values they should be, moving the 'Toggle Rudder Heading' will cause the whole dial to move with it (if all the anchors are setup to reference one another in the object). If one of the anchors is set to reference some other object then that part won't move when you move 'Toggle Rudder Heading'.
Okay so now we have a new dial on PageTDC. But how do we get the game to update it? That's the easy part. Go back to the page you copied this new dial from. I'll use the Heading/Rudder here as an example. For the game to update a dial it needs 3 pieces of information: the dial, the current value, and the new value. Open up the file \data\Menu\cfg\Dials.cfg. This is where we define the dials. Do a search for 'CompassFdbk'. This dial, [Dial22] is responsible for updating the 'Heading' dial in Page layout. How do I know this? Easy. Look at the values for CrtVal (current value), NewVal (new value), and Dial. They start with 3F (0x just means this is a hex value). If we go back to the menu editor and go to Page layout we see that it's ID is 3F000000. If we find the values for CrtVal, NewVal, and Dial on Page layout we see that they reference objects of the dial in question (parts of the Heading dial). Now if you correlate the CrtVal, NewVal, and Dial to the objects on the screen you can see what is controlling what. After you denote the correlation then add another entry to Dials.cfg at the bottom. Copy the whole entry for [Dial22] to the bottom and give it the next number in the chain (if you're using the stock file the next number will be 75. Now change the CrtVal, NewVal, and Dial IDs on this new entry to reflect the IDs of the dial on PageTDC. But wait we're not done yet. This dial has two states - Heading and Rudder. We have to create another entry in Dials.cfg. But what is this entry? Well I know that rudder needs to look like the entry [Dial21] (RudderFdbk). So copy the whole entry for [Dial21] to the bottom of Dials.cfg and give it the next number in the chain (would be 76 with stock file). Now these names - RudderFdbk, SpeedFdbk, etc. can be anything you want to call them for your new dials. Change the IDs of the new dial entry to reflect the object in PageTDC (parts of the Rudder dial). Don't forget to change the Dials.cfg's top number 'DialsNo=' to one plus the last entry in the chain of dials (it's zero based). For our example that line should read 'DialsNo=77'. Save the file.
Are we done yet? Nope. We have a new dial on PageTDC. The game will update it. But the game will not switch it between states - Heading/Rudder. Why? Because the original dial's 'Toggle Rudder Heading' ID is hard coded in the game. The game recognizes 'events' from that ID and responds to them. Your new 'Toggle Rudder Heading' ID means nothing to it. So you have to get creative and create some python code to make it switch states! Where do you place this python code? In PageTDC.py.
TheDarkWraith is offline   Reply With Quote
Old 03-22-10, 12:45 PM   #9
reaper7
sim2reality
 
Join Date: Jun 2007
Location: AM 82
Posts: 2,288
Downloads: 262
Uploads: 31
Default

Thank you TheDarkWraith

I really appreciate you taking the time out to write this, especially when your hard at work working your excellent mods.

This makes it great for us new guys, so much easier to figure out when there's a solid example in front - compared to trying to reverse engineer what others have already done.
This is my first time getting involved in the modding scene, I'm usually the one sitting back waiting to see what some else does.
And with my only abilities on the graphics side, it can be hard to figure things out.

I've been spending the last 2-3 weeks going thru what has being released, thru the editor and trying to understand pyhton but its all going over my head.
So far I've only done graphic editing mods to the dds files. But with the help of the community I'm sure I'll be able to contribute a lot more in time.

Thanks again, its really appreciated.
reaper7 is offline   Reply With Quote
Old 03-22-10, 06:04 PM   #10
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,959
Downloads: 147
Uploads: 5


Default

Quote:
Originally Posted by reaper7 View Post
This makes it great for us new guys, so much easier to figure out when there's a solid example in front - compared to trying to reverse engineer what others have already done.
reverse engineering/ethical hacking is my second hobby
TheDarkWraith is offline   Reply With Quote
Old 03-23-10, 04:58 PM   #11
reaper7
sim2reality
 
Join Date: Jun 2007
Location: AM 82
Posts: 2,288
Downloads: 262
Uploads: 31
Default

Thanks to TheDarkWraiths help in the previous post I've been learning from him the last 2 days. And have put together a tutorial on what I've learnt so far.
This should be of help to those starting to learn to Mod

Post can be found here:
http://www.subsim.com/radioroom/showthread.php?t=165968

reaper7 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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 09:38 AM.


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