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.

Two simple scripts

I was wondering if someone could help me or make the following scripts:

One, a script that changes a given game switch on or off, based on the state it is already in. So, it would turn it on if it was off. The switch number is pulled from a game variable.

Two, a script that can change game variables. It could change a variable that is referenced by another variable. It could also change the value of a variable by a variable referenced by another variable.

For those of you who have used 2003, it just adds the versatility of that system to VX.

Thank you ahead of time.
 
You can do the first simply via events. Use a Conditional Branch and check if a switch is off; if so, turn it on, else, turn it off.

For the second, do you mean setting a variable to another variable's value? In the "Control Variables" command, there are many options you can use to do this.
 
On the first one, yes i can, but that gets very annoying to actually code that for every switch i need it for.

Two, I mean setting a variable to another variable's value, but the variable it sets it to is chosen by a third variable, instead of just choosing it in the editor. So:
v2 is set to 5, v1 then sets itself to v5's value.
Also, the variable being changed could be chosen by a second variable.
 
@Necro: Actually, the part I'm asking for was taken out of XP and VX. You can't do it like 2003.

@Pattousai: That does smooth things somewhat, but I still have to go through and make one for every switch.
 
I can help you with the first one, but I'll have to think on the actual concept of the second one before I can do something with that
Code:
def switch_switch(var)
   unless $game_variables[var] == nil
      if !$game_switches[$game_variables[var]]
         $game_switches[$game_variables[var]] = true
         return
      else
         $game_switches[$game_variables[var]] = false
         return
      end
   end
end
That should work, though I haven't tested it. Paste that anywhere above main and below everywhere else.
If you now want to turn a switch on/off based on a variable and state of the switch, just use the call script command and write "switch_switch(variable you want to use)" without the quotes. That should do the job. If it doesn't, let me know. (I used the weird name because I'm not sure whether the "switch" method already exists :P better not risk it XD)

EDIT: OOPS!, if you already used it, repaste the script in now, I had to make a small edit.
EDIT2: just for your convenience, I've added a clause so that the script now does nothing in case your chosen variable hasn't been set.
 

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