[RESOLVED] [XP --> XPA] How does 'eval' work?

Started by SolarisSpell, April 25, 2021, 10:41:59 am

Previous topic - Next topic

SolarisSpell

April 25, 2021, 10:41:59 am Last Edit: April 25, 2021, 05:28:55 pm by SolarisSpell
Hi

I've just realized that my project had and old script used for crafting, but after updating to XPA it just fails.

I'm trying to fix it, but is a script far too complex for meeĀ”. It uses something called SDK that I don't know what it is (but somehow is in my project) and when I call the script it fails in a line that uses 'eval'. It should just be a selection menu.

In order to clarify, I have prepared a demo of the XP version (which works) and another version for the XPA version (which doesn't work)


Crafting - XP


Crafting - XPA


Also, as an added bonus, if someone is having problems updating to XPA, maybe you can use this demo as base

Thanks

KK20

April 25, 2021, 01:16:17 pm #1 Last Edit: April 25, 2021, 01:56:01 pm by KK20
Heads up, your second link didn't work.

SDK stands for standard development kit. It was a collaborative effort of many XP scripters to essentially rewrite the base XP scripts since XP wasn't exactly written with the best design principles in mind. The idea was to break up lengthy methods and modularize it, with the intent to make extending the base scripts easier for future user scripts. Basically, it tried to make XP look more like what VXA does.

Unfortunately, this caused a divide in the community since certain scripts now depended on SDK in order to function properly. Meanwhile, other scripters assumed no SDK was being used when writing their scripts, but now it's most likely incompatible when SDK is introduced. The idea had good intentions, but since it was never standardized, it ended up being a mistake. Not to mention, not all of the scripters who worked on the SDK were particularly good at programming either, so there's some poorly written/hackish solutions still lurking in it. We here at CP frown upon its usage as a result.

Anyways, the issue is the fact that Object#instance_variables has changed between Ruby versions 1.8 and 1.9; the former returned Strings while the latter returns Symbols. The solution is to convert the Symbols to Strings using to_s. Find and replace in Scene_Base:
  #--------------------------------------------------------------------------
  # * Main Processing : Disposal
  #--------------------------------------------------------------------------
  def main_dispose
    # Passes Through All Instance Variables
    self.instance_variables.each do |object_name|
      # Evaluates Object
      object = eval object_name.to_s
      # Pass Object To Auto Dispose
      auto_dispose(object)
    end
  end
  #--------------------------------------------------------------------------
  # * Main Processing : Ending
  #--------------------------------------------------------------------------
  def main_end; end
  #--------------------------------------------------------------------------
  # * Main Processing : Update
  #--------------------------------------------------------------------------
  def main_update
    # Passes Through All Instance Variables
    self.instance_variables.each do |object_name|
      # Evaluates Object
      object = eval object_name.to_s
      # Pass Object To Auto Update
      auto_update(object)
    end
  end

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

SolarisSpell

Thanks for the explanation and for the solution (it was so simple... and I think I wouldn't have figured it)

I've checked the XPA demo, and it seems Google Drive had marked it as a violation of terms of service.
I have created a new file and updated the link. Maybe is not needed to check the script for those who might be interested, but is a XPA-ready project (it even autoupdates the .dll with the method you posted) so I though it could be nice having it.

SolarisSpell

SDK sounds like a good idea, but I can see the problems you're talking about.

It also creates a barrier for users like me who don't know how to properly script. My project has been constructed with a lot of scripts from a lot of sources from different countries, so it creates a barrier as some coding that should work is suddenly incompatible.

I've had it implemented since a lot of years ago, so it seems whatever I have in my game seems to work, but I cannot be certain. I have just discovered that this portion that should be ok wasn't working, so I'm going to check again every system, even those that I'm certain that were previously working.

Again, thanks for the help.