How can I run a script instead of/before/after the menu comes up?
From OHRRPGCE-Wiki
Contents |
[edit] New Way
Starting with the voxhumana release, the OHRRPGCE supports user defined menus which include script triggers.
needs example
[edit] Old Way
Running a script before the menu comes up is easy enough. All you need is an on-key-press script that checks for the escape or alt keys. The other two are minor variations.
[edit] Script Before Menu
Use an on-key-press script (set in general map data) that checks for the Esc or alt keys being pressed:
include, scancode.hsi
plotscript, my key handler, begin
if (key is pressed (key: esc), or, key is pressed (key: alt)) then (
#script gos here...
)
end
You can't use wait commands in such a script (see below for reason). If you need to use wait commands, you need to disable the menu altogether.
[edit] Script After Menu
To make a script run after the menu closes, you need to add a single wait command to the front of the script code. When a menu key is pressed, the script interpreter runs your script and runs into the wait command. At this, it will stop interpreting, and GAME.EXE will get on with other things. Finding that esc was pressed, it will bring up the menu and concentrate on that until the player closes the menu. To the plotscript, only one tick has passed in all this time because GAME.EXE moved into a different state while displaying the menu.
include, scancode.hsi
plotscript, my key handler, begin
if (key is pressed (key: esc), or, key is pressed (key: alt)) then (
wait (1)
#script gos here...
)
end
[edit] Script Instead Of Menu
In order to prevent the menu from coming up at all, so that you can replace it with your own custom menu, the player must be suspended at the instant the game checks whether it should pull up the menu, and there are two ways to implement this. The first is to suspend player for the entire game, or map, or scene as the case may be. This isn't an easy solution, because you will have to write scripts to handle all of the things you have disabled, like moving the hero when the player pushes an arrow key.
The simpler solution is to suspend the player for one tick when esc or alt is pressed, and then resume it again after GAME.EXE has been fooled into not calling the menu.
include, scancode.hsi
plotscript, my key handler, begin
if (key is pressed (key: esc), or, key is pressed (key: alt)) then (
suspend player
wait (1)
resume player
#script gos here...
)
end
