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

@Kes Alright, sorry for the misplaced question. Thanks for the directions! haha
Is there anyway to check note tags from states an attack has on using the built in scripts?
I don't need regex or anything. note.include on its own is fine.
But stuff like a.state.note.include? doesn't work at all.

I have seen state.note.include? show up in a few scripts, so I don't know if that's the proper way of referencing an actors state.
@AquaDog
Where do you want to check that? In which class(es) and in which method(s)?
state.note.include?("string") should work, as long as the state variable is a valid RPG::State object.
I want to check it from a method - run by an attack formula. So I can use a "bonus multiplier" method to check for states/variables to boost damage or negate it.

Attack box:
attack(a,b,v)*bitebonus(a,b);

Code:
def bitebonus(a,b)
bonus = 1;
if a.note.include?("biter"); bonus += 1; end
bonus;
end

So the way it runs is if the user has "biter" in it's tag, the damage calc. by attack(a,b,v) is upped 100%.
As it is right now, by checking the actor itself, it works.

So what I'm hoping for is to get something equivalent to "a.state.note.include?(biter)".
I just noticed that you wrote this:
Is there anyway to check note tags from states an attack has on using the built in scripts?
Attacks don't have states. I assume you want to check the actor's active states, right?
You can do that with this:
Code:
a.states.any? {|state| state.note.include?("string") }

Or you can check the note-tags from all feature objects an actor has at once with this:
Code:
a.feature_objects.any? {|obj| obj.note.include?("string") }
This will check the notebox from all active feature objects including actors, classes, equipment and states if variable a is an actor.
If variable a is an enemy, it will check the notebox from the enemy itself and from it's active states.

Btw, that snippet you posted... Why the semi-colons? It's not JS, you can leave those out.
Code:
def bitebonus(a,b)
  bonus = 1
  bonus += 1 if a.note.include?("biter")
  return bonus
end
Or make it even shorter:
Code:
def bitebonus(a,b)
  return a.note.include?("biter") ? 2 : 1
end
Sorry, I just feel itchy when I see needlessly lengthy code lines/methods. 😛
Thanks! That worked perfectly! And thanks for the clean up advice - though I'm sure if that made you itchy, some of the code I have in would give you a heart attack.
I'm using
Code:
$game_player.move_speed = x
to set a non-integer movement speed for the player. 4 is too slow, and 5 is too fast. After walking for a while, seemingly at random, player's sprite starts jiggling back and forth as he moves. Everything is perfectly fine once I switch back to integer speed. Is there a way to fix this or am I doomed to be stuck at miserable 4 speed?
I've been doing a few edits to the base scripts, and its getting hard to keep track of them all - I was wondering if there's any way to edit things from using scripts in the Materials sections?
I've been doing a few edits to the base scripts, and its getting hard to keep track of them all - I was wondering if there's any way to edit things from using scripts in the Materials sections?
That is EXACTLY how you do it. Basically base script should NEVER changed. All changes need to put in Material section for easier tracking. For example, put this in Material section.
Code:
module Vocab
  ShopBuy = "Buuuuy"
end
It will overwrite vocab module.
That is EXACTLY how you do it. Basically base script should NEVER changed. All changes need to put in Material section for easier tracking. For example, put this in Material section.
Code:
module Vocab
  ShopBuy = "Buuuuy"
end
It will overwrite vocab module.

Okay, that's great! Though I guess to be safe - I should probably go back to all the scripts I did edit (I marked them with an "@" because its easy to see during a scroll) and see if I can them back and just move the edit material in its own script.

I wasn't expecting it though, to be that simple - do the base scripts not have a load order or anything?
All scripts are loaded in the order you place them in the script editor, from top to bottom, including the default scripts.

A method can only be defined once. If you define it in different scripts, it will get overwritten, the effective method will be from the script closest to the bottom, all previous method definitions are lost. That is why we call this as "overwrite".
This same principle is true for module constants as well.

But if you plan for compatibility with other scripts, you will need to alias some methods instead of directly overwriting them. Doing this will let you preserve the old method and redefine it later with the possibility of loading the preserved parts of the method if needed.

Like Theo wrote, you should never edit the default scripts if you plan to keep those edits for good, just make your addons/changes in new script slots.
I've been trying to get an actor's party position though it's Game_Actor class, so I can use it for this Sprite Battler script.
I just haven't been able to get it to work, the error messages have ranged from Nil can't be coerced into a fix num, to stack overflows errors.

I'm not really sure why it's not working - since there seems to be an "index" method in Game_Actor, that looks like it does get its own party position - but it acts like it's NIL when referenced, so I'm kind of at a loss of what to do.

What I'm hoping to do is get an integer of the actor's party index - and use it for this bit of code here:
@screen_x = 10+ (100 * index)

Something else I've tried was this:
Code:
 @screen_x = 10+ (100 * battleindex)

  #Get index
  def battleindex
    ref_actor = $game_actors[self]
    position = $game_party.members.index(ref_actor)
    position
  end
But it gives me an error that Actor cannot be used as an integer.
Maybe this will tell you something
3b1a63f33899cdc7d09bce2a88850fb9.png
I had tried that before, and it just gives:
9RHCHNq.png

But I don't really understand why it's not working out - it's the same class, so I felt that it would know what calling "index" is - and even just making a new method, or plugging $game_party.members.index will give an error too.
Maybe post an entire script could help. I see no reason why it went nil unless you do it in really unusual way.
The usage is something like
Code:
i = $game_actors[1].index
or simply write "index" if you use it within Game_Actor.

The var "i" can be ranged around 0 to whatever max index is. It might went nil IF the said actor is not in party. The method "members" is depend on where you call it. It's "all_members" if outside battle, and "battle_members" during battle.
This is the main code - there's some "note.include" at the end until I understand regex better. I feel like I'd get slapped for that part so I'll hold on to it.

Code:
class Game_Actor < Game_Battler
 
  attr_accessor :screen_x
  attr_accessor :screen_y
  attr_accessor :screen_z

  def initialize(actor_id)
    super()
    setup(actor_id)
    @last_skill = Game_BaseItem.new
    @battler_name = aquadogtest
    @letter = ""
    @plural = false
    @screen_x = 10 + (100 * battleindex)
    @screen_y = 325
    @screen_z = 100
  end
 
  #Get index
 def battleindex
  $game_party.members.index(self)
  end
 
  #Use Sprites
  def use_sprite?
    return true
  end

end

I pretty much just took things from the enemy battler's - and set the actor's use sprites to on.
And then it just runs some note checks to get the file name. So There's nothing really crazy going on - just trying to set up something like XP's battles without any huge modules or anything.
Oh I see the problem now. This one....
Code:
@screen_x = 10 + (100 * battleindex)
You're initializing @screen_x variable by deciding the value from the start using actor index. While the said actor is not a part of party member when they're created. So the engine doesn't know which index they're in. I'd say it's a bad practice.
index(val)
Returns the position of the first element equal to val (using ==). If no such element is found, returns nil.
Your final formula will always be @screen_x = 10 + (100 * nil)

Are you trying to create custom battle system?
In a way - I guess so? Though I'm mostly just trying to get the player to show sprites like the enemies. In the simplest way possible.
Though that's going to be a problem if the index isn't going to be to pick up characters before it gets to screen_x.

Thought that maybe putting the id check in initialize might do something, but it leads to the same error.
My tip is if you want to do it that way. Put those in a new method
Code:
def init_position
   @screen_x = 10 + (100 * battleindex)
   @screen_y = 325
   @screen_z = 100
end
Call it whenever the battle starts
It doesn't seem to work, I tried having the method called in by on_battle_start, to get the same error.
So something I've been trying is to instead plug the index into an equation, that I do something like:
Code:
partypos = 50 if $game_actors[actor].index = 0
But it gives me an error - that actor cannot be used as an integer.
Putting in if $game_party.members.index(actor) = 0, will bring an error about an "unexpected = sign".
I think to understand this better, I need to see where the base scripts actually calls the index - then maybe I can get a better understanding of how it works, and how it likes to be called.

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