[RMXP]Help with Transparent menu script

Started by jayje, October 16, 2018, 01:44:44 pm

Previous topic - Next topic

jayje

October 16, 2018, 01:44:44 pm Last Edit: October 16, 2018, 01:47:22 pm by jayje
Hi gang!  :)

I'm using LittleDrago's Transparent Menu script, but I have a problem :^_^\':. It seems the script interferes with variable manipulation. By that, I mean it delayed the changing of a variable's value by a few frames. Usually this wouldn't be a problem, but it's slowing down a vital mechanic of my game, which will affect player's enjoyment.

Here's the script:

Spoiler: ShowHide
#==============================================================================
# ** [XP] Drago - Translucent Menu
# Version : 2.00
# Contact : littledrago.blogspot.com / forum.chaos-project.com
#==============================================================================

module Transparency
 
  Scene = [Scene_Menu, Scene_Item, Scene_Skill, Scene_Equip, Scene_Status,
           Scene_Save, Scene_End,  Scene_Shop,  Scene_Name,  Scene_Debug]
           
  No_Pause_Menu = true
           
end

($imported ||= {})[:drg_translucent_menu] = 2.00
#==============================================================================
# ** Object
#------------------------------------------------------------------------------
#  This class is superclass for all class
#==============================================================================
class Object
  #--------------------------------------------------------------------------
  # * self.menu_transparency
  #--------------------------------------------------------------------------
  def self.menu_transparency
    unless method_defined?(:menu_transparency_update)
      send(:alias_method, :menu_transparency_main,   :main)
      send(:alias_method, :menu_transparency_update, :update)
    end
    send(:define_method, :main) do |*args|
      @spriteset = Spriteset_Map.new if $game_map && $game_map.map_id != 0
      @menu_transparency = !@spriteset.nil?
      menu_transparency_main(*args)
      @spriteset && @spriteset.dispose
    end
    send(:define_method, :update) do |*args|
      menu_transparency_update(*args)
      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
  end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================
class Window_Base
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias_method :menu_transparency_main, :initialize
  #--------------------------------------------------------------------------
  # * Aliased method: initialize
  #--------------------------------------------------------------------------
  def initialize(*args)
    menu_transparency_main(*args)
    self.opacity = 255 if $scene.instance_variable_get(:@menu_transparency)
  end
end

Transparency::Scene.each {|scene| scene.menu_transparency }


Any fixes welcomed. Thanks for your help.


KK20

How are you testing this? What made you realize there was a delay? And the variables you're talking about are the Game_Variables you can manipulate through event commands right?





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

jayje

Yes these are variables that you use in the regular events menu. I've tested it using a cond. branch to see if the variable changes or not. When the variable is "0", do one thing, but if it isn't, make a screen flash and play a sound. I've tried it with and without the script and noticed there was a delay.


KK20

I'm not noticing anything. Can you reproduce in a clean project and upload it?





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

jayje

I can give you a google drive link. https://drive.google.com/drive/folders/19wpA6hy8Grw8r2tkTCh7GSG1LYdiPlk9?usp=sharing. You'll notice that when you start you're asked to use an item. When you heal with potion a variable (VAR1) is supposed to be increased by 1. But the script pauses this for some reason and then lets it update.

Thanks for looking.



KK20

The same effect happens whether the script is there or not. Drago's script has a parameter to allow the map to still update normally while the menu is open. This results in the screen flash occurring when the item scene is opened a second time (after using the potion).

What's actually going on is the order of events running. The parallel process map event is executing first BEFORE the item's common event executes. Throw in a Wait for 1 frame at the top of the parallel process to fix that.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

jayje

Maybe I mispoke. What I'm trying to do is have the flash happen once the variable is changed. I tried what you told me and the same thing happened. When I removed the script the Flash occured once the variable changed(which was automatic).


KK20

Taking a step back here.
What exactly are you trying to achieve? Maybe you're using the wrong script for the job. The script is called "Translucent Menu" but you changed the opacity to 255 (i.e. no longer translucent). The whole point of this script is to be able to see the map behind the menu windows.

The "bug" you're experiencing is because of No_Pause_Menu being true. It causes the event interpreter to keep running while the player is in the menu. Upon changing to Scene_Item, the Parallel Process fires its event to set Variable 2 = Variable 1, and then does the conditional branch check. It pauses once it reaches the Show Text command, waiting for the player to exit out of the menu. If you use the potion, variable 1 does get changed, but the parallel process has already fired past the conditional branch check, thus it kicks you back into Scene_Item again.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

jayje

October 16, 2018, 10:35:27 pm #8 Last Edit: October 16, 2018, 10:40:48 pm by jayje
I was wanting the just show the menu without the weird black background, if i could. Also, if I were to set the Puase to false would that fix the "bug"?

EDIT: Yes That Fixed It. THANKS FOR POINTING THAT OUT.



KK20

Okay I don't know why your demo has it set to 255 then
self.opacity = 255 if $scene.instance_variable_get(:@menu_transparency)


And yes, setting it to false and putting the Wait 1 frame should fix your problem. What you'll get as a background is just a "snapshot" of the map though. Nothing will animate or move around. If you still want things to move around, then you're going to need to put some safety checks in your events.

Make a conditional branch, Tab 4->Script, put
!$scene.is_a?(Scene_Map)

uncheck the box for when conditions do not apply, OK.
Inside the branch, put an Exit Event Processing.

(alternatively, use a Script event command and put inside it
$scene.is_a?(Scene_Map)
It's not super obvious what it's doing but it's an option if you like one-liners)

This way, when the player is in the Menu, the events won't start until they exit out of it. Yes it's more work but there's literally nothing else that can be done script-wise.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!