How do I implement pause outside battles/ in my battle system?
From OHRRPGCE-Wiki
If you are interested in implementing a pause system outside battle, well it's perfectly possible to do so.
Here we go. The first thing to do is to edit your hss file and copy and paste the following code and adapt it to your hss file. You can choose for example Global variable (22, minute) instead of 12 like in the example above. The only ones you cannot change are the "read general" ones.
define script (45, my keyispressed script, none) #--------------------------------------------------------------------------- Global variable (10, day) Global variable (11, hour) Global variable (12, minute) Global variable (13, savetime) Global variable (13, pauseisactive) #--------------------------------------------------------------------------- define script (autonumber,my keyboard pause,none) define script (autonumber,my keyboard unpaused,none) #--------------------------------------------------------------------------- script, my keyispressed script, begin if (key is pressed(key: numlock)) then, begin if (pauseisactive==false) then, begin my keyboard pause end, else, begin #thus, pauseisactive must be true my keyboard unpaused end #end of the first if end #numlock is pressed for pause #--------------------------------------------------------------------------- script,my keyboard pause, begin set on keypress script (92) suspend player suspend npcs show text box (334) #pause suspend box advance day:= days of play hour:= hours of play minute:= minutes of play savetime:= read general (54) #ToDo: make an official seconds of play command pauseisactive:=true wait(1) end #end of the plotscript #--------------------------------------------------------------------------- script, mykeyboard unpaused, begin while (pauseisactive) do, begin wait (1) advance text box write general(51, day) #ToDo: Make official set days of play, etc. commands write general(52, hour) write general(53, minute) write general(54, savetime) resume box advance resume player resume npcs pauseisactive:=false wait(1) end #end of the while pause is active set on keypress script (48) end #end of plotscript #---------------------------------------------------------------------------
Save your hss file but don't compile it. Now go under custom.exe and pick up a free text box. Write pause in it. Press the windows key on the keyboard and check that the number of the text boxes correspond to the one you have in the script (show text box (the txt boxe you've just pick). Save the changes under custom but don't leave the game. Now you can compile your game. Feel free to test it! Even if you don't press num lock for several you'll see that no time has pass (when you save your game.)
[edit] Conclusion:
Note only will this system be useful outside battles but it may be useful to include this code in your own battle system's code! Note that you can also use this system to reset time. but you'll have to write
#reset time write general(51,0) # days write general(52,0) # hours write general(53,0) # minutes write general(54,0) # seconds
