Thoughts on the Interpreter's Script Command
#7
Good job on the new fix!

Yes, Ruby really follows through on the everything-is-an-object mentality. You can even be naughty and add methods to nil
Code:
def nil.method_missing(method, *args, &block)
  # hiding the error
end

I bet you are right about 0 being truthy is hard on poor C and C++ fans  Laughing


Wulfo did a refactor of my code which he shared with me. 
It's not mine to share, but I can share my own refactor:
Code:
class Interpreter
  # * Script Event Command * #
  # Just a small variant of a very old bug fix published by several people
  def command_355
    # Set first line to script
    script = @list[@index].parameters[0] + "\n"
    # Store index in case we need to wait
    working_index = @index
    # Loop
    loop do
      # Subsequence script call event commands have code 655
      # Stop looping once we hit a different command
      break if @list[working_index].code != 655
      # Add script line
      script += @list[working_index].parameters[0] + "\n"
      # Advance to next event command
      working_index += 1
    end
    # Evaluate
    result = eval(script)
    if result == :wait
      # Wait and repeat next frame
      return false
    else
      # Continue processing event commands
      @index = working_index
      return true
    end
  end
end
This is still a version that allows waiting. Here I prefer not modifying the @index until we are sure we need to.

I tested both your and my version with the 3 hello world examples in my previous post. The text window disappears shortly before reappearing for the versions that evalues to false. This doesn't happen otherwise.
Hmm... What do you think about this code? It preserves the same behavior of that specific example:
Code:
class Interpreter
  def command_355
    # Set first line to script
    script = @list[@index].parameters[0] + "\n"
    # Loop
    loop do
      # Subsequent script call event commands have code 655
      break if @list[@index + 1].code != 655
      # Advance index
      @index += 1
      script += @list[@index].parameters[0] + "\n"
    end
    # Evaluation
    result = eval(script)
    # Continue
    return true
  end
end

*hugs*
[Image: ZeriabSig.png]
Reply }


Messages In This Thread
RE: Script Commands Bug Fixes - by kyonides - 02-13-2025, 08:35 PM
RE: Script Commands Bug Fixes - by Zeriab - 02-26-2025, 07:53 AM
RE: Script Commands Bug Fixes - by kyonides - 02-26-2025, 05:45 PM
RE: Script Commands Bug Fixes - by Zeriab - 02-26-2025, 07:25 PM
RE: Thoughts on the Interpreter's Script Command - by Zeriab - Yesterday, 07:39 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Your thoughts on Action Game Maker? PK8 10 20,281 11-18-2011, 03:58 AM
Last Post: KasperKalamity
   Pause Script Feature Requests? PK8 11 18,634 05-25-2009, 11:07 AM
Last Post: Kain Nobel
   Beyond the script editor line: Is it bad practice? PK8 6 12,481 05-22-2009, 09:27 PM
Last Post: Charlie Fleed



Users browsing this thread: 1 Guest(s)