Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Detecting current RTPs [RESOLVED!]

Good day to everyone !

I need a tiny bit of help, I'm not familiar with Win32API stuff, and I'm not sure exactly how the game reads the RTP information from the registry, but I know the registry key I need it to look at.

Code:
'HKEY_LOCAL_MACHINE\SOFTWARE\Enterbrain\RGSS\RTP\'

I've got 'Standard' and 'Kain Nobel' as my two RTP folders, and they've both been confirmed in the registry, now how do I have my script look for all of the RTPs the game is using from the registry?

Right now, I specify them in a constant

Code:
RTP = []
RTP[0] = 'C/Program Files/RPG Maker XP/'
RTP[1] = 'C/Program Files/RPG Maker XP/Kain Nobel RTP/'

But how do I auto-detect the RTPs in use, instead of having to specify them by hand?

The reason I need this is because my Extreme Debug Menu allows you to playtest all BGM/BGS/SE/ME, which by default lists all the music in the Game folder only, but I need it to list the audio files in the respective RTPs assigned to the game as well. RPG::Cache handles it with graphics, but not audio.
 
I still haven't figured this out yet (mostly because I've been working all week).

How do I locate the directories to the assigned RTP(s) the current game is using? Do I have to use some kinda WinAPI code to read the registry?
 
I think you want to obtain the path for the used RTPs, correct? You should be able to use Win32::Registry module for this. I am not quite sure as I ain't too fimiliar with the Win32 module. It is something like Win32::Registry.read(name, *rtype). You could try googling it. You are destined to find something about this on ruby-doc.org, I asure you.

Now when it comes to how the game handles it, I think the RGSS Player first hand reads the .ini file, parses the path to be linked with the game folders so if you use Audio/BGM/whatever it will be able to play the whatever.* file as long as it is inside the RTP or game folders. I'm not quite sure here either, though.
 
That tiny INI snippet worked wonders, I modified it specifically for the Game.ini, thanks! Also, instead of going through the trouble of looking for Ruby's Win32API, Registry, API, etc modules, I just worked off Alework's module(s) since it is essentially similiar (as far as I can tell) to the Win32API module and all of its related classes (thanks vgvgf!).

I do have one last question, since it is related to the same thing I'm working on I figured I'll just ask it here instead of wasting a new topic.

Can someone demonstrate how to utilize .gsub and .gsub! methods and all of that fun stuff? Here's what I'm trying to do...

Filepaths, when read with the scriptlets I've used and created, are returned with a backslash notation, like so....

"C:\RPG Maker XP\" # (filepath to my personal RTP Standard folder)

But for some reason or another, Ruby/RGSS doesn't like this notation, so I have to replace that entry with...

"C:/RPG Maker XP/"

After reading the Help file and a Ruby book from the library, I haven't been able to sucessfully replace the "\" character with "/", how do I do it? I've even looked at some of Ccoa's UMS to try and get a reference but only go crosseyed @_@ Thanks for anybody who can demystify this for me.
 
You'd think something like that would be that simple, but I tried (with a print test) a few variations of the following.

p "C:\Windows".gsub(/\/, '/')
p "C:\Windows".gsub(/\\/, '/')
p "C:\Windows".gsub('\', '/')

Either it would return "C:Windows" (without either slash character), or a syntax error. I'm not sure what I'm doing wrong here, and neither the help file or my books mention anything for this, as far as I've found. Thanks for the help though, I'll keep trying.
 
Kain Nobel":27jqh83b said:
You'd think something like that would be that simple, but I tried (with a print test) a few variations of the following.

p "C:\Windows".gsub(/\/, '/')
p "C:\Windows".gsub(/\\/, '/')
p "C:\Windows".gsub('\', '/')

Either it would return "C:Windows" (without either slash character), or a syntax error. I'm not sure what I'm doing wrong here, and neither the help file or my books mention anything for this, as far as I've found. Thanks for the help though, I'll keep trying.

p "C:\\Windows".gsub(/\\/, '/') works for me (\ is an escape character in double quoted strings so you need \\ to represent \ in the original string, or use single quotes). This works too: p 'C:\Windows'.gsub('\\', '/'). The syntax error is probably because it treats the first string as a pattern and \ alone is not a valid pattern
 
I had it like the second example, except I used quotes for the dummy filepath in the print test instead of commas, maybe that was why it wasn't returning the corrected string. Thank you both for your help, I really appreciate it all!

This topic is resolved!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top