Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
Punk

RGSS/Maker Version Detection - Accomplishing cross-engine Scripting

Recommended Posts

I apologize in advance if I ended up posting this in the wrong area. My reason for it being that it's a topic about scripting for multiple makers.

 

BuEqfkXIMAAFhbS.png

RPG Maker XP with RGSS3 / Maker + RGSS Detection

 

Alright, a little background as to why this thread exists! (You can skip this part)

So recently I've been writing a few scripts on a very sporadic basis. Most of the scripts I've written thus far this year works fairly well with all RGSS-capable makers as their code is generally the same, save for a few minor differences and some extra features and functionality added to go with them.

 

Because it's possible to power an RPG Maker XP project with RGSS2 or even RGSS3 functionality (or even RMVX with RGSS3), I figured I should let users of older makers take advantage of all the features provided by later (or the latest) versions of RGSS, if they really wanted to. Of course, they'd have to jump through some hoops and a lengthy tutorial and then activate a particular setting in the script's config to be able to do this.

 

But after awhile of scripting, I started growing kind of tired of managing about 2-3 different text files that had very little differences in each (for some, the only differences were the inclusion of if statements for whether the RGSS2/RGSS3 settings were enabled). I also grew tired of users having to gain access to the extra functionality by changing the value of a particular setting. That's when I decided to start looking into scripts that could sniff out/detect which version of RGSS and RPG Maker someone is using.

 

And now onto the thread!

In this thread, I'm going to propose two suggestions (along with a snippet to go with each) that could aid a fellow scripter in writing cross-engine scripts. Whether that be scripts that could be installed in any RGSS-capable RPG Maker and/or scripts that grants users access to extra features and calls depending on which version of RGSS is being used. This means that someone could write a script that is very friendly towards older versions of RPG Maker, but can automatically take advantage of what the latest version of RGSS offers if the user decides to power their projects with later versions of RGSS. In order to do this, we will be using a sniffing/detection technique that sniffs out which RPG Maker and version of RGSS a user is using.

 

Of course, scripters don't necessarily have to install one or two of these in their own scripts. That is, unless the scripter absolutely needs to use it for a script that's intended to be cross-engine in the sense that it could be installed in any maker and/or use any feature provided by later versions of RGSS.

 

Implementations and Snippets!

Originally, I wanted to make these a part of the $imported hash by using $imported[:RGSS_VERSION] and $imported[:MAKER_VERSION] to store the RGSS version and maker the project is being powered by. Then Cremnophobia pointed out to me that the constant RGSS_VERSION exists in Ace, which made me realize there wasn't much of a point in using $imported for this purpose (though $imported is still very useful).

 

Anywho, so we will be using constants RGSS_VERSION and MAKER_VERSION to help us out with making cross-engine scripting better.

 

RGSS_VERSION would detect which version of RGSS is being used for your project. The snippet below might not be able to check for a very specific version of RGSS, especially for RGSS10**, but it is very effective if you just want to write scripts that works for any current version of RGSS.

 

defined?(RGSS_VERSION) || (RGSS_VERSION = defined?(Hangup) ? '1.0.0' : '2.0.0')
Snippet by Cremnophobia

 

MAKER_VERSION would detect which RGSS-capable RPG Maker your project uses no matter which version of RGSS your project is powered by. So like the screenshot above this post, you could have a project that's made in RPG Maker XP but uses a succeeding version of RGSS.

 

FenixFyreX suggested that the best and safest way to determine which maker is being used is to check for file extensions.

 

I went with checking the extension of the Scripts data file. I wrote three attempts at it.

[spoiler=Attempt 1]

MAKER_VERSION = (["rxdata", "rvdata", "rvdata2"].each { |i|
  file = load_data("Data/Scripts.#{i}") rescue nil
  file = true if file
  case i
    when "rxdata"; break :xp if file
    when "rvdata"; break :vx if file
    when "rvdata2"; break :vxa if file
    else; break :other
  end
}) if !defined?(MAKER_VERSION)

 

[spoiler=Attempt 2]

MAKER_VERSION = (['rxdata', 'rvdata', 'rvdata2'].each { |i|
  file = load_data("Data/Scripts.#{i}") rescue nil
  file = true if file
  case i
    when 'rxdata'; break :xp if file
    when 'rvdata'; break :vx if file
    when 'rvdata2'; break :vxa if file
  end
  break :other if i == 'rvdata2' and !file
}) if !defined?(MAKER_VERSION)

 

[spoiler=Attempt 3]

MAKER_VERSION = (['rxdata', 'rvdata', 'rvdata2'].each { |i|
    file = load_data("Data/Scripts.#{i}") rescue nil; file = true if file
    break :xp if i == 'rxdata' && file; break :vx if i == 'rvdata' && file
    (file ? (break :vxa) : (break :other)) if i == 'rvdata2'
}) if !defined?(MAKER_VERSION)

 

 

Q&A!

Q: ...Is this required?

From the perspective of the scripter and the average user: Nope!

This is optional for scripters to insert into their script. It also doesn't need to be inserted into every script you write. Only insert either or both of these somewhere around the top of your script below the header (Near the Import Check if your script includes that) if your script RELIES on RGSS/Maker version detection.


So! Any questions? Comments? Suggestions?

Do you like or dislike this idea?

Came up with better snippets than what's been posted up here thus far? Post them!

Edited by Punk

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...