Hello there.
I recently had an issue in creating a script due to my lack of general knowledge on RGSS. I have read several articles, tutorials, guides, and topics for learning RGSS, however, I find I learn much faster if I learn in an engaged way. Merely reading an article on a function or topic does not leave the same impression a lesson or conversation would, for example. To this end, I'd like to request some help with understanding attr_writer/reader/accessor.
I recently created a script for creating custom stats which I required help with. KK20 jumped in and provided the solution:
Quote from: KK20
It's exactly what the message window says: You don't have a 'set' method for your variables. Easy way to do that would be to make your new stats be attr_writer
I noticed you defined your 'get' methods, so I that's why I didn't suggest attr_accessor.
Once I set the attr_writer for all of the new variables I was using, everything worked. If I held a better understanding of these functions, I feel I wouldn't have had this issue. So here I am.
I believe attr_writer/reader provide the writing/reading function to a value, respectively. However, I have little to no understanding of attr_accessor, except that perhaps it provides both of these functions. Beyond those basic statements, I haven't the foggiest impression of their function and how to effectively utilize them.
Bottom Line-
For attr_reader/writer/accessor, would someone mind going in-depth in explaining these for me?
For attr_accessor, how would this differ from using attr_reader/writer and definitions? Is it more effective?
Thank you in advance if you decide to indulge my curiosity.