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.

controlling switches by scripts

McP

Member

Hello!
I use Aleworks Options Menu since yesterday and set up my own option.
Basically, i set up an option in the "graphics tab", that should turn on or off some eye candy in my game.
I want the script to set a switch to true when the option is activated.
The party of the script that can do this is this i think:
Code:
    when 17 # My option
    return nil if type != 0
    if @bloom_effekt == true
      @bloom_effekt = false
    else
      @bloom_effekt = true
    end
i tried to add lines to set game_switches[200] = true (or false)
but that gives me a nil error.

I also thoungt about adding some lines to an update class since the game has to know about the changes in the option menu i did it like this:
Code:
def update
if @bloom_effekt == true
$game_switches[200] = true
else $game_switches[200] = false
end

but thats not workin either.
Then i tried it with a simple conditional branch checkin for
Code:
if bloom_effekt
but that simply does nothin..even with an else branch..

Can somebody help me, or explain what i am doing wrong?
I have absolutely no knowledge of ruby and maybe i am getting some points wrong about how ruby works.
I just try around using ruby hoping i'll get no errors an this usually works^^
so please, give me some hints!
 
If you are just wanting to toggle a variable, you can use this:

Code:
your_variable = !your_variable

So if you are just toggling a game switch, you can use
Code:
$game_switches[switch_id] = !$game_switches[switch_id]

Thats it.
 

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