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.

[Resolved] Menu option only avaliable if switch is on

Status
Not open for further replies.
How would I go about doing this. I tried doing this -

Code:
      when 1  # skill
        if $game_system.switches[1] = false
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0

and

Code:
     if $game_system.switches[1] = false
      # Disable skill
      @command_window.disable_item(1)
    end

But, it doesn't work. I think one reason might be is because I'm not supposed to say '$game_system.switches'
 

Anonymous

Guest

if !$game_switches[1]

First, = is the assignment operator. == is comparison. Using = in an if statement is usually a logic error.

Second, switches are already either true or false, so there's no need for if $game_switches[1] == false, you can just say if !$game_switches[1] (if not switch 1).

Third, the global variable is $game_switches.
 
Thank you, that works, but when I turn the switch on, the menu option still doesn't become usable

Code:
      when 1  # skill
        if !$game_switches[1] = false
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
 

Mac

Member

Its cause you call upon the same conditions, as they both are set for false, so one would need to be true , try changing that:-

Code:
if $game_system.switches[1] = false
      # Disable skill
      @command_window.disable_item(1)
    end

To this:-
Code:
if $game_system.switches[1] = true
      # Disable skill
      @command_window.disable_item(1)
    end
 
Okay, I got it working with this

Code:
      when 1  # skill
        if !$game_switches[1]
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0

Thank you, I'm still a noob at scripting
 
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