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.

Disable a script with switches?

I was wondering how I could disable a whole script until I turned on a switch so it will run.

For instance, I have a platformer script that I only want activated when the player is transfered to a certain area. ;D Thanks anyone who can help...I am having trouble trying to do it with $game_switches[#] = false...etc.
 

Star

Sponsor

Hmm..

I'm thinking maybe you could turn it off and on by saying under each class

class Blah blah blah
if $game_switches[xx] == true


end # end of "if branch"
end # end of "class"

Have you tried doing this for each class under the script?

Edit: Oh wait this is game maker.. Shit I goofed
 

Zeriab

Sponsor

I am afraid that turning a script on and off at runtime is impossible in the general case. (I.e. it's impossible to make a script which can do that for any arbitrary script)

Luckily you just have to get it working for your specific case.
How to do it depends on the script, so I highly suggest you post the platform script (or a link to it) and tell us which other scripts you use.

The best case would be if you would post a demo with all the scripts present. (I understand if you don't want to do that)

*hugs*
 
Scripts do not work like "parallel process". All they make have a logical sequence.

What I mean by this is that, if there is a system you want not to work in a certain instant, you must restrain it by its "starting point".


See an example:
You paste in your script editor one that makes the button A call an special menu.
To make A call this menu the script certainly "aliased"(that would mean like "added functions") to the update method of the Scene_Map script.

So, if you want this menu to be called only if a certain switch is triggered on, you should search this alias update on the place the script you pasted edited the Scene_Map. There, you should make your editions:
if $game_switches 
 

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