VXAce NoMethodError for method that definitelly exists

I created a acessor property for one of my variables but when i try to assign it i receive a "NoMethodError" despite the method existing there.(I solved it using the attr_acessor notation) but i would like to see if someone have an insight in this for the future because i think this might be a bug in the RPG Maker itself.

The attribute:
1751239304234.png


The set Method:
1751239377424.png


Where i'm calling the set method:
1751239421766.png



The error:
1751239640517.png
you misread the error message.
it doesn't say that the method itself does not exist, it says that the method does not exist for said game actor placeholder.

and that usually means that the game actor itself does not exist, that the method was called for a nonexistant actor.
you misread the error message.
it doesn't say that the method itself does not exist, it says that the method does not exist for said game actor placeholder.

and that usually means that the game actor itself does not exist, that the method was called for a nonexistant actor.
Thanks for your reply, but i dont think this can be the case because of some reasons:

1. The $game_party.menu_actor actor is always set in the scene that calls the add method

2. if it were the case of the actor not existing it would return a nil value and as long as its recognized as an instance of the Game_Actor class it should have the defined method

3. i fixed the issue by writing the acessor with the "attr_acessor" notation, further confirming that the actor does in fact exist and the problem was in the method itself.

And in the middle of writing this i think i might have discovered the possible problem. Maybe in Ruby you have to define a get method too for the foo=(value) method notation.
Yes, i was right, aparently in Ruby when you create a set method with the property=(value) notation you have to create a get method too. I'm new to Ruby programming lol.
Yes, i was right, aparently in Ruby when you create a set method with the property=(value) notation you have to create a get method too. I'm new to Ruby programming lol.
Not in all cases, but in this case specifically,
actor.hero_sword_bonus += 15
is a syntactical abbreviation for essentially
actor.hero_sword_bonus = actor.hero_sword_bonus + 15
which does include calling a getter method.

If you had just written
$game_party.menu_actor.hero_sword_bonus = 115
then a setter method would have been sufficient.

attr_accessor creates both a getter and setter method for your specified variables. If you only need one or want to define the other yourself, you can use attr_reader or attr_writer respectively.
Not in all cases, but in this case specifically,
actor.hero_sword_bonus += 15
is a syntactical abbreviation for essentially
actor.hero_sword_bonus = actor.hero_sword_bonus + 15
which does include calling a getter method.

If you had just written
$game_party.menu_actor.hero_sword_bonus = 115
then a setter method would have been sufficient.

attr_accessor creates both a getter and setter method for your specified variables. If you only need one or want to define the other yourself, you can use attr_reader or attr_writer respectively.
I see. Thanks for the insight.

Original thread: https://forums.rpgmakerweb.com/threads/nomethoderror-for-method-that-definitelly-exists.178628/