Save-Point
Allow menu during events - for Visual Novels - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+--- Thread: Allow menu during events - for Visual Novels (/thread-3691.html)



Allow menu during events - for Visual Novels - Taylor - 08-25-2011

In truth, I don't have a plan to release this system public on the basis I don't trust it to be stable. However I am showing it because I would like any pointers as to improvements on how to better handle what I have.

This script allows the menu to be opened during events. Due to the way events are handled in XP, this isn't quite straight-forward. This script backs up events to where they were after the menu was opened (important for re-reading messages), and makes sure to skip the "mid-command" lines RMXP seems to have (things like Show Choice are actually interpreted in multiple lines, not as a single command).

The last point is specifically something I want to watch out for. I have an array there of every command index that leads to an actual command, but I cannot say for certain that this is the most apt way to handle it?

PHP Code:
#==============================================================================
# ■ Visuality System
# ● Core Functions
#==============================================================================

#==============================================================================
# ■ Game_System
#==============================================================================

class Game_System
  
#--------------------------------------------------------------------------
  # ● Alias Functions
  #--------------------------------------------------------------------------
  
alias tayruu_vn_system_init initialize
  
#--------------------------------------------------------------------------
  # ● Public Instance Variables
  #--------------------------------------------------------------------------
  
attr_accessor :oldindex
  attr_accessor 
:leavingmenu
  
#--------------------------------------------------------------------------
  # ● Object Initialization
  #--------------------------------------------------------------------------
  
def initialize
    tayruu_vn_system_init
    
@oldindex = -1
    
@leavingmenu false
  end
end

#==============================================================================
# ■ Interpreter (part 1)
#==============================================================================
class Interpreter
  
#--------------------------------------------------------------------------
  # ● Alias Functions
  #--------------------------------------------------------------------------
  
alias tayruu_vn_interpreter_update update
  
#--------------------------------------------------------------------------
  # ● Frame Update
  #--------------------------------------------------------------------------
  
def update
    
if $game_system.leavingmenu && @list != nil
      
@index $game_system.oldindex 
      
@index -= 1 unless @list[@index].code == 101
      valid_commands 
= [101102402403103104105106111411112,
         
403113115116117118119121122123124125126127,
         
128129131132133134135136201202203204205206,
         
207208209210221222223224225231232233234235
         
236241241242245246247248249250251301601602,
         
603302303311312313314315316317318319320321,
         
322331332333334335336337338339340351352353,
         
354355, ]
      if !
valid_commands.include?(@list[@index].code)
        @
index -= 1
      end
      $game_system
.leavingmenu false
    end
    tayruu_vn_interpreter_update
    $game_system
.oldindex = @index 1 unless @index == nil
  end
end    

#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map SDK::Scene_Base
  
#--------------------------------------------------------------------------
  # ● Frame Update : Message Test
  #--------------------------------------------------------------------------
  
def update_message?
    return 
false
  end
  
#--------------------------------------------------------------------------
  # ● Frame Update : Menu Call
  #--------------------------------------------------------------------------
  
def update_call_menu
    
# If B button was pressed
    
if Input.trigger?(Input::B)
      
# If event is running, or menu is not forbidden
      
unless $game_system.menu_disabled
        
# Set menu calling flag or beep flag
        
$game_temp.menu_calling true
        $game_temp
.menu_beep true
      end
    end
  end
end

#==============================================================================
# ■ Scene_Menu
#==============================================================================
class Scene_Menu SDK::Scene_Base
  
#--------------------------------------------------------------------------
  # ● Alias Functions
  #--------------------------------------------------------------------------
  
alias tayruu_vn_menu_init initialize
  
#--------------------------------------------------------------------------
  # ● Object Initialization
  #--------------------------------------------------------------------------
  
def initialize(menu_index 0)
    
tayruu_vn_menu_init(menu_index)
    
$game_system.leavingmenu true
  end
end 



RE: Allow menu during events - for Visual Novels - MetalRenard - 08-25-2011

Oh brill, that's handy, very handy. Thanks for sharing!


RE: Allow menu during events - for Visual Novels - Taylor - 08-25-2011

Minor update to avoid an error if you open the menu before any events happened. ... which wouldn't show up in a demo I'd imagine, but better safe than sorry 'case it affected other things.