[RMVX ACE] CHOICE IN MENU

Posts

Pages: 1
Hello,

I'm trying to create a fast travel menu. So far I have that


I would like to have like that


Basically I want to see the fast travel points for each kingdom, instead of having just one list of every points.

I use a script and the command to do it
add_command("feu 1", :feu1)

Thanks !
Marrend
Guardian of the Description Thread
21781
Let me verify what you're trying to do with screenshots.



Here's the "nation" category. If you select "Sucror" here, you get...



...this. If you cancel out, and then select "Espea", you get...



...this. Is something like this the kind of thing you are looking for?

*Edit: Hugely assuming VX Ace here, going off of your user title.
It's on VX Ace indeed.

What I would like will be more

Staerdale Palace_____Wal Pinnacle - Monastery
Glikx Heights
Sraphyhl Peak
Blils Wood


But if not possible, I can use your script too :)
Marrend
Guardian of the Description Thread
21781
So, if I go off the previous example, it might go something more like...



...so? There's a non-zero amount of technicality and behind-the-scenes work here, as these screenshots are based off of an already-made project, of course. However, the general idea is what I'm attempting to capture.
Yep, it's exaclty what I need :)

For the moment, I'm doing my menu with a script based on : http://www.biloucorp.com/creation-dun-shifumi-avec-le-rgss3-16

Everything working so far except that I'm limited to 14 locations because of the length of the menu.

Edit for the link
Marrend
Guardian of the Description Thread
21781
I get a 404 error when trying to access that page. However, I'm not going to worry about that right now.

I don't want to get terribly involved (unless I have to), but, the code might look a little something like..

class Window_Locale < Window_Command
  # Window processing for Item/Skill use for teleportation.
  def initialize
    super(0, 0)
    @list = []
    self.index = 0
    activate
    refresh
  end
    
  def window_width
    return Graphics.width
  end

  def window_height
    # Should equate to the number of visible rows on-screen.
    fitting_height(4)
  end
  
  def col_max
    return 3
  end

  def make_item_list
    # First row
    add_command("R1C1", :locale, true)
    add_command("R1C2", :locale, true)
    add_command("R1C3", :locale, true)

    # Second row
    add_command("R2C1", :locale, true)
    add_command("R2C2", :locale, true)
    add_command("R2C3", :locale, true)
    
    # Third row
    add_command("R3C1", :locale, true)
    add_command("R3C2", :locale, true)
    add_command("R3C3", :locale, true)
    
    # Fourth row
    add_command("R4C1", :locale, true)
    add_command("R4C2", :locale, true)
    add_command("R4C3", :locale, true)

    # And so on.
  end
  
  def item_max
    @list.size
  end
  
  def refresh
    make_item_list
    create_contents
    draw_all_items
  end
end

class Scene_Teleport < Scene_MenuBase
  # Scene processing for Item and/or Skill use of the Locale class.
  attr_accessor :window # The command window.

  def start
    super
    create_locale_window
  end

  def create_locale_window
    @window = Window_Locale.new()
    @window.set_handler(:ok, method(:on_ok))
    @window.set_handler(:cancel, method(:return_scene))
  end
  
  def on_ok
    Sound.play_ok
    case @window.index
    when 0
      # The cursor position is in the upper left.
      $game_player.reserve_transfer(map_id, x, y, face)
      # "map_id" is the map ID to transfer to
      # "x" is the x position on the map to transfer to
      # "y" is the y position on the map to transfer to
      # "face" is the facing of the player character after transition
    when 1
      # The cursor position is in the top-center.
      $game_player.reserve_transfer(map_id, x, y, face)
      # This would use different variables than the above, as it's a different location.
    when 2
      # The cursor position is in the upper left.
      $game_player.reserve_transfer(map_id, x, y, face)
      # Same as above.
    when 3
      # Cursor position is in second row from the top, first column on the left.
      $game_player.reserve_transfer(map_id, x, y, face)
    when 4
      # Second row from the top, second row on the left.
      $game_player.reserve_transfer(map_id, x, y, face)
    when 5
      # Second row from the top, third row on the left.
      $game_player.reserve_transfer(map_id, x, y, face)
      # And so on.
    end
      $game_player.perform_transfer
      sfx = RPG::SE.new("Up1", 80)
      sfx.play
      return_scene
    end
  end
end


...this. Or something like this. Note that this isn't taking into consideration locations that are locked at the offset of the game, and are unlocked later. That code would, by necessity, be more complex.
What I have so far is

# Scène de jeu principal
#[url]http://www.biloucorp.com/creation-dun-shifumi-avec-le-rgss3-16[/url]
class Scene_Fastravel < Scene_Base
  # Lancement de la scène
  def start
    super
    create_title
    create_commands
    #generate_choice
    #create_window_message
  end
  
  # Création de la fenêtre de titre
  def create_title
    @title = Window_Help.new(1)
    @title.set_text("Choisis ta destination")
  end
  
  # Création de la fenêtre de sélection
  def create_commands
    @window_selection = Window_Fastravel.new(0, 48)
    @window_selection.set_handler(:feu1, method(:feu1))
    @window_selection.set_handler(:feu2, method(:feu2))
    @window_selection.set_handler(:feu3, method(:feu3))
    @window_selection.set_handler(:exit, method(:exit))

  end
  
  # Cas de sélection de feu1
  def feu1
    p "Vous avez choisi feu1"
    $game_variables[2] = 1
    $game_temp.reserve_common_event(1)
    SceneManager.call(Scene_Map)
  end
  # Cas de sélection de feu2
  def feu2
    $game_variables[2] = 2
    p "Vous avez choisi feu2"
    $game_temp.reserve_common_event(1)
    SceneManager.call(Scene_Map)
  end
  # Cas de sélection de feu3
  def feu3
    p "Vous avez choisi feu3"
    $game_variables[2] = 3
    $game_temp.reserve_common_event(1)
    SceneManager.call(Scene_Map)
  end
  # Cas de sélection de feu3
  def exit
    p "Vous avez choisi Exit"
    SceneManager.call(Scene_Map)
  end
end


  # Fenêtre de sélection de la destination
  class Window_Fastravel < Window_Command
  # Création de la liste de selection
  def make_command_list
    
    add_command("feu  1", :feu1)
    add_command("feu 2", :feu2) if $game_variables[22]>0
    add_command("feu 3", :feu3) if $game_variables[23]>0
    add_command("Sortie", :exit)
    
        
  end
end

I'll try to fit yours somewhere :)
It almost worked :P if I'm not wrong, it display everything one after another.
meaning that if I have only 2 points on 2nd row in my game, i'll stil have 3 in the menu.

Can you explain how you get the "location locked!" ?

+ def make_item_list : it's creating lines, not rows.
Do you know how to create rows ?
Marrend
Guardian of the Description Thread
21781
Let me tackle these questions one at a time.

If I'm not wrong, it displays everything one after another. Meaning that if I have only 2 points on 2nd row in my game, I'll still have 3 in the menu.

So, let's roll back to...



...this screenshot for a bit. The "empty nodes" here were filled with something akin to...

add_command("", :locale, false)

...this code. This code not only displays no text in the cell, but, causes the cell to be unable to be selected as an option.

Can you explain how you get the "location locked!" ?

The short-and-sweet explanation is that it's the text that is displayed when a location is locked.

The long explanation is that the text that is displayed for a given location is based on a global variable that is a member of a "Locales" class. The variable is an array of "Locale" objects, which keeps track of location data.

It might be a little difficult to understand without seeing it, so, code-tag time!

class Locale
  # This class will keep track of whatever variables we need to teleport.
  attr_accessor :map_id   # Map ID
  attr_accessor :x        # X coordinate
  attr_accessor :y        # Y coordinate
  attr_accessor :lock     # Location locked/unlocked attribute.
  attr_accessor :face     # Character facing after teleport.
  attr_accessor :name     # Location display name.
  
  def initialize
    # Initializes variables.
    @map_id = 0
    @x = 0
    @y = 0
    @lock = true
    @face = 2
    @name = "Undefined"
  end
  
  def set_map_id(index)
    # Sets the Map ID.
    @map_id = index
  end
  
  def set_x(pos)
    # Sets the X coordinate.
    @x = pos
  end
  
  def set_y(pos)
    # Sets the Y coordinate.
    @y = pos
  end
      
  def set_lock(lock)
    # Sets whether or not the location is available
    # or not. Default value is true.
    @lock = lock
  end
  
  def set_face(angle)
    # Sets the facing of the character after teleport.
    # With this function, the possible values are the same as the ones
    # resulting from Set Varibles -> Character facing.
    # So 2 is down, 4 is left, 6 is right and 8 is up.
    # Default value is down (2)
    @face = angle
  end
  
  def get_name
    # Gets the display name for a location.
    if @map_id != 0
      if @lock == true
        map = load_data(sprintf("Data/Map%03d.rvdata2", @map_id))
        @name = map.display_name
        # Note that name stays "Undefined" when map_id is 0. This is mostly
        # to emulate Lloyd's Beacon-like effects, should one choose to go
        # that route.
      else
        @name = "Location locked!"
      end
    end
  end
  
  def add(index, pos_x, pos_y, lock = true, face = 2)
    # A quicker method to add locales than going function-by-function.
    set_map_id(index)
    set_x(pos_x)
    set_y(pos_y)
    set_lock(lock)
    set_face(face)
    get_name
  end
    
  def teleport
    # Performs the teleport operation. Not EXACTLY the self-same that the
    # Transfer Player event command uses, but for our purposes, close enough.
    $game_player.reserve_transfer(@map_id, @x, @y, @face)
    $game_player.perform_transfer
  end
end

class Locales
  attr_reader :data # Location array.
  
  def initialize
    @data = []
    set_array
  end
  
  def add_locale(id, x, y, lock = true, face = 2)
    # Adds a locale to the locals array.
    index = @data.size
    @data[index] = Locale.new
    @data[index].add(id, x, y, lock, face)
  end

  def set_array
    # ID = 10 [Staerdale Palace]; Place = (17, 13); not availabe; default (down)
    add_locale(10, 17, 13, false)
    
    # ID = 15 [Glikx Heights]; Place = (9, 9); not availabe; default (down)
    add_locale(15, 9, 9, false)
    
    # ID = 19 [Sraphyhl Peak]; Place = (9, 9); not available; default (down)
    add_locale(19, 9, 9, false)
    
    # ID = 25 [Blils Wood]; Place = (12, 14); not available; default (down)
    add_locale(25, 12, 14, false)
    
    # ID = 28 [Windwhisper Outpost]; Place = (12, 11); not available; default (down)
    add_locale(28, 12, 11, false)
    
    # ID = 31 [Clafton Keep]; Place = (13, 17); not available; default (down)
    add_locale(31, 13, 17, false)
    
    # ID = 37 [Monastery]; Place = (33, 16); not available; default (down)
    add_locale(37, 33, 16, false)
    
    # ID = 40 [Klird Timberwood]; Place = (9, 10); not available; default (down)
    add_locale(40, 9, 10, false)
    
    # ID = 43 [Southsong Manor]; Place = (7, 10); not available; default (down)
    add_locale(43, 7, 10, false)
    
    # ID = 46 [Parltron Citadel]; Place = (8, 17); not available; default (down)
    add_locale(46, 8, 17, false)
    
    # ID = 49 [Trygh Forest]; Place = (14, 14); not available; default(down)
    add_locale(49, 14, 14, false)
    
    # ID = 53 [Lost Village]; Place = (15, 12); not available; default (down)
    add_locale(53, 15, 12, false)
    
    # Example
    # ID = map_id; Place = (x, y); locked; default (down)
    # add_locale(map_id, x, y, false)
  end

  def set(index, id, x, y, lock = true, face = 2)
    # Replaces one location data for another. Mostly for Llody's Beacon-like
    # effects.
    @data[index].add(id, x, y, lock, face)
  end
  
  def set_lock(index, lock)
    # Locks, or unlocks, a location.
    @data[index].set_lock(lock)
    @data[index].get_name
  end
end

When displaying names in the context of the window-display, it looks like...

def make_item_list
  i = 0
  while i < $locales.data.size
    add_command($locales.data[i].name, :locale, $locales.data[i].lock)
    i += 1
  end
end

...this. Though, that loop worked better in the context of a list format for how the "Locales" data was set up. Displaying in a column format was a bit awkward, but...

def make_item_list
  # First row
  add_command($locales.data[0].name, :locale, $locales.data[0].lock)
  add_command($locales.data[5].name, :locale, $locales.data[5].lock)
  add_command($locales.data[9].name, :locale, $locales.data[9].lock)

  # Second row
  add_command($locales.data[1].name, :locale, $locales.data[1].lock)
  add_command($locales.data[6].name, :locale, $locales.data[6].lock)
  add_command($locales.data[10].name, :locale, $locales.data[10].lock)
    
  # Thrid row
  add_command($locales.data[2].name, :locale, $locales.data[2].lock)
  add_command($locales.data[7].name, :locale, $locales.data[7].lock)
  add_command($locales.data[11].name, :locale, $locales.data[11].lock)
    
  # Fourth row
  add_command($locales.data[3].name, :locale, $locales.data[3].lock)
  add_command($locales.data[8].name, :locale, $locales.data[8].lock)
  add_command("", :locale, false)
    
  # Fifth row
  add_command($locales.data[4].name, :locale, $locales.data[3].lock)
  add_command("", :locale, false)
  add_command("", :locale, false)
end

...still doable.

+ def make_item_list : it's creating lines, not rows.
Do you know how to create rows ?

If you look under my class definition for Window_Locale, above, you might notice...

def col_max
  return 3
end

...this little ditty. That's what creating the columns!



*considers more*
Really cool ! thanks !!

I understood the empty nodes and the "location locked!"

For the row thing, it's my bad english the culprit. I don't know why, i was sure that row = column.

Right now, the empty nodes can be selectionnable (even if they cannot be confirmed). Do you see a way to make them unselectionnable ( like it was really empty) ?
Marrend
Guardian of the Description Thread
21781
With the last row, you can just use as many "add_command" lines as there are options for that row. In the screenshot above, there would only be one command, and the other cells in that row couldn't be selected at all. Other than that, I can't think of anything off-hand. At least, not if you use one window for all locations.

If there is a window for each "column", you could make a method to cycle between windows with left/right buttons. So, the function to cycle through these windows might look something like...

def arrow_trigger
  if Input.trigger?(:RIGHT)
    # Right arrow was pressed.
    if @win_col1.active
      @win_col2.activate
      @win_col2.select(0)
    if @win_col2.active
      @win_col3.activate
      @win_col3.select(0)
    if @win_col3.active
      @win_col1.activate
      @win_col1.select(0)
    end
  end

  if Input.trigger?(:LEFT)
    # Left arrow was pressed.
    if @win_col1.active
      @win_col3.activate
      @win_col3.select(0)
    if @win_col2.active
      @win_col1.activate
      @win_col1.select(0)
    if @win_col3.active
      @win_col2.activate
      @win_col2.select(0)
    end
  end
end


...that, probably to be placed in the update method for Scene_Teleport...

class Scene_Teleport < Scene_MenuBase
  # Omitting other functions for now.
  def update
    super
    arrow_trigger
  end
end


...like so? I haven't tested this, but, it's the idea running through my head.
Pages: 1