Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: Juan on April 27, 2008, 04:58:14 pm

Title: [XP] Interpreter Script Call Fix
Post by: Juan on April 27, 2008, 04:58:14 pm
Interpreter Script Call Fix
Authors: Juan, Blizzard
Version: 1.0
Type: Bug Fix
Key Term: Misc Add-on



Introduction

This script fixes the interpreter script call when you use $game_system.anything = false it would normal frezze this script fixes that.


Features




Screenshots

N/A for this type of script.


Demo

N/A


Script
Spoiler: ShowHide

class Interpreter
  SCRIPT_WAIT_RESULTS = [:wait, FalseClass]
  #-------------------------------------------------------------------
  # * Script
  #-------------------------------------------------------------------
  def command_355
    # Set first line to script
    script = @list[@index].parameters[0] + "\n"
    # Store index in case we need to wait.
    current_index = @index
    # Loop
    loop do
      # If next event command is second line of script or after
      if @list[@index+1].code == 655
        # Add second line or after to script
        script += @list[@index+1].parameters[0] + "\n"
      # If event command is not second line or after
      else
        # Abort loop
        break
      end
      # Advance index
      @index += 1
    end
    # Evaluation
    result = eval(script)
    # If return value is false
    if SCRIPT_WAIT_RESULTS.include?(result)
      # Set index back (If multi-line script call)
      @index = current_index
      # End and wait
      return false
    end
    # Continue
    return true
  end
end




Instructions

Just make a new script and post it above main


Compatibility

Compatable with sdk.


Credits and Thanks




Author's Notes

If there are any bugs please post it or email me at juanpena1111@yahoo.com
and credit me.
Title: Re: [XP]Interpreter Script Call Fix
Post by: Blizzard on April 28, 2008, 10:07:33 am
I love you. <3 *powers up*
Title: Re: [XP]Interpreter Script Call Fix
Post by: Sally on April 28, 2008, 08:27:06 pm
i... dont get it....?
Title: Re: [XP]Interpreter Script Call Fix
Post by: Juan on April 29, 2008, 12:48:20 am
@Blizzard thanks for the power up.
@Susys If you tried using
game_system.save_disabled = false
or something similar to that the game would frezze.
Title: Re: [XP] Interpreter Script Call Fix
Post by: G_G on March 24, 2009, 02:39:02 pm
I get en error everytime I run my game with it I've put it below all the scripts and above main. I've tried above blizz's scripts and below mine. I've tried above mine as well but here are the errors I am getting please help!
(http://gameguy27.l4rge.com/error.png)
(http://gameguy27.l4rge.com/lineerror.png)
The things in the red square are the scripts The only ones I didnt make are the ABS 1-3 the Hud and the Script call fix.
(http://gameguy27.l4rge.com/scripts.png)
Title: Re: [XP] Interpreter Script Call Fix
Post by: fugibo on March 24, 2009, 03:04:10 pm
Just take away the parentheses (accept for the ones around "script") and the "= true" part; it's unneeded.

ie

return eval(script)
Title: Re: [XP] Interpreter Script Call Fix
Post by: G_G on March 24, 2009, 03:31:32 pm
I still got a syntax error

class Interpreter
  #--------------------------------------------------------------------------
  # * Script
  #--------------------------------------------------------------------------
  def command_355
    # Set first line to script
    script = @list[@index].parameters[0] + "\n"
    # Loop
    loop {
      # If next event command is not second line of script or after
      if @list[@index+1].code != 655
        # Abort loop
        break
      end
      # Add second line or after to script
      script += @list[@index+1].parameters[0] + "\n"
      # Advance index
      @index += 1
    }
    # Evaluation and return resulting value
    return eval(script) = true
  end
end
Title: Re: [XP] Interpreter Script Call Fix
Post by: Aqua on March 24, 2009, 04:03:02 pm
GG... you didn't even change what WcW told you to change...
Title: Re: [XP] Interpreter Script Call Fix
Post by: G_G on March 24, 2009, 04:24:38 pm
I did too didnt I?
Title: Re: [XP] Interpreter Script Call Fix
Post by: fugibo on March 24, 2009, 04:40:36 pm
You didn't take off the "= true" part.
Title: Re: [XP] Interpreter Script Call Fix
Post by: Juan on March 24, 2009, 10:25:52 pm
Oh lol I couldn't remember what part I forgot to change. I'll update my post.
Title: Re: [XP] Interpreter Script Call Fix
Post by: legacyblade on March 25, 2009, 10:26:28 am
Is there any way to make the game not crash on syntax error? I want to make a "command prompt" thing, for beta testing, that doesn't crash if you type something that would cause an error.

Great script though!
Title: Re: [XP] Interpreter Script Call Fix
Post by: Juan on March 25, 2009, 03:27:19 pm
I'll have to look into that.
Title: Re: [XP] Interpreter Script Call Fix
Post by: fugibo on March 25, 2009, 03:49:33 pm
I've seen one of those on another forum. All you'd do is get a keyboard input script, make an input box, have it eval on enter, and output to another window. To keep it from crashing, you'd just use rescue.
Title: Re: [XP] Interpreter Script Call Fix
Post by: legacyblade on March 25, 2009, 05:56:20 pm
can you find me a link, WcW?
Title: Re: [XP] Interpreter Script Call Fix
Post by: fugibo on March 25, 2009, 09:03:28 pm
Just search for console on RMXP.org. I'll see if I can find it myself, though :P
Title: Re: [XP] Interpreter Script Call Fix
Post by: legacyblade on March 25, 2009, 09:19:42 pm
I found it, thanks for the tip, WcW!
Title: Re: [XP] Interpreter Script Call Fix
Post by: Zeriab on January 07, 2010, 09:20:38 am
Reviving this topic because I don't feel this 'fix' properly fixes the problem.
If the result of evaluating the script is false then it will wait just like normally.
It doesn't wait on multi-line script calls. Two lines of false will for example cause the event to wait one frame before continuing.

That said the waiting feature is nice and should be kept. Having false as what's triggering the wait is perhaps not the best idea since accidental waiting is likely to happen.
Of course you can just put $game_switches[42] in a call script to wait until that switch is turned on. (No wait if it already is on)

My own fix is this:
class Interpreter
  SCRIPT_WAIT_RESULTS = [:wait, FalseClass]
  #-------------------------------------------------------------------
  # * Script
  #-------------------------------------------------------------------
  def command_355
    # Set first line to script
    script = @list[@index].parameters[0] + "\n"
    # Store index in case we need to wait.
    current_index = @index
    # Loop
    loop do
      # If next event command is second line of script or after
      if @list[@index+1].code == 655
        # Add second line or after to script
        script += @list[@index+1].parameters[0] + "\n"
      # If event command is not second line or after
      else
        # Abort loop
        break
      end
      # Advance index
      @index += 1
    end
    # Evaluation
    result = eval(script)
    # If return value is false
    if SCRIPT_WAIT_RESULTS.include?(result)
      # Set index back (If multi-line script call)
      @index = current_index
      # End and wait
      return false
    end
    # Continue
    return true
  end
end


It fixes the multi-line issue and I use :wait to when it should wait. The FalseClass check is for providing compatibility with and older version of mine.
To wait for switch 42 to be on you now have to use something like :wait unless $game_switches[42].

Considering how it can ease certain integration issue it's stupid not to keep that feature :3

*hugs*
Title: Re: [XP] Interpreter Script Call Fix
Post by: Juan on January 07, 2010, 01:00:15 pm
I'll update the main post with yours.