[RMXP] Editing On-Map Menu

Started by Zangetsu, February 13, 2016, 12:58:34 am

Previous topic - Next topic

Zangetsu

So, I'm using the On-Map Menu by Bigace360. I edited it a little to allow the menu to only open when there's a switch on and when a certain key is pressed. Also, the menu opens only when there are common events attached to items. To allow it to open with "O", I used Glitchfinder's Key Module.

This has worked well, and the menu can open anytime even when I have text appearing on the screen. I love this, and I want to keep it this way. However, the common event that I have attached is supposed to show a picture that the player can press "X" to exit from. But when I open the common event, the on-map menu closes, and the text continues running on screen. This is a problem.

What I would like to do is revise the script to have the menu remain open WHILE the common event runs. Then, you can press "X" to stop exit the picture and then return to the menu. The menu will not close until the common event is run, when "X" is pressed. The main objective is to allow the player to view the picture without the menu closing and without the text continuing.

That's what I'd like, if anyone can help me or direct me to how to create it (I only have a little bit of experience in JavaScript, not much), I'd be glad!

Thanks!

The script is below:

#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
# ■ On-Map Item Menu [RMXP]                                       
# ■ Author: Bigace360   
# ■ Version: 1.0
# ■ Date: Jan. 17, 2013
# ■ Blog: http://bigaceworld.wordpress.com/
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#                               VERSION HISTORY                                #
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
# 01.17.2013 (v1.00) - Started and Finished Script
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#                                INTRODUCTION                                  #
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
# This script allows the player to access the on-map item menu by pressing the
# [Shift] button on the keyboard. The items that show up on the on-map item menu
# are only items that will begin common events.
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#                                  SECTIONS                                    #
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#  ■ Game_Objects
# ** Warrior_Engine Module
# ** Game_Party
#
#  ■ Windows
# ** Window_Map_Item
#
#  ■ Scenes
# ** Scene_Map
#
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#
# Credits/Thanks:
#   - Bigace360, for the script.
#
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#                     Script Conflicts and Compatability                       #
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Compatibility
#   Requires the script 'Warrior Engine - XP Core Engine' v1.15 or higher
#
# ● Alias methods
#   class Scene_Map
#     def update
#
# ● Overwrite methods
#   class Scene_Map
#     def main
#
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#
#===============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death,
# and/or halitosis so edit at your own risk.
#===============================================================================
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ■ Warrior Engine (Setting module for the Warrior Engine)
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
module Warrior_Engine
#=============================================================================
# ▼ Warning DO NOT TOUCH THIS MODULE, altering this will ruin any chances of
#   any script that requires this engine to run.
#
# For Configurations go to Module Core below this one.
#=============================================================================
module MESSAGE
#--------------------------------------------------------------------------
# * required
#   This method checks for the existance of the basic module and other
#   WARRIOR scripts required for this script to work, don't edit this
#--------------------------------------------------------------------------
def self.required(name, req, version, type = nil)
if !$ace_script[:ace_warrior_module]
msg = "The script '%s' requires the script\n"
msg += "'Warrior_Engine' v%s or higher above it to work properly\n"
msg += "Go to http://bigaceworld.wordpress.com/ to download this script."
print(sprintf(msg, self.script_name(name), version))
exit
else
self.required_script(name, req, version, type)
end
end
#--------------------------------------------------------------------------
# * script_name
#   Get the script name base on the imported value, don't edit this
#--------------------------------------------------------------------------
def self.script_name(name, ext = "WE")
name = name.to_s.gsub("_", " ").upcase.split
name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
name.join(" ")
end
end
end

$ace_script ||= {}
$ace_script[:on_map_item_menu] = 1.0
Warrior_Engine::MESSAGE.required(:on_map_item_menu, :ace_warrior_module, 1.15, :above)

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ■ Game_Party
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Game_Party
def items
result = []
@items.keys.sort.each {|i| result << $data_items[i] if @items[i] > 0}
@weapons.keys.sort.each {|i| result << $data_weapons[i] if @weapons[i] > 0}
@armors.keys.sort.each {|i| result << $data_armors[i] if @armors[i] > 0}
return result
end
  def consume_item(item)
    lose_item(item.id, 1) if item.is_a?(RPG::Item) && item.consumable
  end
end

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ■ Window_Map_Item
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Window_Map_Item < Window_Selectable
def initialize
super(180, 0, 300, 128)
@column_max = 1
select(0)
refresh
hide
deactivate
end
def line_height;       return 32;  end
def translucent_alpha; return 160; end
def standard_padding;  return 16;  end
def fitting_height(line_number)
(line_number * line_height) + (standard_padding * 2)
end
def visible_line_number
return [[128, @item_max].min, 2].max
end
def item; return @data[index]; end
def include?(item)
    return false if item.nil?
    return false unless item.is_a?(RPG::Item)
    return false if item.common_event_id == 0
    return true
end
def enable?(item); return $game_party.item_can_use?(item); end
def refresh
self.contents.dispose unless self.contents.nil?
self.contents = nil unless self.contents.nil?
    select(0) unless @starting
    @starting = true
@data = []
    make_item_list
@item_max = @data.size
    select([[self.index, @item_max-1].min, 0].max)
    self.height = fitting_height(visible_line_number)
    self.y = 300 - self.height
    self.z = 1000
self.contents = Bitmap.new(width - 32, row_max * 32) if @item_max > 0
@item_max.times {|i| draw_item(i)} if @item_max > 0
end
  def make_item_list
    $game_party.items.each {|item| next unless include?(item); @data << item}
  end
def draw_item(index)
rect = item_rect(index)
contents.clear_rect(rect)
item = @data[index]
return if item.nil?
    case item
    when RPG::Item   then number = $game_party.item_number(item.id)
    when RPG::Weapon then number = $game_party.weapon_number(item.id)
    when RPG::Armor  then number = $game_party.armor_number(item.id)
    end
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enable?(item.id))
draw_text(rect, sprintf(':%2d', number), 2)
end
def update_help; @help_window.set_text(item.nil? ? '' : item.description); end
end

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ■ Scene_Map
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Scene_Map
def main
@spriteset = Spriteset_Map.new
@message_window = Window_Message.new
create_map_item_window
Graphics.transition
loop {Graphics.update; Input.update; update; break if $scene != self}
Graphics.freeze
terminate_map_item_window
@spriteset.dispose
@message_window.dispose
if $scene.is_a?(Scene_Title)
Graphics.transition
Graphics.freeze
end
end
def create_map_item_window
@on_map_help_window = Window_Help.new
@on_map_item_window = Window_Map_Item.new
@on_map_item_window.help_window = @on_map_help_window
@on_map_help_window.hide
end
def terminate_map_item_window
return if @on_map_item_window.nil?
@on_map_item_window.dispose
@on_map_item_window = nil
@on_map_help_window.dispose
@on_map_help_window = nil
end
alias update_on_map_item_menu update unless $@
def update
update_on_map_item_menu
if !$game_system.map_interpreter.running?
map_item_window if Keys.trigger?(0x4F)
end
end
def map_item_window
    $game_switches[24] = true
disabled = true
$game_party.items.each do |item|
next unless item.is_a?(RPG::Item)
next unless item.common_event_id >= 0
disabled = false
break
end
return if disabled
$game_system.se_play($data_system.decision_se)
@on_map_item_window.refresh
@on_map_item_window.show.activate
@on_map_help_window.show
loop do
update_basic
@on_map_help_window.update
@on_map_item_window.update
if Keys.press?(0x50) or Keys.press?(0x0D)
$game_system.se_play($data_system.decision_se)
item = @on_map_item_window.item
        $game_switches[24] = true
$game_temp.common_event_id = item.common_event_id
$game_party.consume_item(item)
break
elsif Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
        $game_switches[24] = false
break
end
end
@on_map_item_window.hide.deactivate
@on_map_help_window.hide
    $game_switches[24] = false
loop do
break if @on_map_item_window.hide.deactivate
update_basic
@on_map_help_window.update
@on_map_item_window.update
end
end
def update_basic
Graphics.update
Input.update   
$game_map.update           
@spriteset.update             
end
end
My name is Kitsuki.

KK20

Pretty much throwing it out there that this is probably impossible with the current state of your scripts. What you're requesting is essentially everything your scripts were not designed to do.

The on-map menu isn't truly an "on-map" menu. While the map graphical elements are updating, all the actual Scene_Map#update code is ignored entirely while the menu is open. There is a work-around, but handling the common event is an entirely different problem now. My suggestion would be to make your common event have some script call to tell the menu to reopen/reactivate. I take it your item calls a common event that shows a picture and turns on a switch that will activate another common event that is set to be a parallel process, which will erase the picture when the button is pressed.

All that is fine, but the "without the text continuing" is something you'll have to figure out on your own. The custom message system script you're using might have some kind of pause function. The fact that you say the messages keep appearing when the menu is open is definitely awkward in design, especially when I just said the menu script ignores the entirety of Scene_Map#update, which updates the message window. Not only that but the menu isn't even allowed to open if there's an event running.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

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

Join the CP Discord Server!