Yesterday, 07:39 AM
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
I bet you are right about 0 being truthy is hard on poor C and C++ fans
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:
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:
*hugs*
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

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
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]](http://www.twinkfish.com/al/ZeriabSig.png)