This thread is going to shine a light on proposing two ways in which we can accomplish cross-engine scripting
Background (You can go ahead and skip this part)
During my I-took-a-break-longer-than-actually-intended hiatus, I was writing and refining more than a few scripts on a sporadic basis. Most of those scripts worked seamlessly with all RGSS-capable versions of RPG Maker from the start as their code was generally the same, save for a few extra settings along with some extra functionality to go with it.
Because it's so well known now that one could make their RPG Maker XP project capable of utilizing RGSS2 or RGSS3 functionality or even get their RMVX project to use RGSS3, I figured I should just let users of older makers be able to take advantage of functionality provided by the later (or the latest) versions of RGSS if they really wanted it. Of course, they would have to enable it through a setting in order to gain access to it, right after they do a lengthy process to power their projects with RGSS2/RGSS3.
But after awhile, I started growing tired of managing 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.
Introduction
In this thread, I will be proposing two suggestions that (when implemented) could greatly aid a 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.
These wouldn't need to be included
Implementation
We will be using Constants named RGSS_VERSION (Already available in Ace as mentioned by cremnophobia) and MAKER_VERSION. You can read the next section to learn about the differences between the two.
So I was bouncing ideas back and forth with FenixFyreX about putting together detection scripts people can use. You can click the spoiler to look at what we came up with.
Spoiler
For RGSS Version detection, Fenix and I came up with this.*
* Unfortunately, I had to bunch up the code in order to get it to fit within the script editor's margin line, so it doesn't look quite as pretty as it did before then.
$imported[:RGSS_VERSION]||=RUBY_VERSION.to_f==1.8 ? (defined?(Hangup) ? 1:2) : 3
* Unfortunately, I had to bunch up the code in order to get it to fit within the script editor's margin line, so it doesn't look quite as pretty as it did before then.
$imported[:RGSS_VERSION]||=RUBY_VERSION.to_f==1.8 ? (defined?(Hangup) ? 1:2) : 3
Cremnophobia said:
Code:
defined?(RGSS_VERSION) || (RGSS_VERSION = defined?(Hangup) ? '1.0.0' : '2.0.0')Q&A
Q: What's the difference between RGSS_VERSION and MAKER_VERSION?
RGSS_VERSION would indicate which version of RGSS your project uses no matter which RPG Maker you use.
MAKER_VERSION should indicate which RPG Maker you use no matter which version of RGSS your project is powered by.
Q: Is this required?
From the perspective of the scripter and the user: No and no.
Like $imported[:SCRIPT_LIST] and the expansion of $imported, this is optional for scripters to insert into their script. It also doesn't need to be inserted into every script. 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.
Now irrelevant Q&As
Spoiler
Q: Why $imported (again)?
So any questions? Comments?
Do you like or dislike this idea?
Came up with better snippets than what's been posted up here thus far?