Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Where is the F12 command script?

I need to replace the scene: game over - return to title screen command with the F12 command, this is to refresh the game entirely so I don't get that big ass death error in Battle World, but where abouts is the F12 command script?
Someone please tell me or post it here, thanks.
 
The [F12] button has been a royal pain to scripters and script-users alike for some time. The built-in [F12] system has either had problems reloading scripts or hadn't reloaded 'configured' values. Stack errors have also occurred with this system by 'Not' unloading scripts that need reloading every New game.

I wouldn't recommend replacing the 'Return to Title' option with [F12], regardless of your problem. It would probably just compound the issue.
 
Well, I don't get stack errors or time out errors, I need to replace the return to title part of scene_gameover or what ever it's called with the F12 command because it's the only way to remove a certain glitch I'm getting.
 
Really? I never knew the F12 key was doing that to the scripts in the game. I've always been using F12 in all RPG Maker games as a quick way to return to the title screen.

Does Enterbrain know about this yet?


EDIT: Does it also happen if you went back to the title screen with the "Quit Game" option, or is it only the F12 key causing the problems?
 
Enterbrain may know about it by now. It's been known for some time as Seph and Trickster have been working on the F12 fix for the SDK system for some time and Zeriab made a non-SDK fix about a month ago... shuts your RMXP game down and loads a new RMXP game.

Typically, the stack error and configuration load problems don't occur if you go to the title screen but through the F12 button. It seems that not everything gets unloaded nor reloaded. Seems like there's more of a tendency for it to keep the current 'values' yet tries to reload aliased scripts... and the reloading of some of these 'aliased' scripts causes the stack error.
 
Well, is there a way to call the F12 command through scripts? All I want to know is if there is a way to call F12 instead of returning to title screen after a game over, and if there is, what is it?
 

Zeriab

Sponsor

Yes, you can simulate F12 being pressed.
Here's the snippet for simulating a F1 press, it will
Code:
$win32_keydb_event = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
$win32_keydb_event.call(0x70,0,0,0)   # F1 down
$win32_keydb_event.call(0x70,0,2,0)   # F1 up

The code the F12 button is 0x7B.
However since this is the F12 button it naturally would be so simple.
You must press F12 down for some time and this is where it becomes fun.
If you just press F12 down like this:
Code:
$win32_keydb_event = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
$win32_keydb_event.call(0x70,0,0,0)   # F12 down
You'll keep restarting. Ever tried holding F12 down? There you have it.

Now... How will you call the F12 up function if the game keeps restarting?
One way is this:
Code:
Thread.new {
  $win32_keydb_event = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
  $win32_keydb_event.call(0x7B,0,0,0)   # F12 down
  sleep(0.1)
  $win32_keydb_event.call(0x7B,0,2,0)   # F12 up
}
I press the F12, let the thread sleep in 0.1 seconds and release F12.
In practice it takes much longer. Certainly something to do with it restarting.
You can decrease the sleep, but if it is too little nothing will happen. (F12 being pressed down and released too quickly issue)
Naturally this being a Thread how long a sleep is required varies from run to run.

You can try to increase the thread's priority like this:
Code:
aThread = Thread.new {
  $win32_keydb_event = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
  $win32_keydb_event.call(0x7B,0,0,0)   # F12 down
  sleep(0.1)
  $win32_keydb_event.call(0x7B,0,2,0)   # F12 up
}
aThread.priority = 1

I don't know if it has any effect at all and it might effect other programs you have running.
 
I should be able to edit this
$win32_keydb_event = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
$win32_keydb_event.call(0x70,0,0,0) # F12 down
Into the game over scene, I'm not at an RMXP computer until sunday, so I'll tell if it works or not then.
Thanks Zeriab.
 
This works! The one in my quote there has 0x70, it needs to be 0x7B, I replaced the return to title screen scene with this
Code:
aThread = Thread.new {
  $win32_keydb_event = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
  $win32_keydb_event.call(0x7B,0,0,0)   # F12 down
  sleep(0.1)
  $win32_keydb_event.call(0x7B,0,2,0)   # F12 up
}
aThread.priority = 1
I bumped it so if anyone else wants to know this then here it is, it works and all is fine with the battle world error! you saved it's progress!
Any mods can now put that [RESOLVED] thingy in the title.
Thanks again!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top