12-21-2024, 06:40 PM
(This post was last modified: 12-21-2024, 06:43 PM by DerVVulfman.)
For scripters of RUBY, I did a little bit of discovery.
Within RUBY... even available when using RPGMaker XP's RGSS... you have access to the OBJECT class. Not that you see it in the Scripts database. And the OBJECT class has a few methods. One of these methods is 'instance_variables' which would return an array listing all the variables specific for the class within.
Ergo, you would get instance variables representing the command window, the created sprite background, and a few others if used within "Scene_Title"
However, different versions of Ruby return this array differently.
With Ruby v 1.8.1 (used by both RPGMaker XP and VX at the very least), the names stored within the returned array are listed as strings:
EX: ["@sprite", "@continue_enabled", "@previous_scene", "@command_window"]
But at some point, RUBY had changed, and the current versions (such as version 2.7 used by HiddenChest) now return the instance variables as their 'symbols', and not by their names as strings.
EX: [:@sprite, :@continue_enabled, :@previous_scene, :@command_window]
Now, this is important as older scripts that utilize this method (such as the RMXP SDK) to retrieve the names in string format. And yep, that can cause problems.
BUT, I found that there's no issue just converting the 'symbol' name into a string.
This STOOPID thing works. And lets what I'm doing work between both new and old RUBY versions.
I know, its not 'proper' to change a variable itself from one type to another (like changing a float to an integer), and if a variable needs to be 'defined' as a particular fixed type this wouldn't exactly work... requiring a second variable defined soley for 'string names'. But for the current RUBY version, it works.
Within RUBY... even available when using RPGMaker XP's RGSS... you have access to the OBJECT class. Not that you see it in the Scripts database. And the OBJECT class has a few methods. One of these methods is 'instance_variables' which would return an array listing all the variables specific for the class within.
Ergo, you would get instance variables representing the command window, the created sprite background, and a few others if used within "Scene_Title"
However, different versions of Ruby return this array differently.
With Ruby v 1.8.1 (used by both RPGMaker XP and VX at the very least), the names stored within the returned array are listed as strings:
EX: ["@sprite", "@continue_enabled", "@previous_scene", "@command_window"]
But at some point, RUBY had changed, and the current versions (such as version 2.7 used by HiddenChest) now return the instance variables as their 'symbols', and not by their names as strings.
EX: [:@sprite, :@continue_enabled, :@previous_scene, :@command_window]
Now, this is important as older scripts that utilize this method (such as the RMXP SDK) to retrieve the names in string format. And yep, that can cause problems.
BUT, I found that there's no issue just converting the 'symbol' name into a string.
Code:
object_name = (object_name).to_s unless object_name.is_a?(String)
This STOOPID thing works. And lets what I'm doing work between both new and old RUBY versions.
I know, its not 'proper' to change a variable itself from one type to another (like changing a float to an integer), and if a variable needs to be 'defined' as a particular fixed type this wouldn't exactly work... requiring a second variable defined soley for 'string names'. But for the current RUBY version, it works.