Script request - Map updating while main menu is open

Started by Soulshaker3, April 12, 2014, 03:35:49 pm

Previous topic - Next topic

Soulshaker3

I need a script that allows the main menu to be still open but still refreshes the map and does not accept input in the player like when the menu is open the player can't more or do any actions while the map is still updating. Any of you can do that for me?
Hellow?


Soulshaker3

Unfortunatly doesn't work for me, in a blank project it works no problem but in my project it won't i tryed to take out the Spriteset of my menu but it goes with dark background instead of working any idea of what it might be?
Hellow?

Zexion

I will take a crack at it tomorrow did you want a normal menu or modded?

Soulshaker3

I scripted my own menu for my project, it's all about sprites, I only use windows to draw text there so I guess it's modded
Hellow?

Zexion

Yeah it's modified then, so I can't really make any promises because I am also a noob at scripting, but I will promise to try :D

Soulshaker3

Would it work instead of:
Quote$scene = Scene_menu.new

I would just erase the spriteset of the map in the menu from the code and render the images into the Scene_Map itself?
Hellow?

Zexion

Yeah basically all you have to do is alias the windows to the scene map  and then change what happens when you press the menu button so it makes the windows visible instead of opening scene_menu

Edit I will try to do this on my way home but I will need your menu script in order to do it for you

Soulshaker3

April 14, 2014, 08:47:40 pm #8 Last Edit: April 14, 2014, 10:00:24 pm by soulshaker3
My script code is this

Spoiler: ShowHide
class Texto < Window_Base
 def initialize(x,y,w,h)
    super(x,y,w,h)
 end
end

class Scene_Menu  
 #principal
 def initialize(menu_index = 0)
   @menu_index = menu_index
 end

 def main
   $spriteset_m = Spriteset_Map.new
   $fechar = false
   @sprites = [Sprite.new, Sprite.new, Sprite.new, Sprite.new, Sprite.new]
   for i in 0..4
     @sprites[i].bitmap = RPG::Cache.picture("/Menu/op#{i}")
     @sprites[i].x = 76
     if(i!=0)
       @sprites[i].y = @sprites[i-1].y+96
     else
       @sprites[i].bitmap = RPG::Cache.picture("/Menu/op#{0}_s")
       @sprites[i].y = -516
     end
   end
   #Audio.se_play('Audio/SE/' + "msg", 100, 0)
   Audio.se_play('Audio/SE/' + "Menu/orb_dropdown", 100, 0)  
   Graphics.transition
   while @sprites[@menu_index].y != 156
     for i in 0..4
         @sprites[i].y+=24
     end
     Graphics.update
   end
     
   loop do
     @einput = true
     Graphics.update
     Input.update
     update
     if ($scene != self) or $fechar
       break
     end
   end
   Graphics.freeze
   for i in 0..4
     @sprites[i].dispose
   end
   Audio.se_play('Audio/SE/' + "Menu/dialog_close", 100, 0)
   $spriteset_m.dispose
   $fechar = false
 end
   
 def update
    if Input.trigger?(Input::UP)
      if (@menu_index >0)
        for i in 0..3
          for k in 0..4
          @sprites[k].y+=24
          end
          Graphics.update
        end
        Audio.se_play('Audio/SE/' + "Menu/menu_popup", 100, 0)
        @menu_index-= 1
        @sprites[@menu_index].bitmap= RPG::Cache.picture("/Menu/op#{@menu_index}_s")
        @sprites[@menu_index+1].bitmap= RPG::Cache.picture("/Menu/op#{@menu_index+1}")
      end
    elsif Input.trigger?(Input::DOWN)
      if (@menu_index <4)
        for i in 0..3
          for k in 0..4
          @sprites[k].y-=24
          end
          Graphics.update
        end
        Audio.se_play('Audio/SE/' + "Menu/menu_popup", 100, 0)
        @menu_index+= 1
        @sprites[@menu_index].bitmap= RPG::Cache.picture("/Menu/op#{@menu_index}_s")
        @sprites[@menu_index-1].bitmap= RPG::Cache.picture("/Menu/op#{@menu_index-1}")
      end
    end
   
    if Input.trigger?(Input::C)
      Audio.se_play('Audio/SE/' + "Menu/confirm", 100, 0)
      case @menu_index
      when 0
        Menu_items.new(@sprites[@menu_index].x+64,@sprites[@menu_index].y+6)
      when 1
        Menu_skills.new(@sprites[@menu_index].x+64,@sprites[@menu_index].y-150)
      when 2
        while @sprites[2].x !=300
         @sprites[2].x += 16
         Graphics.update
        end
        Menu_status.new
        while @sprites[2].x !=76
          @sprites[2].x -= 16
          Graphics.update
        end
        Input.update
      when 3
        Menu_save.new
      when 4
        Menu_sair.new
      end
     end
     
    if Input.trigger?(Input::B) or $fechar
     while @sprites[0].y != -516
       for i in 0..4
         @sprites[i].y-=24
       end
       Graphics.update
     end
     $scene = Scene_Map.new
    end
  end
end

I'm trying to do what you said but i'll probably fail so yeah...

Edit :Tried to do the map updates but when i close the menu it freezes the screen and then crashes probably the charachter updates but because the game crashes the character isn't updated so yeah i'm leaving that to you
Hellow?

ForeverZer0

Just so you are aware, updating the spriteset during the menu scene does open up the possibility of some bugs, especially depending on the scripts you may be using. Typically they would only be little graphical glitches when the menu is closed and the player returns to the map scene, but it is something to be aware of.

Best option if you are looking to have the map displayed during your menu scene and don't want the map to pause, is to script a menu that doesn't actually change scenes when it is opened, but that is obviously more in-depth.  $game_map needs to be updated in order for the spriteset to really update and give the feel that the game has never paused, and doing that while not in Scene_Map is just asking for problems.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Soulshaker3

April 15, 2014, 07:46:48 am #10 Last Edit: April 15, 2014, 09:56:22 am by soulshaker3
That's what I tryed to do but when it gets to the main loop of the script the map stops updating because basicly it's only updating the graphics and not the map so the map freezes aswell even if i'm not chaning scenes i'm gonna try again today to see if i can see what's going on.

Edit: O M G i feel so dumb right now, the script that drago posted actually works partially it doesn't work in the first and final part of the script when the orbs drop and go up, i guess it is for the Graphics.update funcion but yeah atleast it works partially.

The reason it didn't work in the first place is that i placed the script in the top right after Scene_debug and now it is before main
Hellow?

LiTTleDRAgo

hint :

Spoiler: ShowHide

  def main
    # $spriteset_m = Spriteset_Map.new # Delete this part
    $fechar = false
    @sprites = [Sprite.new, Sprite.new, Sprite.new, Sprite.new, Sprite.new]
    for i in 0..4
      @sprites[i].bitmap = RPG::Cache.picture("/Menu/op#{i}")
      @sprites[i].x = 76
      if(i!=0)
        @sprites[i].y = @sprites[i-1].y+96
      else
        @sprites[i].bitmap = RPG::Cache.picture("/Menu/op#{0}_s")
        @sprites[i].y = -516
      end
    end
    Audio.se_play('Audio/SE/' + "Menu/orb_dropdown", 100, 0)   
    Graphics.transition
    while @sprites[@menu_index].y != 156
      for i in 0..4
          @sprites[i].y+=24
      end
      Graphics.update
      update_map               # Add this part
    end
     
    loop do
      @einput = true
      Graphics.update
      Input.update
      update
      if ($scene != self) or $fechar
        break
      end
    end
    Graphics.freeze
    for i in 0..4
      @sprites[i].dispose
    end
    Audio.se_play('Audio/SE/' + "Menu/dialog_close", 100, 0)
    # $spriteset_m.dispose # Delete this part
    $fechar = false
  end


  def update
     if Input.trigger?(Input::UP)
       if (@menu_index >0)
         for i in 0..3
           for k in 0..4
             @sprites[k].y+=24
           end
           Graphics.update
           update_map               # Add this part
         end
         Audio.se_play('Audio/SE/' + "Menu/menu_popup", 100, 0)
         @menu_index-= 1
         @sprites[@menu_index].bitmap= RPG::Cache.picture("/Menu/op#{@menu_index}_s")
         @sprites[@menu_index+1].bitmap= RPG::Cache.picture("/Menu/op#{@menu_index+1}")
       end
     elsif Input.trigger?(Input::DOWN)
       if (@menu_index <4)
         for i in 0..3
           for k in 0..4
             @sprites[k].y-=24
           end
           Graphics.update
           update_map               # Add this part
         end
         Audio.se_play('Audio/SE/' + "Menu/menu_popup", 100, 0)
         @menu_index+= 1
         @sprites[@menu_index].bitmap= RPG::Cache.picture("/Menu/op#{@menu_index}_s")
         @sprites[@menu_index-1].bitmap= RPG::Cache.picture("/Menu/op#{@menu_index-1}")
       end
     end
     
     if Input.trigger?(Input::C)
       Audio.se_play('Audio/SE/' + "Menu/confirm", 100, 0)
       case @menu_index
       when 0
         Menu_items.new(@sprites[@menu_index].x+64,@sprites[@menu_index].y+6)
       when 1
         Menu_skills.new(@sprites[@menu_index].x+64,@sprites[@menu_index].y-150)
       when 2
         while @sprites[2].x !=300
          @sprites[2].x += 16
          Graphics.update
          update_map               # Add this part
         end
         Menu_status.new
         while @sprites[2].x !=76
           @sprites[2].x -= 16
           Graphics.update
           update_map               # Add this part
         end
         Input.update
       when 3
         Menu_save.new
       when 4
         Menu_sair.new
       end
      end
     
     if Input.trigger?(Input::B) or $fechar
      while @sprites[0].y != -516
        for i in 0..4
          @sprites[i].y-=24
        end
        Graphics.update
        update_map               # Add this part
      end
      $scene = Scene_Map.new
     end
   end

  # Add this method
  def update_map
      return unless $game_temp
      return unless Transparency::No_Pause_Menu
      return if $game_temp.player_transferring
      return if $game_temp.transition_processing
      message = $game_temp.message_window_showing
      @spriteset   && @spriteset.update
      $game_map    && $game_map.update
      $game_system && $game_system.update
      $game_system && (sys = $game_system.map_interpreter) && sys.update
      $game_screen && $game_screen.update
      $game_temp.message_window_showing = true
      $game_player && $game_player.update
      $game_temp.message_window_showing = message
   end


Soulshaker3

It works perfect it only gives a little graphical bug but it works for me, actually the complete menu is composed by 7 scripts can I post the others here and you do your magic?
Hellow?