08-25-2011, 08:20 AM
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?
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:
<?php
#==============================================================================
# ■ 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 = [101, 102, 402, 403, 103, 104, 105, 106, 111, 411, 112,
403, 113, 115, 116, 117, 118, 119, 121, 122, 123, 124, 125, 126, 127,
128, 129, 131, 132, 133, 134, 135, 136, 201, 202, 203, 204, 205, 206,
207, 208, 209, 210, 221, 222, 223, 224, 225, 231, 232, 233, 234, 235,
236, 241, 241, 242, 245, 246, 247, 248, 249, 250, 251, 301, 601, 602,
603, 302, 303, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321,
322, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 351, 352, 353,
354, 355, ]
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