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

Status
Not open for further replies.

McP

Member

Hi, I am using Aleworks Options Menu v2 .5 and i want this script to control a switch when turning an option on or off in the option menu.
So I set up the script properly to display my new option( I think) but that doesn't affect the game yet.
Heres the part of the script thats important I think:
Code:
 when 17 # HDR
    return nil if type != 0
    if @HDR_Effekt == true
      @HDR_Effekt = false
    else
      @HDR_Effekt = true
    end
    end

i tried to do it like this:
Code:
when 17 # HDR
    return nil if type != 0
    if @HDR_Effekt == true
      @HDR_Effekt = false
        def []=(switch_id, value)
      @game_switches[200] == false
      end
    else
      @HDR_Effekt = true
        def []=(switch_id, value)
            @game_switches[200] == true
            end
    end
    end

but thats also doing nothing.. so what am I doing wrong?
I think i might need to do something with updating but i don't know how..
so help plz
 

McP

Member

that still doesn't make the options menu change the variable...
it looks like this now
Code:
when 17 # HDR
    return nil if type != 0
    if @HDR_Effekt == true
      @HDR_Effekt = false
        def []=(switch_id, value)
      $game_switches[200] = false
      end
    else
      @HDR_Effekt = true
        def []=(switch_id, value)
            $game_switches[200] = true
            end
 
Whoa maybe I should look next time, hehe. Anyways

def []=(switch_id, value) has to go, along with the end that goes along with it. You cannot have a definition inside another definition. return nil if type != 0 is also not needed, and you forgot to close off your IF statements with end. So:
Code:
when 17 # HDR
    return nil if type != 0
    if @HDR_Effekt == true
      @HDR_Effekt = false
        def []=(switch_id, value)
      $game_switches[200] = false
      end
    else
      @HDR_Effekt = true
        def []=(switch_id, value)
            $game_switches[200] = true
            end
becomes


Code:
when 17 # HDR
    if @HDR_Effekt == true
      @HDR_Effekt = false
      $game_switches[200] = false
    else
      @HDR_Effekt = true
       $game_switches[200] = true
    end
 
Status
Not open for further replies.

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