Hi - I'm doing some tests, at trying to use Scene_Base to have it's own "event" when a game starts, I'm doing that using an aliased update method. But the results seem to loop constantly.
I think I understand why - it's because the @@doOnce is constantly being set to 0 - so it's stuck in a loop of going to 0, then setting itself to 1 and playing the text. But I'm unsure how else I'd set it to a number - just once.
(I'm sure I'll get advice to do an easier method, using events, etc. but I am trying to understand the code better - so I'd still like to understand what to do in a situation where it had to be done this way.)
Code:
class Scene_Base
attr_accessor :doOncetest
@@doOncetest = 0
alias do_Once_alias update
def update
do_Once_alias
if @@doOncetest == 0
@@doOncetest == 1
$game_message.add("*It's looping forever!! Panic!!*")
end
end
end
I think I understand why - it's because the @@doOnce is constantly being set to 0 - so it's stuck in a loop of going to 0, then setting itself to 1 and playing the text. But I'm unsure how else I'd set it to a number - just once.
(I'm sure I'll get advice to do an easier method, using events, etc. but I am trying to understand the code better - so I'd still like to understand what to do in a situation where it had to be done this way.)