This is a common misconception between scripters. I had the same issue as you when I started scripting and the solution is not that simple. While in events you can easily call the wait command without stopping all the processing, scripts behave in a different way.
You can do something like that:
class Scene_Base alias milena_update update alias milena_terminate terminate def update milena_update update_momotaros if @character_motion != nil end def terminate if @character_motion != nil @character_motion.dispose @character_motion = nil end milena_terminate end def create_momotaros(momo) momo_x = get_motion(0) @character_motion = NPC_TkboxWindow.new(momo_x, momo) @character_motion.visible = true @character_motion.update_pos(momo_x) @wait_milena = 5 end def update_momotaros if @wait_milena > 0 @wait_milena -= 1 else @character_motion.dispose @character_motion = nil end endendSo, you call SceneManager.scene.create_momotaros(momo) to call your method
When 5 frames pass, the window will be automatically disposed.
Also, if the scene you are currently in terminates, the window will also be disposed (you can't have windows, sprites and bitmaps messing around - you need to dispose them when they finish their job).
Please note that this isn't the best solution - but it works, and should encourage you to find better ones.
You can do something like that:
class Scene_Base alias milena_update update alias milena_terminate terminate def update milena_update update_momotaros if @character_motion != nil end def terminate if @character_motion != nil @character_motion.dispose @character_motion = nil end milena_terminate end def create_momotaros(momo) momo_x = get_motion(0) @character_motion = NPC_TkboxWindow.new(momo_x, momo) @character_motion.visible = true @character_motion.update_pos(momo_x) @wait_milena = 5 end def update_momotaros if @wait_milena > 0 @wait_milena -= 1 else @character_motion.dispose @character_motion = nil end endendSo, you call SceneManager.scene.create_momotaros(momo) to call your method
When 5 frames pass, the window will be automatically disposed.
Also, if the scene you are currently in terminates, the window will also be disposed (you can't have windows, sprites and bitmaps messing around - you need to dispose them when they finish their job).
Please note that this isn't the best solution - but it works, and should encourage you to find better ones.