Ruby/RGSSx questions that don't deserve their own thread

I haven't really looked why it won't work on battle start. But here are your common mistakes.
But it gives me an error - that actor cannot be used as an integer.
Of course, it demands integer value. $game_actors[1].index. What are you implying by using "actor"? maybe you should use @actor_id instead.
Putting in if $game_party.members.index(actor) = 0, will bring an error about an "unexpected = sign".
The correct syntax is to use == instead of =

Also, if your screen_x, screen_y, and screen_z values are not going to change, why not just write it like this?
Code:
def screen_x
  return 10 + 100 * index
end

def screen_y
  return 325
end

def screen_z
  return 100
end
Turning screen_x into a method seems to have done the trick! I would never have thought about turning screen_x into a method like that.

I am kind of curious why "index" works in there, instead of being used in another method - but maybe it has something to do with the "initialization"?
Like maybe that runs before the party is set up in the index?
Because screen_x would be called in Sprite_Battler. If they're called, it's true that they're already in party member array thus it won't return nil.

You may want a different implementation though if you want to make your battle move here and there like many popular sideview battle. So keep working on your previous idea could be good too.
I was wondering, a lot of the times when I edit classes - with really big methods, I copy/paste the entire method, just so I can change usually one line of code to call a method added to the class - is there way to insert a method into a classes method without overwriting the entire thing?

Or is it just better practice just to take everything not nailed to the floor - and just edit the few lines?
You either alias that method or, in some rare cases, call super on them (if the method is from a superclass but isn't explicitly defined in the class itself).
But there are some cases where alias/super won't work due to how the method you want to change is written, in which case you have no choice but to overwrite it.

When you use an alias, it will save the original method and will store it with a new method name you specify. You can than redefine the method you want by using that alias method and add in the new stuffs you want before or after the alias method call.

Example:
Spoiler
Code:
class SomeClass

  alias old_some_method7725 some_method
  def some_method(*args)
    # Add stuffs before if needed
    old_some_method7725(*args) # <-- This is the original method process
    # Add stuff after if needed
  end

end
The old_some_method7725 will be the name of the saved method and can be called anytime by using any valid method calls (which means not only in the originally aliased method, you can also call it from other methods if needed).
You can name these aliased methods however you want, but you must pass the same amount of arguments as the original methods have when you call them.

The format of the alias line is:
Code:
  alias aliased_method_name original_method_name
  def original_method_name(*args)
    # Code here
  end

You can do the same by calling super, if the class you work in inherited the method from a superclass, but that will not save the original method, it will simply call it in that specified method only.
Ok - I think I got a hang on it, I managed to get it going for a turn_end call, which is good, since I imagine a lot of scripts like to overwrite that.
Hopefully I'll be able to get it working though the item_use scripts and etc. Since those are the really long boys.

Thanks so much Sixth!

edit:
I meant, the sprite_effect scripts - which it worked like a charm, so now all the custom sprite effects / update effects - live in their own little pocket, so thanks again! It's so much easier to swim through now.
Is there a way to change z of either animations or battle status window so that animations would be above actor faces?
(Using Yanfly Battle Engine)
Is there a way to change z of either animations or battle status window so that animations would be above actor faces?
(Using Yanfly Battle Engine)
For the z value of animations, this might help. https://www.rpgmakercentral.com/topic/27765-show-animation-over-pictures/
Is there any way to execute a specific command in the command list (that you don't hover over) that you can immediently activate by pressing a button (through conditional branch means) in a script call?
By that I mean, it's your characters turn and then by pressing the A button on your keyboard, you activate Guard.
It's for a more reflex based ATB system and I don't want the player to go two selections down to activate the guard command, because convenience.
Using VX (Looking it up on Ace also doesn't hurt, as I can just translate that easily onto VXs side of things, if there is means of doing so)
@ShinNessTen In VX, you can do this:
Code:
class Scene_Battle < Scene_Base
 
  alias battlehotkeys_scenebattle_updateactorcomsel update_actor_command_selection
  def update_actor_command_selection
    if Input.trigger?(Input::A)
      @actor_command_window.index = 0     # Attack
      Sound.play_decision
      @active_battler.action.set_attack
      start_target_enemy_selection
    elsif Input.trigger?(Input::X)
      @actor_command_window.index = 1     # Skill
      Sound.play_decision
      start_skill_selection
    elsif Input.trigger?(Input::Y)
      @actor_command_window.index = 2     # Guard
      Sound.play_decision
      @active_battler.action.set_guard
      next_actor
    elsif Input.trigger?(Input::Z)
      @actor_command_window.index = 3     # Item
      Sound.play_decision
      start_item_selection
    else
      battlehotkeys_scenebattle_updateactorcomsel
    end
  end
 
end
Replace Input::A, etc., with the buttons you want to use. Bear in mind that keys Input::C and Input::B are already in use. If you go into the help file and search Input, you can find more info on the buttons there. Also, not sure if this will work with custom battle systems.
@ShinNessTen In VX, you can do this:
Code:
class Scene_Battle < Scene_Base
 
  alias battlehotkeys_scenebattle_updateactorcomsel update_actor_command_selection
  def update_actor_command_selection
    if Input.trigger?(Input::A)
      @actor_command_window.index = 0     # Attack
      Sound.play_decision
      @active_battler.action.set_attack
      start_target_enemy_selection
    elsif Input.trigger?(Input::X)
      @actor_command_window.index = 1     # Skill
      Sound.play_decision
      start_skill_selection
    elsif Input.trigger?(Input::Y)
      @actor_command_window.index = 2     # Guard
      Sound.play_decision
      @active_battler.action.set_guard
      next_actor
    elsif Input.trigger?(Input::Z)
      @actor_command_window.index = 3     # Item
      Sound.play_decision
      start_item_selection
    else
      battlehotkeys_scenebattle_updateactorcomsel
    end
  end
 
end
Replace Input::A, etc., with the buttons you want to use. Bear in mind that keys Input::C and Input::B are already in use. If you go into the help file and search Input, you can find more info on the buttons there. Also, not sure if this will work with custom battle systems.

It does indeed work on a normal new project, but not with my battlesystem. I did some digging with my battlesystem script, and this part of the code is for when you are currently selecting a command:
ZDqHz2e.png

The input::RIGHT and LEFT are for when another party member has a full gauge and you can swap between them with left and right.
Not sure if you would be able to put the input button command actions in there. I tried to make it work, but I can only go so far with making it compatible with the little script knowledge that I have 🙁

Edit: forgot to put that on a code
Code:
  #--------------------------------------------------------------------------
  # ● コマンド更新  ※再定義
  #--------------------------------------------------------------------------
  def update_actor_command_selection
    # コマンド入力できる状態でなくなればキャンセル
    return reset_command unless commanding?
    if Input.trigger?(Input::B)
      Input.update
      Sound.play_decision
      start_party_command
    elsif Input.trigger?(Input::C)
      Input.update
      case @actor_command_window.index
      when 0  # 攻撃
        Sound.play_decision
        @commander.action.set_attack
        start_target_enemy_selection
      when 1  # スキル
        Sound.play_decision
        $in_select = true
        start_skill_selection
      when 2  # 防御
        Sound.play_decision
        @commander.action.set_guard
        end_command
      when 3  # アイテム
        Sound.play_decision
        $in_select = true
        start_item_selection
      end
    # →キーでコマンドキャラ送り
    elsif Input.trigger?(Input::RIGHT)
      next_commander
    # ←キーでコマンドキャラ戻し
    elsif Input.trigger?(Input::LEFT)
      back_commander
    end
  end
@ShinNessTen Does it work when you do this?:
Code:
alias battlehotkeys_scenebattle_updateactorcomsel update_actor_command_selection
  def update_actor_command_selection
    return reset_command unless commanding?
    if Input.trigger?(Input::A)
      @actor_command_window.index = 0
      Sound.play_decision
      @commander.action.set_attack
      start_target_enemy_selection
    elsif Input.trigger?(Input::X)
      @actor_command_window.index = 1
      Sound.play_decision
      $in_select = true
      start_skill_selection
    elsif Input.trigger?(Input::Y)
      @actor_command_window.index = 2
      Sound.play_decision
      @commander.action.set_guard
      end_command
    elsif Input.trigger?(Input::Z)
      @actor_command_window.index = 3
      Sound.play_decision
      $in_select = true
      start_item_selection
    else
      battlehotkeys_scenebattle_updateactorcomsel
    end
  end

Otherwise, I think you could do this:
Code:
def update_actor_command_selection
    # コマンド入力できる状態でなくなればキャンセル
    return reset_command unless commanding?
    if Input.trigger?(Input::B)
      Input.update
      Sound.play_decision
      start_party_command
    elsif Input.trigger?(Input::C)
      Input.update
      case @actor_command_window.index
      when 0  # 攻撃
        Sound.play_decision
        @commander.action.set_attack
        start_target_enemy_selection
      when 1  # スキル
        Sound.play_decision
        $in_select = true
        start_skill_selection
      when 2  # 防御
        Sound.play_decision
        @commander.action.set_guard
        end_command
      when 3  # アイテム
        Sound.play_decision
        $in_select = true
        start_item_selection
      end
    # →キーでコマンドキャラ送り
    elsif Input.trigger?(Input::RIGHT)
      next_commander
    # ←キーでコマンドキャラ戻し
    elsif Input.trigger?(Input::LEFT)
      back_commander
    elsif Input.trigger?(Input::A)
      @actor_command_window.index = 0
      Sound.play_decision
      @commander.action.set_attack
      start_target_enemy_selection
    elsif Input.trigger?(Input::X)
      @actor_command_window.index = 1
      Sound.play_decision
      $in_select = true
      start_skill_selection
    elsif Input.trigger?(Input::Y)
      @actor_command_window.index = 2
      Sound.play_decision
      @commander.action.set_guard
      end_command
    elsif Input.trigger?(Input::Z)
      @actor_command_window.index = 3
      Sound.play_decision
      $in_select = true
      start_item_selection
    end
  end
@ShinNessTen Does it work when you do this?:
Code:
alias battlehotkeys_scenebattle_updateactorcomsel update_actor_command_selection
  def update_actor_command_selection
    return reset_command unless commanding?
    if Input.trigger?(Input::A)
      @actor_command_window.index = 0
      Sound.play_decision
      @commander.action.set_attack
      start_target_enemy_selection
    elsif Input.trigger?(Input::X)
      @actor_command_window.index = 1
      Sound.play_decision
      $in_select = true
      start_skill_selection
    elsif Input.trigger?(Input::Y)
      @actor_command_window.index = 2
      Sound.play_decision
      @commander.action.set_guard
      end_command
    elsif Input.trigger?(Input::Z)
      @actor_command_window.index = 3
      Sound.play_decision
      $in_select = true
      start_item_selection
    else
      battlehotkeys_scenebattle_updateactorcomsel
    end
  end

Otherwise, I think you could do this:
Code:
def update_actor_command_selection
    # コマンド入力できる状態でなくなればキャンセル
    return reset_command unless commanding?
    if Input.trigger?(Input::B)
      Input.update
      Sound.play_decision
      start_party_command
    elsif Input.trigger?(Input::C)
      Input.update
      case @actor_command_window.index
      when 0  # 攻撃
        Sound.play_decision
        @commander.action.set_attack
        start_target_enemy_selection
      when 1  # スキル
        Sound.play_decision
        $in_select = true
        start_skill_selection
      when 2  # 防御
        Sound.play_decision
        @commander.action.set_guard
        end_command
      when 3  # アイテム
        Sound.play_decision
        $in_select = true
        start_item_selection
      end
    # →キーでコマンドキャラ送り
    elsif Input.trigger?(Input::RIGHT)
      next_commander
    # ←キーでコマンドキャラ戻し
    elsif Input.trigger?(Input::LEFT)
      back_commander
    elsif Input.trigger?(Input::A)
      @actor_command_window.index = 0
      Sound.play_decision
      @commander.action.set_attack
      start_target_enemy_selection
    elsif Input.trigger?(Input::X)
      @actor_command_window.index = 1
      Sound.play_decision
      $in_select = true
      start_skill_selection
    elsif Input.trigger?(Input::Y)
      @actor_command_window.index = 2
      Sound.play_decision
      @commander.action.set_guard
      end_command
    elsif Input.trigger?(Input::Z)
      @actor_command_window.index = 3
      Sound.play_decision
      $in_select = true
      start_item_selection
    end
  end
The second one worked like a charm! Oh man, I'm so happy now! Thank you very much, you made my game now look even more kind of professional, haha! 😀

I'll make sure to give you big credits! Thanks a ton!
@ShinNessTen No worries!
Not really a "please help" per say - but just kind of curious about something I've noticed.

When I use "(.*)" in Regex, why does it create a ">" at the end - even when the beginning doesn't have it?
I honestly would prefer if I didn't need the <> at the end since I feel the note box looks cleaner without them, but I'm ok with needing to use them.

Also I've noticed that in a lot of scripts - they use a more complicated regex, when this seems to work super easily. So I'm not sure if there's a downside to using "(.*)" other than it kind of looking like a butthole?
It's about how you structured / stylized the notetag. It's not mandatory. You can even use something like this and it works.
Screenshot_324.png


Having the regex written like this
Screenshot_325.png

Means you (or your script user) need to write it exactly like that or the script won't recognize.
This, I believe the idea is to make it easier to recognize which is tag for config, and text for actual note for your game. You don't want to mix both.
That makes sense.

Would anyone know if it's possible to get an actor or battlers note-tag from the battler class?

I'm trying to do a few things, involving note reading - and I pretty much just copy/paste them between the actor and enemy classes, because their the same really. I feel it'd just be easier to manage if I could just put it in the battler class itself, but it doesn't seem to know what "note" is.
Iirc, accessing Actor's class note is as easy as using $game_actors[id].class.note.
Enemy doesn't have class by default, so you figure that out.
I think, he meant class as Ruby class (Game_Actor/Game_Enemy/Game_Battler/etc), not the class from database.

For some weird reason, the default code uses a different method name to get the database information for the actor and enemy classes.
This means that you are better off doing them separately, otherwise you would need to have another check to see if it's an actor or an enemy and read the note-tag accordingly.

The method for getting the database information for actors is called actor inside the Game_Actor class.
The method for getting the database information for enemies is called enemy inside the Game_Enemy class.

So, to get their note-tag data, you can do actor.note in Game_Actor or enemy.note in Game_Enemy.
Yeah, it was for the Script Classes, I'm tweaking a "battler sprite change" script and I thought it'd be easier to manage just from Game_Battler. But Yeah, I'm gonna go with just keeping them separate for now - I want to keep it simple. So it's probably better to do that.

Original thread: https://forums.rpgmakerweb.com/threads/ruby-rgssx-questions-that-dont-deserve-their-own-thread.150/