Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
Sign in to follow this  
  • entries
    7
  • comments
    2
  • views
    3,668

Interpreter command_355

Sign in to follow this  
Zeriab

259 views

This command has given people headaches and many don't really understand it.

In the default scripts if the script call is evaluated to false then the event waits and tries evaluating the script again.

Naturally if you don't think or accidentally cause false to be the result of the script call all the time, the event practically freezes.

An example could be $game_switches[42] = false which will evaluate to false every time. I really think that is not the purpose. Of course you could have $game_switches[42] to halt the event until that switch is turned on. This can have some nice practical purposes that I haven't seen.

 

The solution I most often see is: Oh god no! Let's remove it since it causes my game to freeze!

This is obviously not the most ideal solution. It is true that in practice many errors has been cause by the default behavior and considering how little people seem to use that feature it does seem to better to remove it than to keep it as it is.

 

As you can hear I am not too happy about the idea. It is a nice feature that I would want to keep. My solution would be to check if the call script evaluates to something which it is unlikely to do by accident. I have pushed through the check for FalseClass which is present in the SDK 2.4, but that doesn't really convey the purpose that well.

Checking for the :wait symbol is a nicer solution since it conveys what it means very well. I believe it's very unlikely that someone would make a call script which returns :wait by accident. It is at least much more unlikely than false.

 

Below is a script which also is compatible with the FalseClass version.

 

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

 

Notice that I also fixed the bug where it would not wait with multi-line call scripts.

If you want to also have support for false then you can change

 

SCRIPT_WAIT_RESULTS = [:wait, FalseClass]

to

 

SCRIPT_WAIT_RESULTS = [:wait, FalseClass, false]

 

You can also put in your own objects to check for.

 

*hugs*

Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...