Rare scripiting problem in XP

Hi, im having a extrange problem with scripts. I created my own project for testing. I added for testing the problem this code in GS:
  1.  
  2. class Game_System
  3.   #--------------------------------------------------------------------------
  4.   # * Public Instance Variables
  5.   #--------------------------------------------------------------------------
  6.   attr_accessor :ib_first_initialize            # tileset file name
  7.   #--------------------------------------------------------------------------
  8.   # * Object Initialization
  9.   #--------------------------------------------------------------------------
  10.   alias wep_gs_ib_init initialize
  11.   def initialize
  12.     wep_gs_ib_init
  13.     @ib_first_initialize = true
  14.   end
  15.  
  16.   def set
  17.     #p 'before set'
  18.     @ib_first_initialize = false
  19.     #p 'after set'
  20.   end
  21. end
  22.  
Expand to see the code.

Note that this script is a test one.
Then i create a new project with a event in automatic that calls this script:
$game_system.set
And desactives himself using selfswitch.

With this, the problem, is that the game freezes and i never can freely move the character, when using the set metod. Note that if i modify the variable in the script call it gives the same problem.

Well, that dont have any sense, but if i uncoment the two p phrases, the game works well, and later of the text i can move character freely.

And if i just let the first testing phrase, its printed in a never ending loop. And if i only let the second one, it works well.

Pd: if you dont understand something, just ask
This is an old bug from XP: if a script call return a nil or false value, the game freezes.
Just add a 'return true' at the end of the method.
Better remove the :
if result == false
return false
end

at the end of Interpreter 7 (that's what they did on VX).
Thanks. Exist a script that corrects all the bugs in XP? Exist other bugs?
gerrtunk wrote:
Thanks. Exist a script that corrects all the bugs in XP? Exist other bugs?


I'm not sure there are more bugs, specifically. Technically, this was an oversight more than a bug. This was the first time the script system was available, and I'm not sure they realized that people would do things like insert new methods into something like the interpreter. As for actual bugs, I can think of more for VX than XP. (In point of fact, I'm having trouble coming up with any actual bugs in xp, rather than just oversights or similar things)
Mmm, i was thinking in adding this itnerpeter correction to the script that gives me problems, thats the skip cutescene mode and update it, but maybe its better to just adapt it to the default script putting a unecesary true at the end of it, than obligating to fix that bug and overwrite the whole method...
gerrtunk wrote:
Mmm, i was thinking in adding this itnerpeter correction to the script that gives me problems, thats the skip cutescene mode and update it, but maybe its better to just adapt it to the default script putting a unecesary true at the end of it, than obligating to fix that bug and overwrite the whole method...


True, but if you're going to release this script, like you tend to do, you'll want to make sure it either includes the fix or mentions that it requires the fix in the instructions, so that people don't wonder why it keeps freezing.
Glitchfinder wrote:
gerrtunk wrote:
Mmm, i was thinking in adding this itnerpeter correction to the script that gives me problems, thats the skip cutescene mode and update it, but maybe its better to just adapt it to the default script putting a unecesary true at the end of it, than obligating to fix that bug and overwrite the whole method...


True, but if you're going to release this script, like you tend to do, you'll want to make sure it either includes the fix or mentions that it requires the fix in the instructions, so that people don't wonder why it keeps freezing.


Well, if i put a return true at the end of setting methods in interpreter, that just work for this script and not any extra explanation is needed, no? it dont freezes

I can include the general bugfix, of course, but it rewrites the whole method of call script....
You don't want a script command to always return true. There are multiple ways to fix that, but that is not one of them.

A simple return, instead of return false will suffice. Nothing will be returned, and Ruby interprets nil as false when comparing as a boolean.

Another fix is something like this:

  1.  #--------------------------------------------------------------------------
  2.   # * Script
  3.   #--------------------------------------------------------------------------
  4.   def command_355
  5.     # Set first line to script
  6.     script = @list[@index].parameters[0] + "\n"
  7.     # Loop
  8.     loop {
  9.       # If next event command is not second line of script or after
  10.       if @list[@index+1].code != 655
  11.         # Abort loop
  12.         break
  13.       end
  14.       # Add second line or after to script
  15.       script += @list[@index+1].parameters[0] + "\n"
  16.       # Advance index
  17.       @index += 1
  18.     }
  19.     # Evaluation and return resulting value
  20.     return (eval(script) != false)
  21.   end
Expand to see the code.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=76251