Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Character Order

It's very simple. I would like to change the position of characters in the hero group. Ex: Hero 1 pass to position of Hero 3 and hero 3 go to position of hero 1. To simplify, it's not necessary a new CMS or a new window in menu, just a button to change the order would be perfect. If someone could do this or tell how i make it, i would be very glad. Thanks.
 
Code:
class Game_Party
  def switch_members(position_a, position_b)
    return if @actors[position_a].nil? || @actors[position_b].nil?
    @actors[position_a], @actors[position_b] = @actors[position_b], @actors[position_a]
    $game_player.refresh
  end
end

I wrote that real quick, so if it doesn't work, let me know.

To use:
Code:
Call Script: $game_party.switch_members(position_a, position_b)

Replace position_a with a number that the position of the actors is in. Same goes for postion b.

For example, switching the 2nd and 4th, you would use:
Code:
Call Script: $game_party.switch_members(1, 3)

1st and 4th
Code:
Call Script: $game_party.switch_members(0, 3)

Note that the postion in the party is always subtracted by 1.
First = 0, Second = 1, Third = 2, Fourth = 3

Let me know if it doesn't work or you don't understand. I imagine you can just use a event with the Key Press Command (or whatever it is called. I don't use events. :P)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top