Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Speeding up the event processing of large events.

Zeriab

Sponsor

Hi everyone,
In the default scripts Graphics.update is called whenever 100 event commands have been processed in the same frame. (I.e. no wait or anything like that)
Graphics.update means that it draws the screen and waits for framerate sync. Basically there there is an artificial limit on 4000 event commands processed every second which can be a problem if you have large events with fast event commands.

To mitigate this go to line 120 in the Interpreter 1 section in the script editor to find this area:
Code:
 

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    # Initialize loop count

    @loop_count = 0

    # Loop

    loop do

      # Add 1 to loop count

      @loop_count += 1

      # If 100 event commands ran

      if @loop_count > 100

        # Call Graphics.update for freeze prevention

        Graphics.update

        @loop_count = 0

      end

      # If map is different than event startup time

      if $game_map.map_id != @map_id

 

Change it so that it looks like this:
Code:
  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    # Initialize loop time

    @time = Time.now

    # Loop

    loop do

      # If more than three seconds has passed

      if Time.now - @time > 3

        # Call Graphics.update for freeze prevention

        Graphics.update

        @time = Time.now

      end

      # If map is different than event startup time

      if $game_map.map_id != @map_id

 

Now it calls Graphics.update if more than 3 seconds has passed since it started processing. This way as many event commands can be processed as is possible with an upto 1/40 second extra wait every 3 seconds.
Graphics.update must be called every now and then or you'll get a script is hanging exception which crashes the game so it is necessary to have.

*hugs*
 

Zeriab

Sponsor

No, it should not.
You are thinking about the @wait_count. I remove the @loop_count whose purpose is to prevent 'Script is hanging' for enormous events and replace that with a time checking mechanism.

*hugs*
 
I often think it would be good to have all these things together in one big script. Like the SDK but not necessarily for developers, just a sort of base script with improved lag and speed issues and such which won't break anything, I dunno. That's a great script right there though, makes me understand things I didn't before about how evs are processed.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top