Save-Point
Prevent Deactivation - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+--- Thread: Prevent Deactivation (/thread-7444.html)



Prevent Deactivation - DerVVulfman - 03-24-2019

Prevent Deactivation
by KK20
Version: 1.1
* and Minor F12 fix added by DerVVulfman



Introduction
When the game window is no longer the active window, it normally freezes the game from updating. This script will allow games to still run in the background.

This feature makes it so your game stays active and continues to run, even if you bring up another window or program.



Features
  • Keeps the game running, even if you're running another program
  • Has options to turn on/off the prevention feature
  • Versions for Ruby 1.8 and newer Ruby 2.0+



Script
The version for Ruby 1.8+
--or--
The version for Ruby 1.9.2+
--or--
The version for RPGMaker VXAce


Required Attachment

.zip   MessageIntercept.zip (Size: 27.17 KB / Downloads: 25)



Instructions
Mainly, place the .DLL attached in your project's root directory and paste the script just above main after all other custom scripts.  Other instructions are in the script.



FAQ
This was searched for by DerVVulfman, the request at RPGMakerWeb.Com posted and found right (>HERE<)



Compatibility
Designed for the RPGMaker engines, with two versions based on which version of Ruby/RGSS your engine is using.



Credits and Thanks
This script was designed by KK20, and with thanks to Jaiden for the toggle on/off feature request.


Terms and Conditions
Due credit for both KK20 and Jaiden is required.  Free for use in commercial projects.


RE: Prevent Deactivation - kyonides - 03-24-2019

It's weird to find no reason to double post the code here. Didn't you make any mistake, wulfo? O_o? Or has the original scripter lied to people hoping nobody would notice it?


RE: Prevent Deactivation - DerVVulfman - 03-24-2019

I have done searches within the forum for key words of "KK20", "MessageIntercept", and "Deactivation". At no point do we have any thread or post that comes up. And as towards a search for the keyword of "Jaiden" who supplied a suggestion AND whom I've known for ten years since the old RMXP.Org days, no script posts were provided.

I have also performed a google searches for "MessageIntercept RPG" and "Deactivation RPG", so the returned list of viable links would only involve within RPGMaker forums for either the name 'Deactivation' or the MessageIntercept DLL file. No results were found.

If you are stating that this script already exists within this forum, please provide the link.


RE: Prevent Deactivation - DerVVulfman - 03-24-2019

*ACK! I keep forgetting you go by that name in here!!!

And nope, that is not a double-post. There is a subtle difference between the two. Ruby 1.8 does not include the getbyte statement for the String class, so the 1.8 version contains the line:
Code:
update_if_game_in_focus if MessageIntercept::Flag_Deactivate[0] == 1
However, since the later versions of Ruby does have the getbyte statement, the newer version of the script instead contains the line:
Code:
update_if_game_in_focus if MessageIntercept::Flag_Deactivate.getbyte(0) == 1

This minor change was pointed out by KK20 as below:
KK20 at RPGMakerWeb Wrote:Oh right, forgot about that. You just use String#[] to get the byte. So it should be
Code:
update_if_game_in_focus if MessageIntercept::Flag_Deactivate[0] == 1



RE: Prevent Deactivation - kyonides - 03-25-2019

The question would be if there's an actual need for two versions of the same script. I mean, isn't it enough to use either #[] or get_byte in both versions of Ruby. Who can confirm it? O_O


RE: Prevent Deactivation - DerVVulfman - 03-25-2019

In regards of the two straight ruby versions, the second one utilizes a more current standard, the 'getbyte' function not previously available until Ruby 1.9.2. It is called keeping up with standards and practices, lest you would not be constantly upgrading HiddenChest with the latest version of Ruby. And who knows when a calling method becomes depreciated. You should appreciate that. Have you not found some RPGMaker XP scripts that worked with RPGMaker XP but not iwth your own HiddenChest? So in the spirit of keeping current, there are the two versions depending upon which version of Ruby is used.

Meanwhile, an "F12 Anti-Stack" fix was just added to the three scripts.


RE: Prevent Deactivation - Rangnarok - 12-25-2020

(03-25-2019, 07:26 PM)Thank you for this Wrote: Thanks for this script. I am noob to RPG Maker, let alone Ruby. But this script is exactly what I needed.

I had to change a bit so the game still accepts input while the window is inactive. Luckily, the instructions in the file was clear enough for me to understand and commented that part out.

I tried with SpecialK to do what I need, but it didn't hook at all. Thank you again for this.

EDIT 2: It works :) I had to start a new game. I guess the old save file still uses the old script system somehow.


For those who is curious, I edited this part out so the game would still accept player input while the window is inactive (for controller)


Code:
 # Only accept player input if the game window is in focus
 #  def self.update
 #  update_if_game_in_focus if MessageIntercept::Flag_Deactivate.getbyte(0) == 1
 # end