RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[VX:SOLVED] Help with YERD Common Event Menu

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 75
RMRK Junior
I'm using YERD Common Event Menu but then I want it to be able to access from the Menu, so I try to learn some scripting and make it like this...

Spoiler for:
Code: [Select]
class Scene_Menu < Scene_Base
 
  alias kk_create_command create_command_window
  def create_command_window
    kk_create_command
    s1 = Vocab::item
    s2 = Vocab::skill
    s3 = Vocab::equip
    s4 = Vocab::status
    s5 = Vocab::save
    s6 = Vocab::game_end
    s7 = "Memory List"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s7, s5, s6])
    @command_window.index = @menu_index
  end

  alias kk_update_comselect update_command_selection
  def update_command_selection
    kk_update_comselect
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      if $game_party.members.size == 0 and @command_window.index < 4
        Sound.play_buzzer
        return
      elsif $game_system.save_disabled and @command_window.index == 4
        Sound.play_buzzer
        return
      end
      Sound.play_decision
      case @command_window.index
      when 0      # Item
        $scene = Scene_Item.new
      when 1,2,3  # Skill, equipment, status
        start_actor_selection
      when 4      # Common Event Menu
        $game_variables[YE::EVENT::CE_MENU_VARIABLE] = 3
        $scene = Scene_Common_Event_Menu.new
      when 5      # Save
        $scene = Scene_File.new(true, false, false)
      when 6      # End Game
        $scene = Scene_End.new
      end
    end
  end
end

But the problem arise when I exit the Common Event Menu, it return me to Map instead of Menu...
I tried to fix this as much as I can, but I can't fix this yet, can anyone help me with this? I'd be really thankful if anyone can fix me this problem....
and oh, if you find that my scripting above still need improvement in anywhere, do tell, I'd love to learn more, too.


Oh, here is YERD's script if you don't have any....
Spoiler for:
Code: [Select]
#===============================================================================
#
# Yanfly Engine RD - Common Event Menu
# Last Date Updated: 2009.06.12
# Level: Normal, Hard
#
# Similar to the Common Event Shop, the Common Event Menu lets you create your
# menus to list various common event options. Now, you don't have to use all of
# those obnoxiously tedious Show Choice branches and conditional branches just
# to let the player get somewhere in range.
#
# This script lets you create your own generated common event menus with ease.
# Set the style of the menu, the nature of the menu, and the contents of the
# menu. Afterwards, set the switches (if required) for the common events to
# even appear, any pictures to go along with it, and descriptions on what the
# common event can do for the player.
#
#===============================================================================
# Updates:
# ----------------------------------------------------------------------------
# o 2009.06.12 - Finished script.
# o 2009.06.11 - Started script.
#===============================================================================
# Instructions
#===============================================================================
#
# First, bind CE_MENU_VARIABLE to the variable you wish to launch common event
# menus with.
#
# Scroll down and edit the CE_MENU_HASH. This will reflect what common events
# appear in those menus, the style of the menu, and the title associated with
# the menu.
#
# Scroll down and edit the CE_MENU_ITEMS. This will determine how common events
# can be shown, what switches they require, and if it will display any pictures
# along with it.
#
# Then, to launch the menu, just change the CE_MENU_VARIABLE variable to the
# menu ID you want to launch. Simple as that.
#
#===============================================================================
# Style Names
# "General" - A very normal kind of menu.
# "Compact" - A smaller version of the General style.
# "Double"  - Displays two columns for the menu.
# "Bottom"  - Aligns the choices at the bottom of the screen.
# "Lefty"   - Aligns the choices to the left side of the screen.
# "Righty"  - Aligns the choices to the right side of the screen.
# "Gimmick" - A pretty gimmicky style.
#===============================================================================
#
# Compatibility
# - Alias: Game_Interpreter: command_122
#
#===============================================================================

$imported = {} if $imported == nil
$imported["CommonEventMenu"] = true

module YE
  module EVENT
   
    # This is the variable that triggers the kind of shop you want to open.
    CE_MENU_VARIABLE = 1
   
    #-------------------------------------------------------------------------
    # Use the following hash to determine what common events you can launch
    # from that menu ID. You can set the style, whether or not the player can
    # cancel out of the menu, and the title of the menu. Of course, you also
    # set what common events can be launched from this menu, too.
    #
    # Style Name - Style name used. Look in the instructions to view styles.
    # Cancel     - Can the player cancel out of the menu?
    # Title      - Title used for the menu.
    # [Array]    - Common events allowed to be choosen in the menu.
    #-------------------------------------------------------------------------
    CE_MENU_HASH ={ # Follow the example.
    # MenuID => [ Style Name, Cancel, Title
           1 => [  "Gimmick",   true, "Common Event Teleporter",
                [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
                ], # The above array lists the common events selectable.
               
           2 => [  "General",   true, "Yet another common event launcher.",
                [1, 2, 3, 4, 5, 6]
                ], # The above array lists the common events selectable.
               
           3 => [  "Double",   true, "Double the columns!",
                [1, 2, 3, 4]
                ], # The above array lists the common events selectable.
    } # Do not remove this.
   
    #-------------------------------------------------------------------------
    # Use the following hash to determine how you want your common events to
    # appear. To hide some items, set a switch number to the value shown. To
    # display a picture along with the common event, include the picture name.
    # To change the font size used, set the size. And finally, you can adjust
    # the description given to the common event to be launched.
    #
    # Switch  - Switch required to be on for it to appear. nil for no switch.
    # Picture - Picture shown in the display window. nil for no picture shown.
    # Size    - Font size used for the display window.
    # Descrip - Description used for event. Use | to create a new line.
    #-------------------------------------------------------------------------
    CE_MENU_ITEMS ={ # Follow the example.
    # ItemID => [Switch,  Picture, Size, Description]
           1 => [   nil,      nil,   16, "Teleports you to Capitalia!"],
           2 => [   nil,      nil,   16, "Teleports you to Subclassia!"],
           3 => [   nil,      nil,   16, "Teleports you to Eqskislo-|vatia!"],
           4 => [   nil,      nil,   16, "Teleports you to Magma-|molten!"],
           5 => [   nil,      nil,   16, "Teleports you to Yerd Town!"],
           6 => [   nil,      nil,   16, "Teleports you to Alternate|Capitalia!"],
           7 => [   nil,      nil,   16, "Teleports you to The|Beyond!"],
           8 => [   nil,      nil,   16, "Teleports you to Anibat|Constria!"],
           9 => [   nil,      nil,   16, "Teleports you to Wonganistan!"],
          10 => [     5,      nil,   16, "Teleports you to Margaret's|Castle!"],
    } # Do not remove this.
   
  end # EVENT
end # YE

#===============================================================================
# Editting anything past this point may potentially result in causing computer
# damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
# Therefore, edit at your own risk.
#===============================================================================

#===============================================================================
# Game_Interpreter
#===============================================================================

class Game_Interpreter

  #--------------------------------------------------------------------------
  # alias control variables
  #--------------------------------------------------------------------------
  alias command_122_cemenu command_122 unless $@
  def command_122
    n = command_122_cemenu
    if @params[0] == YE::EVENT::CE_MENU_VARIABLE and !$game_temp.in_battle and
    $game_variables[YE::EVENT::CE_MENU_VARIABLE] != 0
      $scene = Scene_Common_Event_Menu.new
    end
    return n
  end
 
end # Game_Interpreter

#===============================================================================
# Scene_Common_Event_Menu
#===============================================================================

class Scene_Common_Event_Menu < Scene_Base
 
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize
    menu_id = $game_variables[YE::EVENT::CE_MENU_VARIABLE]
    @style  = YE::EVENT::CE_MENU_HASH[menu_id][0]
    @cancel = YE::EVENT::CE_MENU_HASH[menu_id][1]
    @title  = YE::EVENT::CE_MENU_HASH[menu_id][2]
    @items  = YE::EVENT::CE_MENU_HASH[menu_id][3]
  end
 
  #--------------------------------------------------------------------------
  # start
  #--------------------------------------------------------------------------
  def start
    super
    @spriteset = Spriteset_Map.new
    create_windows
    refresh_display
  end
 
  #--------------------------------------------------------------------------
  # create_windows
  #--------------------------------------------------------------------------
  def create_windows
    #---
    if @style == "General" # General Style
      @title_window = Window_Base.new(0, 0, 544, 56)
      @title_window.contents.draw_text(4, 0, 504, 24, @title, 1)
      @command_width = 272
      @columns = 1
      create_command_window
      @command_window.x = 0
      @command_window.y = 56
      @command_window.height = 360
      @display_window = Window_Event_Display.new(272, 56, 272, 360, "tall")
      return
    end
    #---
    if @style == "Compact" # Compact Style
      @title_window = Window_Base.new(48, 48, 448, 56)
      @title_window.contents.draw_text(4, 0, 408, 24, @title, 1)
      @command_width = 224
      @columns = 1
      create_command_window
      @command_window.x = 48
      @command_window.y = 104
      @command_window.height = 264
      @display_window = Window_Event_Display.new(272, 104, 224, 264, "tall")
      return
    end
    #---
    if @style == "Double" # Double Style
      @title_window = Window_Base.new(0, 0, 544, 56)
      @title_window.contents.draw_text(4, 0, 504, 24, @title, 1)
      @command_width = Graphics.width
      @columns = 2
      create_command_window
      @command_window.x = 0
      @command_window.y = 56
      @command_window.height = 232
      @display_window = Window_Event_Display.new(0, 288, 544, 128, "wide")
      return
    end
    #---
    if @style == "Bottom" # Bottom Style
      @title_window = Window_Base.new(0, 0, Graphics.width, 56)
      @title_window.contents.draw_text(4, 0, Graphics.width-40, 24, @title, 1)
      @command_width = Graphics.width
      @columns = 2
      create_command_window
      @command_window.x = 0
      @command_window.y = Graphics.height - 128
      @command_window.height = 128
      return
    end
    #---
    if @style == "Lefty" # Lefty Style
      @title_window = Window_Base.new(0, 0, 200, 56)
      @title_window.contents.draw_text(4, 0, 160, 24, @title, 1)
      @command_width = 200
      @columns = 1
      create_command_window
      @command_window.x = 0
      @command_window.y = 56
      @command_window.height = Graphics.height - 56 - 128
      @display_window = Window_Event_Display.new(0, 288, 200, 128, "no text")
      return
    end
    #---
    if @style == "Righty" # Righty Style
      @title_window = Window_Base.new(344, 0, 200, 56)
      @title_window.contents.draw_text(4, 0, 160, 24, @title, 1)
      @command_width = 200
      @columns = 1
      create_command_window
      @command_window.x = 344
      @command_window.y = 56
      @command_window.height = Graphics.height - 56 - 128
      @display_window = Window_Event_Display.new(344, 288, 200, 128, "no text")
      return
    end
    #---
    if @style == "Gimmick" # Compact Style
      @title_window = Window_Base.new(48, 48, 448, 56)
      @title_window.contents.draw_text(4, 0, 408, 24, @title, 1)
      @dummy_window = Window_Base.new(48, 104, 448, 264)
      @command_width = 224
      @columns = 1
      create_command_window
      @command_window.x = 48
      @command_window.y = 104
      @command_window.height = 264
      @display_window = Window_Event_Display.new(272, 104, 224, 264, "tall")
      @command_window.opacity = 0
      @display_window.opacity = 0
      return
    end
  end
 
  #--------------------------------------------------------------------------
  # create_command_window
  #--------------------------------------------------------------------------
  def create_command_window
    commands = []
    @data = []
    for item_id in @items
      next unless YE::EVENT::CE_MENU_ITEMS.include?(item_id)
      next if YE::EVENT::CE_MENU_ITEMS[item_id][0] != nil and
      !$game_switches[YE::EVENT::CE_MENU_ITEMS[item_id][0]]
      item_name = $data_common_events[item_id].name
      commands.push(item_name)
      @data.push(item_id)
    end
    @command_window = Window_Command.new(@command_width, commands, @columns)
    @last_id = commands.size + 1
  end
 
  #--------------------------------------------------------------------------
  # terminate
  #--------------------------------------------------------------------------
  def terminate
    super
    @spriteset.dispose
    @title_window.dispose if @title_window != nil
    @command_window.dispose if @command_window != nil
    @display_window.dispose if @display_window != nil
    @dummy_window.dispose if @dummy_window != nil
  end
 
  #--------------------------------------------------------------------------
  # update
  #--------------------------------------------------------------------------
  def update
    super
    @spriteset.update
    $game_map.update
    update_input
  end
 
  #--------------------------------------------------------------------------
  # update_input
  #--------------------------------------------------------------------------
  def update_input
    @command_window.update
    if @last_id != @command_window.index
      @last_id = @command_window.index
      refresh_display
    end
    if Input.trigger?(Input::B) and @cancel
      Sound.play_cancel
      $game_variables[YE::EVENT::CE_MENU_VARIABLE] = 0
        $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      if @data == []
        Sound.play_buzzer
        return
      end
      Sound.play_decision
      $game_temp.common_event_id = @data[@command_window.index]
      $game_variables[YE::EVENT::CE_MENU_VARIABLE] = 0
      $scene = Scene_Map.new
    end
  end
 
  #--------------------------------------------------------------------------
  # refresh_display
  #--------------------------------------------------------------------------
  def refresh_display
    return if @display_window == nil
    @display_window.refresh(@data[@command_window.index])
  end
 
end # Scene_Common_Event_Menu

#===============================================================================
# Window_Event_Display
#===============================================================================

class Window_Event_Display < Window_Base
 
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(x, y, w, h, type = "tall")
    super(x, y, w, h)
    @type = type
    menu_id = $game_variables[YE::EVENT::CE_MENU_VARIABLE]
    first_item = YE::EVENT::CE_MENU_VARIABLE[menu_id]
  end
 
  #--------------------------------------------------------------------------
  # refresh
  #--------------------------------------------------------------------------
  def refresh(id = nil)
    self.contents.clear
    return if id == nil
    return unless YE::EVENT::CE_MENU_ITEMS.include?(id)
    txsize = YE::EVENT::CE_MENU_ITEMS[id][2]
    self.contents.font.size = txsize
    if YE::EVENT::CE_MENU_ITEMS[id][1] != nil # Draw a picture.
      name = YE::EVENT::CE_MENU_ITEMS[id][1]
      bitmap = Cache.picture(name)
      rect = Rect.new(0, 0, bitmap.width, bitmap.height)
      self.contents.blt(0, 6, bitmap, rect)
      if @type == "tall"
        dy = bitmap.height + (txsize / 2)
        dx = 0
      elsif @type == "wide"
        dx = bitmap.width + (txsize / 2)
        dy = 0
      end
      bitmap.dispose
    else
      dy = 0
      dx = 0
    end
    return if @type == "no text"
    text = YE::EVENT::CE_MENU_ITEMS[id][3]
    nwidth = Graphics.width
    buf = text.gsub(/\\N(\[\d+\])/i) { "\\__#{$1}" }
    lines = buf.split(/(?:[|]|\\n)/i)
    lines.each_with_index { |l, i|
      l.gsub!(/\\__(\[\d+\])/i) { "\\N#{$1}" }
      self.contents.draw_text(dx, i * txsize + dy, nwidth, WLH, l, 0) }
  end
 
end # Window_Event_Display

#===============================================================================
#
# END OF FILE
#
#===============================================================================
« Last Edit: July 12, 2012, 09:52:41 PM by kairi_key »

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
Go to line 326 in YERD Common Event Script, and replace this
Code: [Select]
$scene = Scene_Map.new
with this
Code: [Select]
$scene = Scene_Menu.new(4)


I'd also recommend not messing around with the default scripts as they can cause unforeseen errors in any new custom scripts you might decide to use.
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

**
Rep: +0/-0Level 75
RMRK Junior
Oh, sorry to not mention this, lol.

I want to use YERD's script for other things, too, so only one Common Event Menu that I assigned(which is 3) must return to Menu.
Other Common Event Menus can return to Map as default.

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
Replace
Code: Line 323 [Select]
if Input.trigger?(Input::B) and @cancel
      Sound.play_cancel
      $game_variables[YE::EVENT::CE_MENU_VARIABLE] = 0
        $scene = Scene_Map.new


With
Code: [Select]
if Input.trigger?(Input::B) and @cancel
      Sound.play_cancel
      if $game_variables[YE::EVENT::CE_MENU_VARIABLE] == 3
        $game_variables[YE::EVENT::CE_MENU_VARIABLE] = 0
        $scene = Scene_Menu.new(4)
      else
        $game_variables[YE::EVENT::CE_MENU_VARIABLE] = 0
        $scene = Scene_Map.new
      end
« Last Edit: July 12, 2012, 09:11:57 PM by D&P3 »
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

**
Rep: +0/-0Level 75
RMRK Junior
It didn't work.

Well, it did return me to the Menu, but, now, every Common Event Menu return to the Menu first.

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
It works fine for me, I'm guessing you must be calling the common event menu using the same variable everytime.


Code: [Select]
      when 0      # Item
        $game_variables[YE::EVENT::CE_MENU_VARIABLE] = 1
        $scene = Scene_Common_Event_Menu.new
      when 1,2,3  # Skill, equipment, status
        $game_variables[YE::EVENT::CE_MENU_VARIABLE] = 2
        $scene = Scene_Common_Event_Menu.new
      when 4      # Common Event Menu
        $game_variables[YE::EVENT::CE_MENU_VARIABLE] = 3
        $scene = Scene_Common_Event_Menu.new
When I fiddled with that, it all went exactly as I wanted it to.
Don't copy that code, it's not something you want to be using. That was just for testing.

You're probably gonna have to be more specific on what you're doing if it's not working for you.
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

**
Rep: +0/-0Level 75
RMRK Junior
Well, I simply replace those four lines with your new nine lines.

This is how I test it out.
I create an NPC that will open one Common Event Menu with variable's value of 2.
Then I test the game out.
I open the Menu, and open Common Event Menu 3
I exit, and it return to Menu, yay!
But then I speak to that NPC to make sure.
It brings me to Common Event Menu 2.
And I exit it... but it brings me to the Menu instead of Map.

I even try to run it the other way around by talk to the NPC first then open the Menu, but it all result in the same thing; return to the Menu.
And it's even on the game that only has those 2 scripts(YERD's and mine)

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
You mind uploading this project?

I'm not understanding why it isn't working for you...
So being able to see it will help me know what's happening.
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

**
Rep: +0/-0Level 75
RMRK Junior
Oh, wait, it works now!

I just forgot to delete my attempt in doing it, lol, sorry.
And thanks again for the help =w=b