In-Game Script Disabler

Blackyu

Professional Procrastinator
Veteran
Joined
Jul 10, 2016
Messages
110
Reaction score
335
First Language
French
Primarily Uses
RMVXA
I've been making a game for 11 months now, and I've decided to add a script called Khas Awesome Light Effects for the last parts of the game.


The problem is, this script  "searches surfaces on the map, in order to cut the light pictures. In a huge map, the number of surfaces may increase a lot."


In the parts of the game where I don't need the script, there are massive maps (roughly 100x200).


Thing is, with this script on, it takes around 10-15 minutes for the script to load every tile as "Non-Light Object".


I've already seen Script Disablers on the forums (TDS's one for example), but those are only for debug purposes, and the game needs to be restarted in order to reenable a script again.


I'm looking for a way to disable scripts while In-Game until a certain condition is met, allowing early large maps to be loaded quickly. Or maybe a piece of code that could prevent the script from working until a switch is activated.


I would mostly ask this as a script, since it could be useful to anyone that uses a lot of heavy scripts, but any way possible is fine.


Of course, I can wait a long time for the script, as the game is still in development (meaning I can use Editor-linked Script Disablers at the moment, but I won't be able to use them when the game will enter its final development phase).


I'm sorry if my English isn't perfect or if my way of writing seems confused (and confusing), it might be the language barrier... ^^'
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,434
Reaction score
7,713
First Language
German
Primarily Uses
RMMV
What you ask for is simply impossible - it can be compared to asking "can I change my car's front tire while driving 50 mph on the highway?"


If the game runs, scripts can't be disabled/enabled - that is why all ways to disable scripts only work on the debug level with access to the script editor.


The only thing that can be done is to impletent a switch into a specific function of a specific script to disable that specific function dynamically.


That is possible, but requires a partial rewrite of the script and cannot be done externally.


So if you really need to disable Khas' script during the game, then you need to request a specific modification to Khas' script, and that modification will not be able to switch off any other script. And because that is a rewrite of a very complex script, there are only very few scripters here that can modify that script.
 
Last edited by a moderator:

Blackyu

Professional Procrastinator
Veteran
Joined
Jul 10, 2016
Messages
110
Reaction score
335
First Language
French
Primarily Uses
RMVXA
So if you really need to disable Khas' script during the game, then you need to request a specific modification to Khas' script, and that modification will not be able to switch off any other script.
In order to request a modification of this script, do I have to post in this kind of subforum or should I rather ask on the script page ?
 

Galactic_Edge

Villager
Member
Joined
Jul 16, 2013
Messages
23
Reaction score
2
First Language
English
Primarily Uses
I banged on it a little and got it loading 500x500 maps in a few seconds. But i can't promise it'll be stable, or won't break other stuff. I only tested it in very basic conditions. It's a hackjob, but it might work. Just paste this over the original. If you get some crashes I'll need you to give me the conditions required to reproduce the crash, and I can't promise I can fix the problems.


I just went by the map's area. At the moment it activates if the total surface is greater than 9999, so a 100x100 map would be exactly big enough to have lighting turned off. To modify that, ctrl-f for this line and use the value:


@lighting_off = $game_map.width * $game_map.height > 9999 ? true : false #added


(Everything I added has #added after it.)


Edit: I'll post a patch soon
 
Last edited by a moderator:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
I understand that you want to help but:

# 4. All Khas scripts are for personal use, you can use or edit for your own
# project, but you are not allowed to post any modified version;
Which means, well, what it is written.


However, you can do patches or addons for the script, and what you edited in it can be easily extracted into a patch/addon.


If you need help with that, I can make it for you. If you know how to do it, remove the edited script and post your patch/addon instead.
 
Last edited by a moderator:

Galactic_Edge

Villager
Member
Joined
Jul 16, 2013
Messages
23
Reaction score
2
First Language
English
Primarily Uses
I understand that you want to help but:


Which means, well, what it is written.


However, you can do patches or addons for the script, and what you edited in it can be easily extracted into a patch/addon.


If you need help with that, I can make it for you. If you know how to do it, remove the edited script and post your patch/addon instead.


Alright thx. I guess a patch is just aliases and overwrites?
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
Yes, that is basically a patch.


It includes the methods changed/overwritten only, and nothing else.


And the patch must always be below the original script.
 

Blackyu

Professional Procrastinator
Veteran
Joined
Jul 10, 2016
Messages
110
Reaction score
335
First Language
French
Primarily Uses
RMVXA
Oh, so the use of an add-on could work ? Nice !


Thanks a lot for helping me ! I'm sorry if I seem to not answer frequently, I really have not much to say, so I'm just silently following the thread.
 

Galactic_Edge

Villager
Member
Joined
Jul 16, 2013
Messages
23
Reaction score
2
First Language
English
Primarily Uses
Hey, I'm not sure if this going to solve your problem or not, since I was unable to create a situation where a map took 10 or 15 minutes to load. I'm not sure what is causing that. This disables lighting about as early as possible. Let me know if it helps. If it doesn't, try to explain how i can recreate a working example of the problem, preferably using the default game that comes with Khaz's lastest download for the most recent version.
 
Last edited by a moderator:

Blackyu

Professional Procrastinator
Veteran
Joined
Jul 10, 2016
Messages
110
Reaction score
335
First Language
French
Primarily Uses
RMVXA
Do I need to restart the game for the patch to work on the original script ?


I've tried loading the closest save and it still took around 7 and a half minutes to load the map.


Actually, the map has >200 Events and rather heavy Parallel Processes, but it only took around 10 seconds to load before installing the script.


Maybe it's because of my computer (I mean, it's quite an exploit to keep a Hewlett-Packard Portable PC alive for 8 years, but the processor is getting worn out.), but it could still play the map in question, so either it could be a problem with another script (which I highly doubt) or I'm just doing something wrong.


EDIT : Do I need to make another section in Material Scripts or do I simply have to paste the patch right underneath the last line of Khas's script ?
 
Last edited by a moderator:

Galactic_Edge

Villager
Member
Joined
Jul 16, 2013
Messages
23
Reaction score
2
First Language
English
Primarily Uses
Ok, I messed around for awhile and was able to recreate the problem. I got a 5 minute map load down to 10 seconds. Give this a try:

#This is a patch for Khaz's Awesome Light Effects to turn off lighting for large maps.
#It must be pasted below Khaz's script.

#To use, find the line "@lighting_off = $game_map.width * $game_map.height > 9999 ? true : false"
#and set a total surface area where the '9999' is. At a value of 9999, a 100x100 map would be exactly big enough
#to have its lightning turned off (allowing it to load faster). Anything smaller will behave normally.

class Game_Player
def perform_transfer #overwrite
if transfer?
set_direction(@new_direction)
if @new_map_id != $game_map.map_id
$game_map.setup(@new_map_id)
if $game_map.lighting_off
$game_map.effect_surface.reset
$game_map.effect_surface.refresh_skip_check
end
$game_map.autoplay
end
moveto(@new_x, @new_y)
clear_transfer_info
end
end
end

class Spriteset_Map
def update #overwrite
kbl_update
update_lights unless $game_map.lighting_off
end
end

class Game_Map
alias off_switch_setup setup
alias lights_out_merge_surfaces merge_surfaces
attr_accessor :lighting_off

def setup(map_id) #alias
map_data = load_data(sprintf("Data/Map%03d.rvdata2", map_id))
@lighting_off = map_data.width * map_data.height > 9999 ? true : false
off_switch_setup(map_id)
end

def update(arg) #overwrite
if @lighting_off
kbl_update(arg)
else
@effect_surface.refresh if arg
kbl_update(arg)
end
end

def merge_surfaces
return if $game_map.lighting_off
lights_out_merge_surfaces
end
end

class Light_Surface

def reset #added
@ta = @a = 0
@tr = @r = 255
@tg = @g = 255
@tb = @b = 255
@va = @vr = @vg = @vb = 0.0
end

def refresh_skip_check #added
@a += @va
@r += @vr
@g += @vg
@b += @vb
$game_map.light_surface.opacity = @a
@timer -= 1
end
end



To answer your question, you should probably put this in a patches section at bottom. In a perfect world you could just paste it directly below khaz's script on the same page, but you might be using other scripts that overwrite my overwrite methods (they're labelled as overwrites). Anyway, give this one a shot. Make sure the map is at least 100x100, or adjust the minimum threshhold.
 
Last edited by a moderator:

Blackyu

Professional Procrastinator
Veteran
Joined
Jul 10, 2016
Messages
110
Reaction score
335
First Language
French
Primarily Uses
RMVXA
I tried using the patch by just using another section right below the Khas script, I tried the map, and it works perfectly !


You have saved my game from eternally charging maps ! I'd like to say something other than "Thank You", but I don't know a lot of ways to express gratitude !


This patch has definitely made my day ! (Or my night, it's past 2 AM in France.)


Anyway, the thread can be closed now. Again, thanks for helping me out, it's really nice !
 

Galactic_Edge

Villager
Member
Joined
Jul 16, 2013
Messages
23
Reaction score
2
First Language
English
Primarily Uses
Let me know if you have any crashes or lighting bugs
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,047
Messages
1,018,540
Members
137,834
Latest member
EverNoir
Top