[XP] Interpreter Script Call Fix

Started by Juan, April 27, 2008, 04:58:14 pm

Previous topic - Next topic

Juan

April 27, 2008, 04:58:14 pm Last Edit: March 23, 2019, 11:35:19 am by Blizzard
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


  • Fixes the call script
  • Plug in and play



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


  • Juan
  • Boris "Blizzard" Mikić
  • Zeriab



Author's Notes

If there are any bugs please post it or email me at juanpena1111@yahoo.com
and credit me.
Dropbox Who need luck when you can make your own.
3ds Friend code: ShowHide
 4468 1422  6617

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Sally


Juan

@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.
Dropbox Who need luck when you can make your own.
3ds Friend code: ShowHide
 4468 1422  6617

G_G

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!


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.

fugibo

Just take away the parentheses (accept for the ones around "script") and the "= true" part; it's unneeded.

ie

return eval(script)

G_G

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

Aqua

GG... you didn't even change what WcW told you to change...

G_G


fugibo

You didn't take off the "= true" part.

Juan

Oh lol I couldn't remember what part I forgot to change. I'll update my post.
Dropbox Who need luck when you can make your own.
3ds Friend code: ShowHide
 4468 1422  6617

legacyblade

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!

Juan

Dropbox Who need luck when you can make your own.
3ds Friend code: ShowHide
 4468 1422  6617

fugibo

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.

legacyblade


fugibo

Just search for console on RMXP.org. I'll see if I can find it myself, though :P

legacyblade

I found it, thanks for the tip, WcW!

Zeriab

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*

Juan

I'll update the main post with yours.
Dropbox Who need luck when you can make your own.
3ds Friend code: ShowHide
 4468 1422  6617