*mobile mode typing
well this maybe a silly question, but how can we define a different ok handler at different command? for example at title screen, when we press ok at new game, the default ok handler method that's called is different than when we press ok at continue and when we press ok at shudown command. because i see, everytime the command is being pressed by ok button, the default process ok at window selectable is being run
When you press OK it runs the command handler for the specific command that is currently selected... the handlers are set at the Scene classes, take a look at those
example: for the title scene, this is where the command handlers for the commands are defined:
def create_command_window
@command_window = Window_TitleCommand.new
@command_window.set_handler🙂new_game, method🙂command_new_game))
@command_window.set_handler🙂continue, method🙂command_continue))
@command_window.set_handler🙂shutdown, method🙂command_shutdown))
end
:new_game is the symbol used to identify the command, while :command_new_game is the OK handler for that command
commands are added via the Windows btw...
*mobile mode typing
oh god i forgot to tell you, that's not what i meant actually. what i mean is, every time we press ok at command, the default process_ok at window_selectable is being processed first before the real handler at its own window is being processed. and what i really ask is, can we assign a different process_ok at different handler at other windows?
What difference would that make from just editing the handler of each command itself (aside from a few less codes to run)?
but to answer your question, you can change it per window class (Like Window_CommandTitle will have it's own ok handler ) via overriding process_ok (make a new process_ok method on that class), but I don't think you can per command in a single window class
sample:
class Window_TitleCommand
def process_ok
end
end
this will make it such that nothing happens if you press OK in any command included in title commands I think
*mobile mode typing
oh i see, so we redefine the default process_ok at window_selectable into it's child class, right? but still, the process_ok is too generally for every command at that window. if it's possible to assign each different process_ok at different command, it'll be more useful. but if not, then i just use the overwriting method of process_ok. how is it adiktuzmiko? can we do different process_ok at different command? (can't tested anything, still mobile mode)
*mobile mode typing
nah you read my mind exactly. 😀 i tried to edit the default process_ok because i wanted the structure to work with my scripts (like having different sound played when clicked ok). i think i just redefine the process_ok at window_titlecommand and then erase the play sound so at different handler of title command i'll set the different played sound
thanks for helping adiktuzmiko, now i got it. this can be closed.
BTW, I edited my post... realized that you can call the ok handler directly instead of process_ok...
though for different sounds, I suggest just removing the sound line from the process_ok (since the other parts of process_ok are still important) then just play sound using the handler
NOTE: the other parts of the process_ok are important and will probably need to stay for all commands so I suggest just editing it and remove what you don't need instead of removing the whole process_ok via the script that I posted above
BTW, you can also utilize the :ext parameter for commands to save things like filename of the sound, then load it on the process_ok
Strictly speaking, process_ok shouldn't even be playing any sounds. I consider it to be poor design.
*mobile mode typing
then what method that when we press the ok button at command, the ok handler is being processed together with sound.play_ok? (i think it was process_ok, can't remember much because i'm not in front of the computer right now, still mobile mode hehehe 😀 )
EDIT :
nah forget it, i'm sure it was process_ok 😀 😀
anyway just close this thread. already been solved
It was process_ok and Tsukihime was pointing out that it's really not a good design idea... IMO, I agree with that... I personally commented out that sound part in some projects because I don't really want sounds on each commands
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
Next time, please report the thread to have it closed, rather than relying on a mod to see one line in one post in the whole thread.