Lune world map framerate/bug issue help

I've been trying to implement Lune world map into my game. ( https://centrorpg.com/index.php?topic=1129.0 )

Using the script by itself results in a lot of lag in this specific project. Though, when using it in a similar project, that also uses a larger resolution, there is no lag. So I asked on Discord for help and TheoAllen made a scriptlet that was able to render the map at 60 fps, instead of the usual 5 fps I was getting. (Theo's fix below)
Ruby:
class Scene_Lune_Map
 
  def update
    super
    if @category_index != @category_window.index
      unless $lune_map_info == []
        @item_window.refresh(@category_window.index)
        @help_window.refresh(@category_window.index)
      end
      @category_index = @category_window.index
    end
  end
 
end

However, this resulted in some odd behaviour when moving around the map.

See video linked for what that odd behaviour looks like.



Does anyone know how I can get this to render at 60 fps without the broken map movement?

Thanks

I've moved this thread to Script Support. Thank you.

Hey its me that created the script X)... I'll tell you the truth, the reason of the lag was because of bad BAD HORRIBLE coding haha... Sorry about that, it was when I was still learning to code. I am clearing and recreating the images which is why the issues are happening, about it working for bigger pictures, it shouldn't work betther haha, I think maybe it's some script together with this that is lagging.

Anyway I tried to make some adjustments, try this out if you can. You can try to replace Theo's fix, just to test it out. (Sorry Theo for my bad code 🙁)
Ruby:
class Window_ShowMap < Window_Base
  #--------------------------------------------------------------------------
  # * Renovação
  #--------------------------------------------------------------------------
  def refresh(index)
    @x += 10 if @x <= $lune_map_info[index]['Position'][0] - window_width/2
    @x -= 10 if @x >= $lune_map_info[index]['Position'][0] - window_width/2
    @y += 10 if @y <= $lune_map_info[index]['Position'][1] - window_height/2
    @y -= 10 if @y >= $lune_map_info[index]['Position'][1] - window_height/2
    @cursor.x = @x + 126 + Cursor_X - @nx + window_width/2
    @cursor.y = @y + fitting_height(2) + 24 + Cursor_Y - @ny + window_height/2
    unless @index == index
      @index = index
      @icon.bitmap.dispose unless @icon.bitmap
      @icon.bitmap = Cache.world_map($lune_map_info[index]['Icon'])
    end
      @icon.x = $lune_map_info[index]['Position'][0] + 160 - @nx
      @icon.y = $lune_map_info[index]['Position'][1] + 80 - @ny
    if @x > @bitmap.width + 24 - window_width
      @nx = @bitmap.width + 24 - window_width
    elsif @x < 0
      @nx = 0
    else
      @nx = @x
    end
    if @y > @bitmap.height + 24 - window_height
      @ny = @bitmap.height + 24 - window_height
    elsif @y < 0
      @ny = 0
    else
      @ny = @y
    end
  end
end
Hey its me that created the script X)... I'll tell you the truth, the reason of the lag was because of bad BAD HORRIBLE coding haha... Sorry about that, it was when I was still learning to code. I am clearing and recreating the images which is why the issues are happening, about it working for bigger pictures, it shouldn't work betther haha, I think maybe it's some script together with this that is lagging.

Anyway I tried to make some adjustments, try this out if you can. You can try to replace Theo's fix, just to test it out. (Sorry Theo for my bad code 🙁)
Ruby:
class Window_ShowMap < Window_Base
  #--------------------------------------------------------------------------
  # * Renovação
  #--------------------------------------------------------------------------
  def refresh(index)
    @x += 10 if @x <= $lune_map_info[index]['Position'][0] - window_width/2
    @x -= 10 if @x >= $lune_map_info[index]['Position'][0] - window_width/2
    @y += 10 if @y <= $lune_map_info[index]['Position'][1] - window_height/2
    @y -= 10 if @y >= $lune_map_info[index]['Position'][1] - window_height/2
    @cursor.x = @x + 126 + Cursor_X - @nx + window_width/2
    @cursor.y = @y + fitting_height(2) + 24 + Cursor_Y - @ny + window_height/2
    unless @index == index
      @index = index
      @icon.bitmap.dispose unless @icon.bitmap
      @icon.bitmap = Cache.world_map($lune_map_info[index]['Icon'])
    end
      @icon.x = $lune_map_info[index]['Position'][0] + 160 - @nx
      @icon.y = $lune_map_info[index]['Position'][1] + 80 - @ny
    if @x > @bitmap.width + 24 - window_width
      @nx = @bitmap.width + 24 - window_width
    elsif @x < 0
      @nx = 0
    else
      @nx = @x
    end
    if @y > @bitmap.height + 24 - window_height
      @ny = @bitmap.height + 24 - window_height
    elsif @y < 0
      @ny = 0
    else
      @ny = @y
    end
  end
end


Hey Raizen. Thanks for replying! I tried this fix, at first I got this error message
1586271350847.png


So I added a "def dispose" into the script. Which kinda works and lets you open the map once, once you go out of the map the cursor and icon stay off the map for a second and then disappear too.

1586271449730.png


Then when trying to go back into the map again after exiting once, I got the same error I had at first.

Hmmm
Oops sorry, I put it the opposite way. If it still doesn't work, later today I will be able to test it out and I'll help you, just let me know!

Ruby:
class Window_ShowMap < Window_Base
  #--------------------------------------------------------------------------
  # * Renovação
  #--------------------------------------------------------------------------
  def refresh(index)
    @x += 10 if @x <= $lune_map_info[index]['Position'][0] - window_width/2
    @x -= 10 if @x >= $lune_map_info[index]['Position'][0] - window_width/2
    @y += 10 if @y <= $lune_map_info[index]['Position'][1] - window_height/2
    @y -= 10 if @y >= $lune_map_info[index]['Position'][1] - window_height/2
    @cursor.x = @x + 126 + Cursor_X - @nx + window_width/2
    @cursor.y = @y + fitting_height(2) + 24 + Cursor_Y - @ny + window_height/2
    unless @index == index
      @index = index
      @icon.bitmap.dispose if @icon.bitmap
      @icon.bitmap = Cache.world_map($lune_map_info[index]['Icon'])
    end
      @icon.x = $lune_map_info[index]['Position'][0] + 160 - @nx
      @icon.y = $lune_map_info[index]['Position'][1] + 80 - @ny
    if @x > @bitmap.width + 24 - window_width
      @nx = @bitmap.width + 24 - window_width
    elsif @x < 0
      @nx = 0
    else
      @nx = @x
    end
    if @y > @bitmap.height + 24 - window_height
      @ny = @bitmap.height + 24 - window_height
    elsif @y < 0
      @ny = 0
    else
      @ny = @y
    end
  end
end
Oops sorry, I put it the opposite way. If it still doesn't work, later today I will be able to test it out and I'll help you, just let me know!

Ruby:
class Window_ShowMap < Window_Base
  #--------------------------------------------------------------------------
  # * Renovação
  #--------------------------------------------------------------------------
  def refresh(index)
    @x += 10 if @x <= $lune_map_info[index]['Position'][0] - window_width/2
    @x -= 10 if @x >= $lune_map_info[index]['Position'][0] - window_width/2
    @y += 10 if @y <= $lune_map_info[index]['Position'][1] - window_height/2
    @y -= 10 if @y >= $lune_map_info[index]['Position'][1] - window_height/2
    @cursor.x = @x + 126 + Cursor_X - @nx + window_width/2
    @cursor.y = @y + fitting_height(2) + 24 + Cursor_Y - @ny + window_height/2
    unless @index == index
      @index = index
      @icon.bitmap.dispose if @icon.bitmap
      @icon.bitmap = Cache.world_map($lune_map_info[index]['Icon'])
    end
      @icon.x = $lune_map_info[index]['Position'][0] + 160 - @nx
      @icon.y = $lune_map_info[index]['Position'][1] + 80 - @ny
    if @x > @bitmap.width + 24 - window_width
      @nx = @bitmap.width + 24 - window_width
    elsif @x < 0
      @nx = 0
    else
      @nx = @x
    end
    if @y > @bitmap.height + 24 - window_height
      @ny = @bitmap.height + 24 - window_height
    elsif @y < 0
      @ny = 0
    else
      @ny = @y
    end
  end
end

I tried this code, and it does fix the issue of the icon and cursor appearing and the dispose crash. but the map doesn't render now, and it still lags without Theos fix, and Theos fix will bug out the cursor moving. 😅

1586273322036.png

Alright, sounds good! If you have discord you can reach me at: AllyJamy#6268

Original thread: https://forums.rpgmakerweb.com/threads/lune-world-map-framerate-bug-issue-help.119912/