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.

Activating a Switch With Script

I am just wondering because I need this I am making some buttons with Cybersam's Keyboard Input Module, I need to know how to activate a switch through a script. This would be very helpful, thanks (I am a scripting newbie).
 
How about we teach you to fish....??

Here's a nifty little trick I use all the time.

You know that there is an event command to set a switch, right?
All of the event commands are handled in the interpreter.
Let's take a look at Interpreter 2, and search for "switch"
On line 60, it says "when 121  #control switches"  so let's look for 'command_121
Found it!  right at the top of interpreter 4
The line that sets the switch:
  $game_switches[n] = (@parameters[2] == 0)

(@parameters[2] == 0) is a 'logical' statement that returns either 'true' or 'false'

So, $game_switches[n] = true  turns it ON
and $game_switches[n] = false  turns it OFF

Be Well
 
Thank you, and actually I didn't know about switch being an interpereter. I haven't even used RMXP for a year, so I don't know that much about scripting, but I am learning :smile:.
 

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