[ACE] comprehension question: calling methods always requires a new object?

Hi,

I am starting to lern ruby at the moment. Let's say I would like to display a BattleLog message when a custom event of mine managed to... 'steal' a potion from the target.

BattleLog = Window_BattleLog.newBattleLog.add_text("Theft successful: Potion was stolen!")kind of works, but do I really need the new BattleLog object? Is there no way of calling a method just in one line of code and without adding in a new object (Windows_BattleLog.add_text("DoesNotWork?"))?

I believe there has to be an option since the 'Conditional Branch\Script' has just one line to call a method for true or false.

(Also the sample above does indeed add the text to the log but it never fanishes or gets replaced by new text from the vanilla Windows_BattleLog. Shouldn't 'Windows_BattleLog' handle the clearing of its messages? Any Ideas?)
I would check out Scene_Battle and see how the battlelog is handled there.  The log window in battle is created in the method create_log_window with @log_window = Window_BattleLog.new, and is later accessed via that same instance variable throughout.  You would use this instance variable to add new messages, and let the rest of Scene_Battle do the updating/disappearing/etc...

It's similar to other things as well, you just need to learn how the normal system handles things it gets easier.
The thing is that those methods are instance methods... so you need first an instance of the object before you can use them...


Just imagine this: How would you add a text to a Battle Log if the Battle Log doesn't exist on the first place?


if you don't want instances, you would probably want to use Modules rather than Classes...

Original thread: https://forums.rpgmakerweb.com/threads/ace-comprehension-question-calling-methods-always-requires-a-new-object.22233/