Ok. Here's a quick something that could help. Basically rather than calling Graphics.update and forcing the Graphics module to update, it'll check the last update and only update if the last update was more than x seconds ago.
class << Graphics
Force_Update_Seconds = 8
unless self.method_defined?(:seph_hanging_update, :update)
alias_method :seph_hanging_update, :update
end
def update
seph_hanging_update
@last_update = Time.now
end
def hanging_update(seconds = Force_Update_Seconds)
update if Time.now > @last_update + seconds
end
end
Now in rather process consuming functions (such as reading and setting pixels, generating paths (pathfinding), etc.) at the end of certain block, just add
Graphics.hanging_update
or
Graphics.hanging_update(seconds)
Such as below:
class Bitmap
def get_pixel_pallette
colors = []
for x in 0...width
for y in 0...height
c = get_pixel(x, y)
colors << c unless color.include?(c)
end
Graphics.hanging_update
end
return colors
end
end
Now when such a method is called, it'll pass from left to right and up to down a bitmap collecting colors (which is a consuming process). Once it finishes every column of pixels, it'll call that Graphics.hanging_update method to try to prevent the hanging error to occur forcing to update the graphics module.
Here's a list of consuming methods for the default RGGS library:
Bitmap
- get_pixel
- set_pixel
- hue_change
Sprite
- angle
So do a search in your scripts. If you see any line of code with those keywords and they are indented 6-8 spaces, throw Graphics.update_hanging on the line beneath them.
Your other error might not be a process that is consuming too much time, as a loop that just is never executing. As simple as
It keeps going through that block (although nothing is happening) but because nothing is happening and it is never exited, you'll eventually get an error. There could just be a bad range or block that just never terminates.