Mastermind Script Edit

Hi, folks. Found a Mastermind Script for VXA up here. I need to have some changes on the script which I'm not able to do on my own. It's mainly to make configuration easier. Let's start off:

- No choices for "play normal game" and "play hard game". The game should start right away and I want to use a switch to define if it's a normal or hard game.
- Difficulty progression with Variable: (Variable set to 1 means one color is used for the code, Variable set to 2 means two colors are used for the code... and so on)
- Scene should end immediately if the player beats the code. There should be a "congratulations, you did it!" or something like that right after so the player knows he won.
- 3 lifes: If the player can't manage to crack the code after 3 tries, he will be Game Over. (life should be a variable as well)

Anyone able to help?

Spoiler: Mastermind Ace
Code:
#==============================================================================
#  Mastermind (VX)
#  Version: 1.0
#  Author: Zylos (rmrk.net)
#  Date: March 21, 2011
#------------------------------------------------------------------------------
#  Description:
#
#   This script sets up a classic Mastermind minigame, in which the player must
#   try to guess the secret sequence of colors that the opponent has chosen.
#   Each turn, the player selects a four piece sequence using six different
#   colors, and the opponent responds by giving the player black and white
#   pegs accordingly. A black peg means that the player has a right color piece
#   in the right position, while a white peg means that the player has a right
#   color piece but in the wrong position. The game ends when the player either
#   guesses correctly or has failed to figure it out after eight turns.
#
#------------------------------------------------------------------------------
#  Instructions:
#
#     - Place this script in the materials section, above Main.
#
#     - Copy the game board and piece graphics to your game's pictures folder.
#       If you do not already have them, they can be found at:
#       http://rmrk.net/index.php/topic,42143.0.html
#
#     - Check the script options below these instructions to tweak the game's
#       appearance to your likings or change the winning and losing sounds.
#
#     - To start the minigame, simply call it with an event by using the
#       script command and entering "call_mastermind" without the quotation
#       marks. It'll automatically initiate the game.
#
#==============================================================================

module Mastermind_Options
    #============================================================================
    # EDITABLE REGION:
    #============================================================================
 
    Win_Lose = true                       # Show the Win Loss Ratio window
    Side = true                           # Show the side decoration graphic
    Black_Background = true              # Show a black background
    Game_Music = false                    # Plays a different BGM during game
    Game_BGM = ""              # BGM played during the game
    Win_Sound = ""            # Sound played when game is won
    Win_Sound_Type = ""                 # Type of sound Win_Sound is (ME/SE)
    Loss_Sound = ""          # Sound played when game is lost
    Loss_Sound_Type = ""                # Type of sound Loss_Sound is (ME/SE)
 
    #============================================================================
    # END EDITABLE REGION
    #============================================================================
end

#==============================================================================
# ** Game_System
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Adding the wins and losses variables to the game here.
#==============================================================================

class Game_System
    #--------------------------------------------------------------------------
    # * Public Instance Variables
    #--------------------------------------------------------------------------
    attr_accessor :wins                    # number of wins
    attr_accessor :losses                  # number of losses
    #--------------------------------------------------------------------------
    # * Object Initialization
    #--------------------------------------------------------------------------
    alias_method :winlossratio, :initialize
    def initialize
        winlossratio
        @wins = 0
        @losses = 0
    end
end

#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Adding the mastermind command.
#==============================================================================

class Game_Interpreter
    #--------------------------------------------------------------------------
    # * Call Mastermind
    #--------------------------------------------------------------------------
    def call_mastermind
        SceneManager.call(Scene_Mastermind)
    end
end

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  Adding the change to Scene_Mastermind.
#==============================================================================

#~ class Scene_Map
#~ #--------------------------------------------------------------------------
#~ # * Execute Screen Switch
#~ #--------------------------------------------------------------------------
#~ alias kylos_mm_update_scene_change scene_change
#~ def kylos_mm_update_scene_change
#~ return if $game_player.moving?
#~ if $game_temp.next_scene == "mastermind"
#~ call_mastermind
#~ else
#~ scene_change
#~ end
#~ end
#~ #--------------------------------------------------------------------------
#~ # * Switch to Mastermind
#~ #--------------------------------------------------------------------------
#~ def call_mastermind
#~ $game_temp.next_scene = nil
#~ $scene = Scene_Mastermind.new
#~ end
#~ end

#==============================================================================
# ** Window_MastermindRatio
#------------------------------------------------------------------------------
#  This window displays yours wins versus your losses in Mastermind.
#==============================================================================

class Window_MastermindRatio < Window_Base
    #--------------------------------------------------------------------------
    # * Object Initialization
    #     x : window X coordinate
    #     y : window Y coordinate
    #--------------------------------------------------------------------------
    def initialize(x, y)
        super(x, y, 135, 80)
        refresh
    end
    #--------------------------------------------------------------------------
    # * Refresh
    #--------------------------------------------------------------------------
    def refresh
        self.contents.clear
        self.contents.font.color = system_color
        self.contents.draw_text(4, 0, 90, line_height, "Wins:")
        self.contents.font.color = normal_color
        self.contents.draw_text(4, 0, 90, line_height, $game_system.wins, 2)
        self.contents.font.color = system_color
        self.contents.draw_text(4, 0, 90, line_height*2.6, "Losses:")
        self.contents.font.color = normal_color
        self.contents.draw_text(4, 0, 90, line_height*2.6, $game_system.losses, 2)
    end
end

class Window_MastermindCommand < Window_Command
    def initialize(x, y)
        super(x, y)
    end
 
    def process_handling
     
    end
 
    def make_command_list
        s1 = "Play Normal Game?"
        s2 = "Play Hard Game?"
        s3 = "Quit"
        add_command(s1, :s1)
        add_command(s2, :s2)
        add_command(s3, :s3)
    end
 
end


class Window_MastermindCommand_Color < Window_Command
    def initialize(x, y)
        super(x, y)
    end
 
    def make_command_list
        s1 = "Red"
        s2 = "Orange"
        s3 = "Yellow"
        s4 = "Green"
        s5 = "Blue"
        s6 = "Purple"
        add_command(s1, :s1a)
        add_command(s2, :s2a)
        add_command(s3, :s3a)
        add_command(s4, :s4)
        add_command(s5, :s5)
        add_command(s6, :s6)
    end
 
    def process_handling
     
    end
 
    def visible_line_number
        return 6
    end
 
end


#==============================================================================
# ** Scene_Mastermind
#------------------------------------------------------------------------------
#  This class performs the Mastermind screen processing.
#==============================================================================

class Scene_Mastermind < Scene_MenuBase
    #--------------------------------------------------------------------------
    # * Start processing
    #--------------------------------------------------------------------------
    def start
        super
        if Mastermind_Options::Game_Music == true
            @last_bgm = RPG::BGM::last
            @last_bgs = RPG::BGS::last
            RPG::BGS.stop
            temp_sound = "Audio/BGM/" + Mastermind_Options::Game_BGM
            Audio.bgm_play(temp_sound, 100, 100)
        end
        @playe_vocab = "Play Normal Game?"
        @playh_vocab = "Play Hard Game?"
        @cancel_vocab = "Quit"
        create_background if Mastermind_Options::Black_Background == false
        create_command_window
        create_command_window_2
        if Mastermind_Options::Win_Lose == true
            @winloss = Window_MastermindRatio.new(5.5, 10)
        end
        @board_sprite = Sprite.new(Viewport.new(0, 0, 544, 416))
        @board_sprite.bitmap = Cache.picture("mm_board")
        @board_sprite.x = 0
        @board_sprite.y = 0
        @board_sprite.z = 1
        @answer_sprite = Sprite.new
        @answer_sprite.bitmap = Cache.picture("mm_answer")
        @answer_sprite.x = 212
        @answer_sprite.y = -25
        @answer_sprite.z = 10
        @hard_sprite = Sprite.new(Viewport.new(0, 0, 544, 416))
        @hard_sprite.bitmap = Cache.picture("mm_hard")
        @hard_sprite.x = 0
        @hard_sprite.y = 0
        @hard_sprite.z = 2
        if Mastermind_Options::Side == true
            @side_sprite = Sprite.new
            @side_sprite.bitmap = Cache.picture("mm_side")
            @side_sprite.x = 399 + (146 - @side_sprite.width) / 2
            @side_sprite.y = (416 - @side_sprite.height) / 2
            @side_sprite.z = 1
        end
        @color_sprite = []
        @peg_sprite = []
        @guess = []
        @guess_used = []
        @answer = []
        @answer_used = []
        @color_index = 0
        @peg_index = 0
        @game_mode = "start"
    end
    #--------------------------------------------------------------------------
    # * Post-Start Processing
    #--------------------------------------------------------------------------
    def post_start
        super
        open_command_window
    end
    #--------------------------------------------------------------------------
    # * Wait
    #--------------------------------------------------------------------------
    def wait(duration)
        for i in 0...duration
            Graphics.update
        end
    end
    #--------------------------------------------------------------------------
    # * Pre-termination Processing
    #--------------------------------------------------------------------------
    def pre_terminate
        super
        close_command_window
        close_command_window_2
    end
    #--------------------------------------------------------------------------
    # * Termination Processing
    #--------------------------------------------------------------------------
    def terminate
        super
        dispose_command_window
        @board_sprite.dispose
        @answer_sprite.dispose
        @hard_sprite.dispose
        @side_sprite.dispose if Mastermind_Options::Side == true
        @winloss.dispose if Mastermind_Options::Win_Lose == true
        if @color_index != 0
            for i in 0...@color_index
                @color_sprite[i].dispose
            end
            for i in 0...@peg_index
                @peg_sprite[i].dispose
            end
        end
        if Mastermind_Options::Game_Music == true
            @last_bgm.play
            @last_bgs.play
        end
    end
    #--------------------------------------------------------------------------
    # * Frame Update
    #--------------------------------------------------------------------------
    # def tests
        # p 1
    # end
    def easy_terminate
        @hard_sprite.dispose
    end
 
    def update
        super
        #update_menu_background if Mastermind_Options::Black_Background == false
        @winloss.update if Mastermind_Options::Win_Lose == true
        if @game_mode == "start"
            if Input.press?(:C)
                case @command_window.index
                when 0
                    Sound.play_ok
                    close_command_window
                    cover_answer
                    easy_terminate
                when 1
                    Sound.play_ok
                    close_command_window
                    cover_answer
                when 2
                    Sound.play_cancel
                    SceneManager.return
                end
            end
        elsif @game_mode == "color"
            if Input.trigger?(:C)
                if @guess_index != 4
                    Sound.play_ok
                    @go = @command_window_2.index
                    @guess[@guess_index] = @go
                    @color_sprite[@color_index] = Sprite.new
                    @color_sprite[@color_index].bitmap=Cache.picture("mm_color"[email hidden]_s)
                    @color_sprite[@color_index].x = 228 + (@guess_index * 35)
                    @color_sprite[@color_index].y = 360 - (@round_index * 40)
                    @color_sprite[@color_index].z = 2
                    @guess_index += 1
                    @color_index += 1
                    if @guess_index == 4
                        @game_mode = "peg"
                        close_command_window_2
                        @command_window.index = 0
                        @command_window_2.index = 0
                        wait(15)
                        check_colors
                    end
                end
            end
            if Input.trigger?(:B)
                if @guess_index == 0
                    Sound.play_cancel
                    close_command_window_2
                    @playe_vocab = "Continue"
                    @playh_vocab = "Continue"
                    @cancel_vocab = "Quit"
                    @command_window.index = 0
                    @command_window.dispose
                    create_command_window
                    open_command_window
                    @game_mode = "quit"
                else
                    case @guess_index
                    when 1
                        @guess[0] = -1
                    when 2
                        @guess[1] = -1
                    when 3
                        @guess[2] = -1
                    end
                    @guess_index -= 1
                    @color_index -= 1
                    Sound.play_cancel
                    @color_sprite[@color_index].dispose
                end
            end
        elsif @game_mode == "quit"
            if Input.press?(:C)
                case @command_window.index
                when 0
                    Sound.play_ok
                    close_command_window
                    open_command_window_2
                    @game_mode = "color"
                when 1
                    Sound.play_ok
                    close_command_window
                    open_command_window_2
                    @game_mode = "color"
                when 2
                    Sound.play_cancel
                    SceneManager.return
                end
            end
        elsif @game_mode == "win" or @game_mode == "lose"
            if @command_window.openness == 255
                if Input.trigger?(:C)
                    case @command_window.index
                    when 0
                        Sound.play_ok
                        opac = 250
                        close_command_window
                        wait(8)
                        begin
                            opac -= 10
                            for i in 0...@color_index
                                @color_sprite[i].opacity = opac
                            end
                            for i in 0...@peg_index
                                @peg_sprite[i].opacity = opac
                            end
                            wait(2)
                        end until opac == 0
                        for i in 0...@color_index
                            @color_sprite[i].dispose
                        end
                        for i in 0...@peg_index
                            @peg_sprite[i].dispose
                        end
                        wait(10)
                        cover_answer
                        easy_terminate
                    when 1
                        Sound.play_ok
                        opac = 250
                        close_command_window
                        wait(8)
                        begin
                            opac -= 10
                            for i in 0...@color_index
                                @color_sprite[i].opacity = opac
                            end
                            for i in 0...@peg_index
                                @peg_sprite[i].opacity = opac
                            end
                            wait(2)
                        end until opac == 0
                        for i in 0...@color_index
                            @color_sprite[i].dispose
                        end
                        for i in 0...@peg_index
                            @peg_sprite[i].dispose
                        end
                        wait(10)
                        cover_answer
                        easy_terminate
                        @hard_sprite = Sprite.new(Viewport.new(0, 0, 544, 416))
                        @hard_sprite.bitmap = Cache.picture("mm_hard")
                        @hard_sprite.x = 0
                        @hard_sprite.y = 0
                        @hard_sprite.z = 2
                    when 2
                        Sound.play_cancel
                        SceneManager.return
                    end
                end
            end
        end
    end
    #--------------------------------------------------------------------------
    # * Update Background for Menu Screen
    #--------------------------------------------------------------------------
    def update_menu_background
        #~ super
        #~ @menuback_sprite.tone.set(0, 0, 0, 128)
    end
    #--------------------------------------------------------------------------
    # * Game Start
    #--------------------------------------------------------------------------
    def cover_answer
      if @command_window.index == 1
        @round_index = 2
      else
        @round_index = 0
      end
        @color_index = 0
        @peg_index = 0
        @guess[0] = -1
        @guess[1] = -1
        @guess[2] = -1
        @guess[3] = -1
        @guess_used[0] = false
        @guess_used[1] = false
        @guess_used[2] = false
        @guess_used[3] = false
        @guess_index = 0
        @answer[0] = -1
        @answer[1] = -1
        @answer[2] = -1
        @answer[3] = -1
        @answer_used[0] = false
        @answer_used[1] = false
        @answer_used[2] = false
        @answer_used[3] = false
        @peg_hole = 0
        @j = 0
        @k = 0
        @distance = 19 - (@answer_sprite.y)
        @iindex = 0
        RPG::ME.stop
        RPG::SE.stop
        for i in 0...4
            Sound.play_cursor
            temp_answer = rand(5)
            @color_sprite[i] = Sprite.new
            @color_sprite[i].bitmap=Cache.picture("mm_color"+temp_answer.to_s)
            @color_sprite[i].x = 228 + (i * 35)
            @color_sprite[i].y = 29
            @color_sprite[i].z = 2
            @color_index += 1
            wait(10)
        end
        while @distance > 0
            @answer_sprite.y += 1
            temp_answer = rand(5)
            @color_sprite[@iindex].bitmap=Cache.picture("mm_color"+temp_answer.to_s)
            @iindex += 1
            if @iindex == 4
                @iindex = 0
            end
            @distance = 19 - (@answer_sprite.y)
            Sound.play_cursor
            wait(2)
        end
        for i in 0...4
            @answer[i] = rand(5)
            @color_sprite[i].bitmap=Cache.picture("mm_color"+@answer[i].to_s)
            @color_sprite[i].z = 2
        end
        open_command_window_2
        @game_mode = "color"
    end
    #--------------------------------------------------------------------------
    # * Game End
    #--------------------------------------------------------------------------
    def uncover_answer
        begin
            @answer_sprite.y -= 1
            wait(2)
        end until @answer_sprite.y == -25
        @playe_vocab = "Try Harder"
        @playh_vocab = "Rematch"
        @cancel_vocab = "Quit"
        @command_window.dispose
        create_command_window
        open_command_window
    end
    #--------------------------------------------------------------------------
    # * Round End
    #--------------------------------------------------------------------------
    def check_colors
        for i in 0...4
            if @guess[i] == @answer[i]
                @guess_used[i] = true
                @answer_used[i] = true
                @peg_sprite[@peg_index] = Sprite.new
                @peg_sprite[@peg_index].bitmap = Cache.picture("mm_black")
                case @peg_hole
                when 0
                    @peg_sprite[@peg_index].x = 184
                    @peg_sprite[@peg_index].y = 358 - (@round_index * 40)
                when 1
                    @peg_sprite[@peg_index].x = 198
                    @peg_sprite[@peg_index].y = 358 - (@round_index * 40)
                when 2
                    @peg_sprite[@peg_index].x = 184
                    @peg_sprite[@peg_index].y = 372 - (@round_index * 40)
                when 3
                    @peg_sprite[@peg_index].x = 198
                    @peg_sprite[@peg_index].y = 372 - (@round_index * 40)
                end
                @peg_sprite[@peg_index].z = 2
                @peg_index += 1
                @peg_hole += 1
                if @peg_hole == 4
                    @game_mode = "win"
                end
            end
        end
        while @j <= 3
            if @j != @k
                if @guess[@j] == @answer[@k]
                    if @guess_used[@j] == false
                        if @answer_used[@k] == false
                            @guess_used[@j] = true
                            @answer_used[@k] = true
                            @peg_sprite[@peg_index] = Sprite.new
                            @peg_sprite[@peg_index].bitmap = Cache.picture("mm_white")
                            case @peg_hole
                            when 0
                                @peg_sprite[@peg_index].x = 184
                                @peg_sprite[@peg_index].y = 358 - (@round_index * 40)
                            when 1
                                @peg_sprite[@peg_index].x = 198
                                @peg_sprite[@peg_index].y = 358 - (@round_index * 40)
                            when 2
                                @peg_sprite[@peg_index].x = 184
                                @peg_sprite[@peg_index].y = 372 - (@round_index * 40)
                            when 3
                                @peg_sprite[@peg_index].x = 198
                                @peg_sprite[@peg_index].y = 372 - (@round_index * 40)
                            end
                            @peg_sprite[@peg_index].z = 2
                            @peg_index += 1
                            @peg_hole += 1
                        end
                    end
                end
            end
            @k += 1
            if @k == 4
                @j += 1
                @k = 0
            end
        end
        @guess[0] = -1
        @guess[1] = -1
        @guess[2] = -1
        @guess[3] = -1
        @guess_used[0] = false
        @guess_used[1] = false
        @guess_used[2] = false
        @guess_used[3] = false
        @guess_index = 0
        @answer_used[0] = false
        @answer_used[1] = false
        @answer_used[2] = false
        @answer_used[3] = false
        @peg_hole = 0
        @j = 0
        @k = 0
        wait(15)
        if @round_index == 7 and @game_mode != "win"
            @game_mode = "lose"
            if Mastermind_Options::Loss_Sound_Type == "SE"
                temp_sound = "Audio/SE/" + Mastermind_Options::Loss_Sound
                Audio.se_play(temp_sound, 100, 100)
            elsif Mastermind_Options::Loss_Sound_Type == "ME"
                temp_sound = "Audio/ME/" + Mastermind_Options::Loss_Sound    
                Audio.me_play(temp_sound, 100, 100)
            end
            $game_system.losses += 1
            @winloss.refresh if Mastermind_Options::Win_Lose == true
            uncover_answer
        elsif @game_mode == "win"
            if Mastermind_Options::Win_Sound_Type == "SE"
                temp_sound = "Audio/SE/" + Mastermind_Options::Win_Sound
                Audio.se_play(temp_sound, 100, 100)
            elsif Mastermind_Options::Win_Sound_Type == "ME"
                temp_sound = "Audio/ME/" + Mastermind_Options::Win_Sound    
                Audio.me_play(temp_sound, 100, 100)
            end
            $game_system.wins += 1
            @winloss.refresh if Mastermind_Options::Win_Lose == true
            uncover_answer
        else
            @round_index += 1
            open_command_window_2
            @game_mode = "color"
        end
    end
    #--------------------------------------------------------------------------
    # * Create Command Window
    #--------------------------------------------------------------------------
    def create_command_window
        @command_window = Window_MastermindCommand.new(0, 0)
        @command_window.x = (Graphics.width - @command_window.width) / 2
        @command_window.y = (Graphics.height - @command_window.height) / 2
        @command_window.height = @command_window.fitting_height(3)
        @command_window.refresh
        @command_window.openness = 0
    end
    #--------------------------------------------------------------------------
    # * Dispose of Command Window
    #--------------------------------------------------------------------------
    def dispose_command_window
        @command_window.dispose
        @command_window_2.dispose
    end
    #--------------------------------------------------------------------------
    # * Open Command Window
    #--------------------------------------------------------------------------
    def open_command_window
        @command_window.open
        @command_window.refresh
        @command_window.active = true
    end
    #--------------------------------------------------------------------------
    # * Close Command Window
    #--------------------------------------------------------------------------
    def close_command_window
        @command_window.close
        @command_window.refresh
        @command_window.active = false
    end
    #--------------------------------------------------------------------------
    # * Create Command Window Two
    #--------------------------------------------------------------------------
    def create_command_window_2
        @command_window_2 = Window_MastermindCommand_Color.new(0, 0)
        @command_window_2.x = (198 - @command_window_2.width) / 2
        @command_window_2.height = @command_window_2.fitting_height(6)
        if Mastermind_Options::Win_Lose == false
            @command_window_2.y = (Graphics.height - @command_window_2.height) / 2
        else
            @command_window_2.y = 210
        end
        @command_window_2.openness = 0
        @command_window_2.active = false
    end
    #--------------------------------------------------------------------------
    # * Open Command Window Two
    #--------------------------------------------------------------------------
    def open_command_window_2
        @command_window_2.open
        @command_window_2.active = true
        @command_window_2.refresh
    end
    #--------------------------------------------------------------------------
    # * Close Command Window Two
    #--------------------------------------------------------------------------
    def close_command_window_2
        @command_window_2.close
        @command_window_2.active = false
        @command_window_2.refresh
    end
end
Got it working, and tested a fair bit. Hopefully there is no bugs.
Spoiler: Mindmaster with options
Ruby:
#==============================================================================
#  Mastermind (VX)
#  Version: 1.0
#  Author: Zylos (rmrk.net)
#  Date: March 21, 2011
#  Mod by Roninator2
#  Date 3 September 2020
#------------------------------------------------------------------------------
#  Description:
#
#   This script sets up a classic Mastermind mini-game, in which the player must
#   try to guess the secret sequence of colors that the opponent has chosen.
#   Each turn, the player selects a four piece sequence using six different
#   colors, and the opponent responds by giving the player black and white
#   pegs accordingly. A black peg means that the player has a right color piece
#   in the right position, while a white peg means that the player has a right
#   color piece but in the wrong position. The game ends when the player either
#   guesses correctly or has failed to figure it out after eight turns.
#
#------------------------------------------------------------------------------
#  Instructions:
#   
#     - Place this script in the materials section, above Main.
#
#     - Copy the game board and piece graphics to your game's pictures folder.
#       If you do not already have them, they can be found at:
#       http://rmrk.net/index.php/topic,42143.0.html
#
#     - Check the script options below these instructions to tweak the game's
#       appearance to your liking or change the winning and losing sounds.
#
#     - To start the mini-game, simply call it with an event by using the
#       script command and entering "call_mastermind" without the quotation
#       marks. It'll automatically initiate the game.
#
#==============================================================================

module Mastermind_Options
#============================================================================
# EDITABLE REGION:
#============================================================================

Side = true                           # Show the side decoration graphic
Black_Background = false              # Show a black background
Game_Music = false                    # Plays a different BGM during game
Game_BGM = ""              # BGM played during the game
Win_Sound = ""            # Sound played when game is won
Win_Sound_Type = ""                 # Type of sound Win_Sound is (ME/SE)
Loss_Sound = ""          # Sound played when game is lost
Loss_Sound_Type = ""                # Type of sound Loss_Sound is (ME/SE)
Difficulty = 1     # switch used to set the difficulty. on = hard
Colours = 1  # Values from 1 - 6 # variable used to set how many colours used
# value equals how many colors. 2 = 2 colors. Will exit if 0.
Lives = 2                 # variable used to set how many chances (lives)
Win = 2                   # switch turns on when player wins
Victory = "Congratulations! You're smater than the average bear."
# message shown after winning
#============================================================================
# END EDITABLE REGION
#============================================================================
end

#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Adding the mastermind command.
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Call Mastermind
  #--------------------------------------------------------------------------
  def call_mastermind
    SceneManager.call(Scene_Mastermind)
  end
end

#==============================================================================
# ** Window_MastermindCommand_Color
#------------------------------------------------------------------------------
#  This window displays your colors to use in the game.
#==============================================================================
class Window_MastermindCommand_Color < Window_Command
  def initialize(x, y)
    super(x, y)
  end
 
  def make_command_list
    s1 = "Red"
    s2 = "Orange"
    s3 = "Yellow"
    s4 = "Green"
    s5 = "Blue"
    s6 = "Purple"
    add_command(s1, :s1a)
    add_command(s2, :s2a)
    add_command(s3, :s3a)
    add_command(s4, :s4)
    add_command(s5, :s5)
    add_command(s6, :s6)
  end
 
  def process_handling
      
  end
 
  def visible_line_number
    return 6
  end
  
end


#==============================================================================
# ** Scene_Mastermind
#------------------------------------------------------------------------------
#  This class performs the Mastermind screen processing.
#==============================================================================

class Scene_Mastermind < Scene_MenuBase
    #--------------------------------------------------------------------------
    # * Start processing
    #--------------------------------------------------------------------------
    def start
      if $game_variables[Mastermind_Options::Colours] == 0
        error = "Colors are set to 0!"
        $game_message.add(sprintf(error, @actor))
        SceneManager.return
      end
      super
      @colours = []
      if Mastermind_Options::Game_Music == true
        @last_bgm = RPG::BGM::last
        @last_bgs = RPG::BGS::last
        RPG::BGS.stop
        temp_sound = "Audio/BGM/" + Mastermind_Options::Game_BGM
        Audio.bgm_play(temp_sound, 100, 100)
      end
      create_background if Mastermind_Options::Black_Background == false
      create_command_window_2
      @board_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
      @board_sprite.bitmap = Cache.picture("mm_board")
      @board_sprite.x = 1
      @board_sprite.y = 1
      @board_sprite.z = 1
      @answer_sprite = Sprite.new
      @answer_sprite.bitmap = Cache.picture("mm_answer")
      @answer_sprite.x = 260
      @answer_sprite.y = -20
      @answer_sprite.z = 10
      @hard_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
      @hard_sprite.bitmap = Cache.picture("mm_hard")
      @hard_sprite.x = 1
      @hard_sprite.y = 1
      @hard_sprite.z = 2
      if Mastermind_Options::Side == true
        @side_sprite = Sprite.new
        @side_sprite.bitmap = Cache.picture("mm_side")
        @side_sprite.x = 420 + (146 - @side_sprite.width) / 2
        @side_sprite.y = (480 - @side_sprite.height) / 2
        @side_sprite.z = 1
      end
      @color_sprite = []
      @peg_sprite = []
      @guess = []
      @guess_used = []
      @answer = []
      @answer_used = []
      @color_index = 0
      @peg_index = 0
      @game_mode = "start"
    end
    #--------------------------------------------------------------------------
    # * Wait
    #--------------------------------------------------------------------------
    def wait(duration)
        for i in 0...duration
            Graphics.update
        end
    end
    #--------------------------------------------------------------------------
    # * Pre-termination Processing
    #--------------------------------------------------------------------------
    def pre_terminate
        super
        close_command_window_2
    end
    #--------------------------------------------------------------------------
    # * Termination Processing
    #--------------------------------------------------------------------------
    def terminate
        super
        @board_sprite.dispose
        @answer_sprite.dispose
        @hard_sprite.dispose
        @side_sprite.dispose if Mastermind_Options::Side == true
        if @color_index != 0
            for i in 0...@color_index
                @color_sprite[i].dispose
            end
            for i in 0...@peg_index
                @peg_sprite[i].dispose
            end
        end
        if Mastermind_Options::Game_Music == true
            @last_bgm.play
            @last_bgs.play
        end
    end
    #--------------------------------------------------------------------------
    # * Frame Update
    #--------------------------------------------------------------------------
    def easy_terminate
        @hard_sprite.dispose
    end
  
    def update
        super
        if @game_mode == "start"
          $game_switches[Mastermind_Options::Win] == false
          Sound.play_ok
          cover_answer
          if $game_switches[Mastermind_Options::Difficulty] != true
            easy_terminate
          end
        elsif @game_mode == "color"
          if Input.trigger?(:C)
            if @guess_index != 4
              Sound.play_ok
              @go = @command_window_2.index
              @guess[@guess_index] = @go
              @color_sprite[@color_index] = Sprite.new
              @color_sprite[@color_index].bitmap=Cache.picture("mm_color"[email hidden]_s)
              @color_sprite[@color_index].x = 278 + (@guess_index * 35)
              @color_sprite[@color_index].y = 430 - (@round_index * 40)
              @color_sprite[@color_index].z = 2
              @guess_index += 1
              @color_index += 1
              if @guess_index == 4
                  @game_mode = "peg"
                  close_command_window_2
                  @command_window_2.index = 0
                  wait(15)
                  check_colors
              end
            end
          end
          if Input.trigger?(:B)
            if @guess_index == 0
              Sound.play_cancel
              close_command_window_2
              @game_mode = "quit"
            else
              case @guess_index
              when 1
                @guess[0] = -1
              when 2
                @guess[1] = -1
              when 3
                @guess[2] = -1
              end
              @guess_index -= 1
              @color_index -= 1
              Sound.play_cancel
              @color_sprite[@color_index].dispose
            end
          end
        elsif @game_mode == "quit"
          Sound.play_cancel
          SceneManager.return
        elsif @game_mode == "lose"
          Sound.play_cancel
          wait(8)
          if $game_variables[Mastermind_Options::Lives] > 0
            open_command_window_2
            @game_mode = "color"
            $game_variables[Mastermind_Options::Lives] -= 1
            for i in 0...@color_index
              @color_sprite[i].dispose
            end
            for i in 0...@peg_index
              @peg_sprite[i].dispose
            end
            wait(10)
            cover_answer
            @hard_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
            @hard_sprite.bitmap = Cache.picture("mm_hard")
            @hard_sprite.x = 1
            @hard_sprite.y = 5
            @hard_sprite.z = 2
            if $game_switches[Mastermind_Options::Difficulty] != true
              easy_terminate
            end
          else
            Sound.play_cancel
            SceneManager.return
          end
      elsif @game_mode == "win"
        Sound.play_use_skill
        $game_message.add(sprintf(Mastermind_Options::Victory, @actor))
        $game_switches[Mastermind_Options::Win] = true
        SceneManager.return
      end
    end
    #--------------------------------------------------------------------------
    # * Game Start
    #--------------------------------------------------------------------------
    def cover_answer
      if $game_switches[Mastermind_Options::Difficulty] == true
        @round_index = 2
      else
        @round_index = 0
      end
      @color_index = 0
      @peg_index = 0
      @guess[0] = -1
      @guess[1] = -1
      @guess[2] = -1
      @guess[3] = -1
      @guess_used[0] = false
      @guess_used[1] = false
      @guess_used[2] = false
      @guess_used[3] = false
      @guess_index = 0
      @answer[0] = -1
      @answer[1] = -1
      @answer[2] = -1
      @answer[3] = -1
      @answer_used[0] = false
      @answer_used[1] = false
      @answer_used[2] = false
      @answer_used[3] = false
      @peg_hole = 0
      @j = 0
      @k = 0   
      @distance = 50 - (@answer_sprite.y)
      @iindex = 0
      RPG::ME.stop
      RPG::SE.stop
      for i in 0..3
        Sound.play_cursor
        temp_answer = rand(5)
        @color_sprite[i] = Sprite.new
        @color_sprite[i].bitmap=Cache.picture("mm_color"+temp_answer.to_s)
        @color_sprite[i].x = 278 + (i * 35)
        @color_sprite[i].y = 20
        @color_sprite[i].z = 2
        @color_index += 1
        wait(10)
      end
      while @distance > 0
        @answer_sprite.y += 1
        temp_answer = rand(5)
        @color_sprite[@iindex].bitmap=Cache.picture("mm_color"+temp_answer.to_s)
        @iindex += 1
        if @iindex == 4
          @iindex = 0
        end
        @distance = 10 - (@answer_sprite.y)
        Sound.play_cursor
        wait(2)
      end
      for i in 0..$game_variables[Mastermind_Options::Colours] - 1
        pick = rand(5)
        if [email protected]?(pick)
          @colours << pick if @colours.size != $game_variables[Mastermind_Options::Colours]
        end
        if (i == $game_variables[Mastermind_Options::Colours]) && (@colours.size != $game_variables[Mastermind_Options::Colours])
          i -= 1
        end
      end
      for i in 0..3
        count = @colours.size
        number = rand(count)
        setcolour = @colours[number]
        @answer[i] = setcolour
        @color_sprite[i].bitmap=Cache.picture("mm_color"+@answer[i].to_s)
        @color_sprite[i].z = 2
      end
      open_command_window_2
      @game_mode = "color"
    end
    #--------------------------------------------------------------------------
    # * Game End
    #--------------------------------------------------------------------------
    def uncover_answer
      begin
        @answer_sprite.y -= 1
        wait(2)
      end until @answer_sprite.y == -25
      wait(60)
    end
    #--------------------------------------------------------------------------
    # * Round End
    #--------------------------------------------------------------------------
    def check_colors
      for i in 0...4
        if @guess[i] == @answer[i]
          @guess_used[i] = true
          @answer_used[i] = true
          @peg_sprite[@peg_index] = Sprite.new
          @peg_sprite[@peg_index].bitmap = Cache.picture("mm_black")
          case @peg_hole
          when 0
            @peg_sprite[@peg_index].x = 234
            @peg_sprite[@peg_index].y = 430 - (@round_index * 40)
          when 1
            @peg_sprite[@peg_index].x = 248
            @peg_sprite[@peg_index].y = 430 - (@round_index * 40)
          when 2
            @peg_sprite[@peg_index].x = 234
            @peg_sprite[@peg_index].y = 444 - (@round_index * 40)
          when 3
            @peg_sprite[@peg_index].x = 248
            @peg_sprite[@peg_index].y = 444 - (@round_index * 40)
          end
          @peg_sprite[@peg_index].z = 2
          @peg_index += 1
          @peg_hole += 1
          if @peg_hole == 4
            @game_mode = "win"
          end
        end
      end
      while @j <= 3
        if @j != @k
          if @guess[@j] == @answer[@k]
            if @guess_used[@j] == false
              if @answer_used[@k] == false
                @guess_used[@j] = true
                @answer_used[@k] = true
                @peg_sprite[@peg_index] = Sprite.new
                @peg_sprite[@peg_index].bitmap = Cache.picture("mm_white")
                case @peg_hole
                when 0
                  @peg_sprite[@peg_index].x = 234
                  @peg_sprite[@peg_index].y = 430 - (@round_index * 40)
                when 1
                  @peg_sprite[@peg_index].x = 248
                  @peg_sprite[@peg_index].y = 430 - (@round_index * 40)
                when 2
                  @peg_sprite[@peg_index].x = 234
                  @peg_sprite[@peg_index].y = 444 - (@round_index * 40)
                when 3
                  @peg_sprite[@peg_index].x = 248
                  @peg_sprite[@peg_index].y = 444 - (@round_index * 40)
                end
                @peg_sprite[@peg_index].z = 2
                @peg_index += 1
                @peg_hole += 1
              end
            end
          end
        end
        @k += 1
        if @k == 4
          @j += 1
          @k = 0
        end
      end
      @guess[0] = -1
      @guess[1] = -1
      @guess[2] = -1
      @guess[3] = -1
      @guess_used[0] = false
      @guess_used[1] = false
      @guess_used[2] = false
      @guess_used[3] = false
      @guess_index = 0
      @answer_used[0] = false
      @answer_used[1] = false
      @answer_used[2] = false
      @answer_used[3] = false
      @peg_hole = 0
      @j = 0
      @k = 0
      wait(15)
      if @round_index == 9 and @game_mode != "win"
        @game_mode = "lose"
        if Mastermind_Options::Loss_Sound_Type == "SE"
          temp_sound = "Audio/SE/" + Mastermind_Options::Loss_Sound
          Audio.se_play(temp_sound, 100, 100)
        elsif Mastermind_Options::Loss_Sound_Type == "ME"
          temp_sound = "Audio/ME/" + Mastermind_Options::Loss_Sound       
          Audio.me_play(temp_sound, 100, 100)
        end
        uncover_answer
        if $game_variables[Mastermind_Options::Lives] > 0
          update
        else
          Sound.play_cancel
          SceneManager.return
        end
      elsif @game_mode == "win"
        if Mastermind_Options::Win_Sound_Type == "SE"
          temp_sound = "Audio/SE/" + Mastermind_Options::Win_Sound
          Audio.se_play(temp_sound, 100, 100)
        elsif Mastermind_Options::Win_Sound_Type == "ME"
          temp_sound = "Audio/ME/" + Mastermind_Options::Win_Sound       
          Audio.me_play(temp_sound, 100, 100)
        end
          uncover_answer
      else
        @round_index += 1
        open_command_window_2
        @game_mode = "color"
      end
    end
    #--------------------------------------------------------------------------
    # * Create Command Window Two
    #--------------------------------------------------------------------------
    def create_command_window_2
      @command_window_2 = Window_MastermindCommand_Color.new(0, 0)
      @command_window_2.x = (200 - @command_window_2.width) / 2
      @command_window_2.height = @command_window_2.fitting_height(6)
      @command_window_2.y = 210
      @command_window_2.openness = 0
      @command_window_2.active = false
    end
    #--------------------------------------------------------------------------
    # * Open Command Window Two
    #--------------------------------------------------------------------------
    def open_command_window_2
      @command_window_2.open
      @command_window_2.active = true
      @command_window_2.refresh
    end
    #--------------------------------------------------------------------------
    # * Close Command Window Two
    #--------------------------------------------------------------------------
    def close_command_window_2
      @command_window_2.close
      @command_window_2.active = false
      @command_window_2.refresh
    end
end
Thanks, @Roninator2. I tested it but it looks like this. Also, is there a way to have the amount of lifes displayed (for example) at the upper left?

Unbenannt.png
it looks like this
Can you give me your graphic files? The positions are adjusted with the files that I have.
You also seem to have 8 slots not 9. what is your graphic resolution?
@Roninator2 I use the default resolution of 544x416 px. I took the graphic files I found from the thread mentioned above. Here are they.

Dunno about the slots, though. Haven't changed anything in the script.
took the graphic files I found from the thread
Right, sorry I had modified the board file to make it 9 high that's why it's different.
Thanks. Try this...
Spoiler: Mastermind - 544x416 - with conditions
Ruby:
#==============================================================================
#  Mastermind (VX)
#  Version: 1.0
#  Author: Zylos (rmrk.net)
#  Date: March 21, 2011
#------------------------------------------------------------------------------
#  Description:
#
#   This script sets up a classic Mastermind minigame, in which the player must
#   try to guess the secret sequence of colors that the opponent has chosen.
#   Each turn, the player selects a four piece sequence using six different
#   colors, and the opponent responds by giving the player black and white
#   pegs accordingly. A black peg means that the player has a right color piece
#   in the right position, while a white peg means that the player has a right
#   color piece but in the wrong position. The game ends when the player either
#   guesses correctly or has failed to figure it out after eight turns.
#
#------------------------------------------------------------------------------
#  Instructions:
#   
#     - Place this script in the materials section, above Main.
#
#     - Copy the game board and piece graphics to your game's pictures folder.
#       If you do not already have them, they can be found at:
#       http://rmrk.net/index.php/topic,42143.0.html
#
#     - Check the script options below these instructions to tweak the game's
#       appearance to your likings or change the winning and losing sounds.
#
#     - To start the minigame, simply call it with an event by using the
#       script command and entering "call_mastermind" without the quotation
#       marks. It'll automatically initiate the game.
#
#==============================================================================

module Mastermind_Options
#============================================================================
# EDITABLE REGION:
#============================================================================

Side = true                           # Show the side decoration graphic
Black_Background = true              # Show a black background
Game_Music = false                    # Plays a different BGM during game
Game_BGM = ""              # BGM played during the game
Win_Sound = ""            # Sound played when game is won
Win_Sound_Type = ""                 # Type of sound Win_Sound is (ME/SE)
Loss_Sound = ""          # Sound played when game is lost
Loss_Sound_Type = ""                # Type of sound Loss_Sound is (ME/SE)
Difficulty = 1                      # switch used to set the difficulty
Colours = 1  # Values from 1 - 6 # variable used to set how many colours used
# value equals how many colors. 2 = 2 colors. Will exit if 0.
Lives = 2                 # variable used to set how many chances (lives)
Win = 2                   # switch turns on when player wins
Victory = "Congradulations! You're smater than the average bear."
# message shown after winning
#============================================================================
# END EDITABLE REGION
#============================================================================
end

#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Adding the mastermind command.
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Call Mastermind
  #--------------------------------------------------------------------------
  def call_mastermind
    SceneManager.call(Scene_Mastermind)
  end
end

#==============================================================================
# ** Window_MastermindCommand_Color
#------------------------------------------------------------------------------
#  This window displays your colors to use in the game.
#==============================================================================
class Window_MastermindCommand_Color < Window_Command
  def initialize(x, y)
    super(x, y)
  end
 
  def make_command_list
    s1 = "Red"
    s2 = "Orange"
    s3 = "Yellow"
    s4 = "Green"
    s5 = "Blue"
    s6 = "Purple"
    add_command(s1, :s1a)
    add_command(s2, :s2a)
    add_command(s3, :s3a)
    add_command(s4, :s4)
    add_command(s5, :s5)
    add_command(s6, :s6)
  end
 
  def process_handling
      
  end
 
  def visible_line_number
    return 6
  end
  
end


#==============================================================================
# ** Scene_Mastermind
#------------------------------------------------------------------------------
#  This class performs the Mastermind screen processing.
#==============================================================================

class Scene_Mastermind < Scene_MenuBase
    #--------------------------------------------------------------------------
    # * Start processing
    #--------------------------------------------------------------------------
    def start
      if $game_variables[Mastermind_Options::Colours] == 0
        error = "Colors are set to 0!"
        $game_message.add(sprintf(error, @actor))
        SceneManager.return
      end
      super
      @colours = []
      if Mastermind_Options::Game_Music == true
        @last_bgm = RPG::BGM::last
        @last_bgs = RPG::BGS::last
        RPG::BGS.stop
        temp_sound = "Audio/BGM/" + Mastermind_Options::Game_BGM
        Audio.bgm_play(temp_sound, 100, 100)
      end
      create_background if Mastermind_Options::Black_Background == false
      create_command_window_2
      @board_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
      @board_sprite.bitmap = Cache.picture("mm_board")
      @board_sprite.x = 50
      @board_sprite.y = 0
      @board_sprite.z = 1
      @answer_sprite = Sprite.new
      @answer_sprite.bitmap = Cache.picture("mm_answer")
      @answer_sprite.x = 260
      @answer_sprite.y = -25
      @answer_sprite.z = 10
      @hard_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
      @hard_sprite.bitmap = Cache.picture("mm_hard")
      @hard_sprite.x = 50
      @hard_sprite.y = 0
      @hard_sprite.z = 2
      if Mastermind_Options::Side == true
        @side_sprite = Sprite.new
        @side_sprite.bitmap = Cache.picture("mm_side")
        @side_sprite.x = 420 + (146 - @side_sprite.width) / 2
        @side_sprite.y = (410 - @side_sprite.height) / 2
        @side_sprite.z = 1
      end
      @color_sprite = []
      @peg_sprite = []
      @guess = []
      @guess_used = []
      @answer = []
      @answer_used = []
      @color_index = 0
      @peg_index = 0
      @game_mode = "start"
    end
    #--------------------------------------------------------------------------
    # * Wait
    #--------------------------------------------------------------------------
    def wait(duration)
        for i in 0...duration
            Graphics.update
        end
    end
    #--------------------------------------------------------------------------
    # * Pre-termination Processing
    #--------------------------------------------------------------------------
    def pre_terminate
        super
        close_command_window_2
    end
    #--------------------------------------------------------------------------
    # * Termination Processing
    #--------------------------------------------------------------------------
    def terminate
        super
        @board_sprite.dispose
        @answer_sprite.dispose
        @hard_sprite.dispose
        @side_sprite.dispose if Mastermind_Options::Side == true
        if @color_index != 0
            for i in 0...@color_index
                @color_sprite[i].dispose
            end
            for i in 0...@peg_index
                @peg_sprite[i].dispose
            end
        end
        if Mastermind_Options::Game_Music == true
            @last_bgm.play
            @last_bgs.play
        end
    end
    #--------------------------------------------------------------------------
    # * Frame Update
    #--------------------------------------------------------------------------
    def easy_terminate
        @hard_sprite.dispose
    end
  
    def update
        super
        if @game_mode == "start"
          $game_switches[Mastermind_Options::Win] == false
          Sound.play_ok
          cover_answer
          if $game_switches[Mastermind_Options::Difficulty] != true
            easy_terminate
          end
        elsif @game_mode == "color"
          if Input.trigger?(:C)
            if @guess_index != 4
              Sound.play_ok
              @go = @command_window_2.index
              @guess[@guess_index] = @go
              @color_sprite[@color_index] = Sprite.new
              @color_sprite[@color_index].bitmap=Cache.picture("mm_color"[email hidden]_s)
              @color_sprite[@color_index].x = 278 + (@guess_index * 35)
              @color_sprite[@color_index].y = 360 - (@round_index * 40)
              @color_sprite[@color_index].z = 2
              @guess_index += 1
              @color_index += 1
              if @guess_index == 4
                  @game_mode = "peg"
                  close_command_window_2
                  @command_window_2.index = 0
                  wait(15)
                  check_colors
              end
            end
          end
          if Input.trigger?(:B)
            if @guess_index == 0
              Sound.play_cancel
              close_command_window_2
              @game_mode = "quit"
            else
              case @guess_index
              when 1
                @guess[0] = -1
              when 2
                @guess[1] = -1
              when 3
                @guess[2] = -1
              end
              @guess_index -= 1
              @color_index -= 1
              Sound.play_cancel
              @color_sprite[@color_index].dispose
            end
          end
        elsif @game_mode == "quit"
          Sound.play_cancel
          SceneManager.return
        elsif @game_mode == "lose"
          Sound.play_cancel
          wait(8)
          if $game_variables[Mastermind_Options::Lives] > 0
            open_command_window_2
            @game_mode = "color"
            $game_variables[Mastermind_Options::Lives] -= 1
            for i in 0...@color_index
              @color_sprite[i].dispose
            end
            for i in 0...@peg_index
              @peg_sprite[i].dispose
            end
            wait(10)
            cover_answer
            @hard_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
            @hard_sprite.bitmap = Cache.picture("mm_hard")
            @hard_sprite.x = 1
            @hard_sprite.y = 5
            @hard_sprite.z = 2
            if $game_switches[Mastermind_Options::Difficulty] != true
              easy_terminate
            end
          else
            Sound.play_cancel
            SceneManager.return
          end
      elsif @game_mode == "win"
        Sound.play_use_skill
        $game_message.add(sprintf(Mastermind_Options::Victory, @actor))
        $game_switches[Mastermind_Options::Win] = true
        SceneManager.return
      end
    end
    #--------------------------------------------------------------------------
    # * Game Start
    #--------------------------------------------------------------------------
    def cover_answer
      if $game_switches[Mastermind_Options::Difficulty] == true
        @round_index = 2
      else
        @round_index = 0
      end
      @color_index = 0
      @peg_index = 0
      @guess[0] = -1
      @guess[1] = -1
      @guess[2] = -1
      @guess[3] = -1
      @guess_used[0] = false
      @guess_used[1] = false
      @guess_used[2] = false
      @guess_used[3] = false
      @guess_index = 0
      @answer[0] = -1
      @answer[1] = -1
      @answer[2] = -1
      @answer[3] = -1
      @answer_used[0] = false
      @answer_used[1] = false
      @answer_used[2] = false
      @answer_used[3] = false
      @peg_hole = 0
      @j = 0
      @k = 0   
      @distance = 50 - (@answer_sprite.y)
      @iindex = 0
      RPG::ME.stop
      RPG::SE.stop
      for i in 0..3
        Sound.play_cursor
        temp_answer = rand(5)
        @color_sprite[i] = Sprite.new
        @color_sprite[i].bitmap=Cache.picture("mm_color"+temp_answer.to_s)
        @color_sprite[i].x = 277 + (i * 35)
        @color_sprite[i].y = 28
        @color_sprite[i].z = 2
        @color_index += 1
        wait(10)
      end
      while @distance > 0
        @answer_sprite.y += 1
        temp_answer = rand(5)
        @color_sprite[@iindex].bitmap=Cache.picture("mm_color"+temp_answer.to_s)
        @iindex += 1
        if @iindex == 4
          @iindex = 0
        end
        @distance = 20 - (@answer_sprite.y)
        Sound.play_cursor
        wait(2)
      end
      for i in 0..$game_variables[Mastermind_Options::Colours] - 1
        pick = rand(5)
        if [email protected]?(pick)
          @colours << pick if @colours.size != $game_variables[Mastermind_Options::Colours]
        end
        if (i == $game_variables[Mastermind_Options::Colours]) && (@colours.size != $game_variables[Mastermind_Options::Colours])
          i -= 1
        end
      end
      for i in 0..3
        count = @colours.size
        number = rand(count)
        setcolour = @colours[number]
        @answer[i] = setcolour
        @color_sprite[i].bitmap=Cache.picture("mm_color"+@answer[i].to_s)
        @color_sprite[i].z = 2
      end
      open_command_window_2
      @game_mode = "color"
    end
    #--------------------------------------------------------------------------
    # * Game End
    #--------------------------------------------------------------------------
    def uncover_answer
      begin
        @answer_sprite.y -= 1
        wait(2)
      end until @answer_sprite.y == -25
      wait(60)
    end
    #--------------------------------------------------------------------------
    # * Round End
    #--------------------------------------------------------------------------
    def check_colors
      for i in 0...4
        if @guess[i] == @answer[i]
          @guess_used[i] = true
          @answer_used[i] = true
          @peg_sprite[@peg_index] = Sprite.new
          @peg_sprite[@peg_index].bitmap = Cache.picture("mm_black")
          case @peg_hole
          when 0
            @peg_sprite[@peg_index].x = 234
            @peg_sprite[@peg_index].y = 357 - (@round_index * 40)
          when 1
            @peg_sprite[@peg_index].x = 248
            @peg_sprite[@peg_index].y = 357 - (@round_index * 40)
          when 2
            @peg_sprite[@peg_index].x = 234
            @peg_sprite[@peg_index].y = 371 - (@round_index * 40)
          when 3
            @peg_sprite[@peg_index].x = 248
            @peg_sprite[@peg_index].y = 371 - (@round_index * 40)
          end
          @peg_sprite[@peg_index].z = 2
          @peg_index += 1
          @peg_hole += 1
          if @peg_hole == 4
            @game_mode = "win"
          end
        end
      end
      while @j <= 3
        if @j != @k
          if @guess[@j] == @answer[@k]
            if @guess_used[@j] == false
              if @answer_used[@k] == false
                @guess_used[@j] = true
                @answer_used[@k] = true
                @peg_sprite[@peg_index] = Sprite.new
                @peg_sprite[@peg_index].bitmap = Cache.picture("mm_white")
                case @peg_hole
                when 0
                  @peg_sprite[@peg_index].x = 234
                  @peg_sprite[@peg_index].y = 357 - (@round_index * 40)
                when 1
                  @peg_sprite[@peg_index].x = 248
                  @peg_sprite[@peg_index].y = 357 - (@round_index * 40)
                when 2
                  @peg_sprite[@peg_index].x = 234
                  @peg_sprite[@peg_index].y = 371 - (@round_index * 40)
                when 3
                  @peg_sprite[@peg_index].x = 248
                  @peg_sprite[@peg_index].y = 371 - (@round_index * 40)
                end
                @peg_sprite[@peg_index].z = 2
                @peg_index += 1
                @peg_hole += 1
              end
            end
          end
        end
        @k += 1
        if @k == 4
          @j += 1
          @k = 0
        end
      end
      @guess[0] = -1
      @guess[1] = -1
      @guess[2] = -1
      @guess[3] = -1
      @guess_used[0] = false
      @guess_used[1] = false
      @guess_used[2] = false
      @guess_used[3] = false
      @guess_index = 0
      @answer_used[0] = false
      @answer_used[1] = false
      @answer_used[2] = false
      @answer_used[3] = false
      @peg_hole = 0
      @j = 0
      @k = 0
      wait(15)
      if @round_index == 7 and @game_mode != "win"
        @game_mode = "lose"
        if Mastermind_Options::Loss_Sound_Type == "SE"
          temp_sound = "Audio/SE/" + Mastermind_Options::Loss_Sound
          Audio.se_play(temp_sound, 100, 100)
        elsif Mastermind_Options::Loss_Sound_Type == "ME"
          temp_sound = "Audio/ME/" + Mastermind_Options::Loss_Sound       
          Audio.me_play(temp_sound, 100, 100)
        end
        uncover_answer
        if $game_variables[Mastermind_Options::Lives] > 0
          update
        else
          Sound.play_cancel
          SceneManager.return
        end
      elsif @game_mode == "win"
        if Mastermind_Options::Win_Sound_Type == "SE"
          temp_sound = "Audio/SE/" + Mastermind_Options::Win_Sound
          Audio.se_play(temp_sound, 100, 100)
        elsif Mastermind_Options::Win_Sound_Type == "ME"
          temp_sound = "Audio/ME/" + Mastermind_Options::Win_Sound       
          Audio.me_play(temp_sound, 100, 100)
        end
          uncover_answer
      else
        @round_index += 1
        open_command_window_2
        @game_mode = "color"
      end
    end
    #--------------------------------------------------------------------------
    # * Create Command Window Two
    #--------------------------------------------------------------------------
    def create_command_window_2
      @command_window_2 = Window_MastermindCommand_Color.new(0, 0)
      @command_window_2.x = (200 - @command_window_2.width) / 2
      @command_window_2.height = @command_window_2.fitting_height(6)
      @command_window_2.y = 210
      @command_window_2.openness = 0
      @command_window_2.active = false
    end
    #--------------------------------------------------------------------------
    # * Open Command Window Two
    #--------------------------------------------------------------------------
    def open_command_window_2
      @command_window_2.open
      @command_window_2.active = true
      @command_window_2.refresh
    end
    #--------------------------------------------------------------------------
    # * Close Command Window Two
    #--------------------------------------------------------------------------
    def close_command_window_2
      @command_window_2.close
      @command_window_2.active = false
      @command_window_2.refresh
    end
end
Hell yeah, that's it! Thanks a ton, Ronny. It works just fine as far as I tested it.

Ohh, found a bug when losing a life. There's a graphic bug as seen below. And if you lose a life, you get the exact same combination of colors again; would be better to have a new. Can you help me with this?
It works just fine
And here is the lives window
Spoiler: Mastermind - 544x416 - with conditions and lives
Ruby:
#==============================================================================
#  Mastermind (VX)
#  Version: 1.0
#  Author: Zylos (rmrk.net)
#  Date: March 21, 2011
#------------------------------------------------------------------------------
#  Description:
#
#   This script sets up a classic Mastermind minigame, in which the player must
#   try to guess the secret sequence of colors that the opponent has chosen.
#   Each turn, the player selects a four piece sequence using six different
#   colors, and the opponent responds by giving the player black and white
#   pegs accordingly. A black peg means that the player has a right color piece
#   in the right position, while a white peg means that the player has a right
#   color piece but in the wrong position. The game ends when the player either
#   guesses correctly or has failed to figure it out after eight turns.
#
#------------------------------------------------------------------------------
#  Instructions:
#   
#     - Place this script in the materials section, above Main.
#
#     - Copy the game board and piece graphics to your game's pictures folder.
#       If you do not already have them, they can be found at:
#       http://rmrk.net/index.php/topic,42143.0.html
#
#     - Check the script options below these instructions to tweak the game's
#       appearance to your likings or change the winning and losing sounds.
#
#     - To start the minigame, simply call it with an event by using the
#       script command and entering "call_mastermind" without the quotation
#       marks. It'll automatically initiate the game.
#
#==============================================================================

module Mastermind_Options
#============================================================================
# EDITABLE REGION:
#============================================================================

Side = true                           # Show the side decoration graphic
Black_Background = true              # Show a black background
Game_Music = false                    # Plays a different BGM during game
Game_BGM = ""              # BGM played during the game
Win_Sound = ""            # Sound played when game is won
Win_Sound_Type = ""                 # Type of sound Win_Sound is (ME/SE)
Loss_Sound = ""          # Sound played when game is lost
Loss_Sound_Type = ""                # Type of sound Loss_Sound is (ME/SE)
Difficulty = 1                      # switch used to set the difficulty
Colours = 1  # Values from 1 - 6 # variable used to set how many colours used
# value equals how many colors. 2 = 2 colors. Will exit if 0.
Lives = 2                 # variable used to set how many chances (lives)
Win = 2                   # switch turns on when player wins
Victory = "Congradulations! You're smater than the average bear."
# message shown after winning
#============================================================================
# END EDITABLE REGION
#============================================================================
end

#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Adding the mastermind command.
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Call Mastermind
  #--------------------------------------------------------------------------
  def call_mastermind
    SceneManager.call(Scene_Mastermind)
  end
end

#==============================================================================
# ** Window_MastermindRatio
#------------------------------------------------------------------------------
#  This window displays yours wins versus your losses in Mastermind.
#==============================================================================

class Window_MastermindLives < Window_Base
    #--------------------------------------------------------------------------
    # * Object Initialization
    #     x : window X coordinate
    #     y : window Y coordinate
    #--------------------------------------------------------------------------
    def initialize(x, y)
        super(x, y, 135, 50)
        refresh
    end
    #--------------------------------------------------------------------------
    # * Refresh
    #--------------------------------------------------------------------------
    def refresh
        self.contents.clear
        self.contents.font.color = system_color
        self.contents.draw_text(4, 0, 90, line_height, "Lives:")
        self.contents.font.color = normal_color
        self.contents.draw_text(4, 0, 90, line_height, $game_variables[Mastermind_Options::Lives], 2)
    end
end

#==============================================================================
# ** Window_MastermindCommand_Color
#------------------------------------------------------------------------------
#  This window displays your colors to use in the game.
#==============================================================================
class Window_MastermindCommand_Color < Window_Command
  def initialize(x, y)
    super(x, y)
  end
 
  def make_command_list
    s1 = "Red"
    s2 = "Orange"
    s3 = "Yellow"
    s4 = "Green"
    s5 = "Blue"
    s6 = "Purple"
    add_command(s1, :s1a)
    add_command(s2, :s2a)
    add_command(s3, :s3a)
    add_command(s4, :s4)
    add_command(s5, :s5)
    add_command(s6, :s6)
  end
 
  def process_handling
      
  end
 
  def visible_line_number
    return 6
  end
  
end


#==============================================================================
# ** Scene_Mastermind
#------------------------------------------------------------------------------
#  This class performs the Mastermind screen processing.
#==============================================================================

class Scene_Mastermind < Scene_MenuBase
    #--------------------------------------------------------------------------
    # * Start processing
    #--------------------------------------------------------------------------
    def start
      if $game_variables[Mastermind_Options::Colours] == 0
        error = "Colors are set to 0!"
        $game_message.add(sprintf(error, @actor))
        SceneManager.return
      end
      super
      @colours = []
      if Mastermind_Options::Game_Music == true
        @last_bgm = RPG::BGM::last
        @last_bgs = RPG::BGS::last
        RPG::BGS.stop
        temp_sound = "Audio/BGM/" + Mastermind_Options::Game_BGM
        Audio.bgm_play(temp_sound, 100, 100)
      end
      create_background if Mastermind_Options::Black_Background == false
      create_command_window_2
      @lives = Window_MastermindLives.new(30, 30)
      @board_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
      @board_sprite.bitmap = Cache.picture("mm_board")
      @board_sprite.x = 50
      @board_sprite.y = 0
      @board_sprite.z = 1
      @answer_sprite = Sprite.new
      @answer_sprite.bitmap = Cache.picture("mm_answer")
      @answer_sprite.x = 260
      @answer_sprite.y = -25
      @answer_sprite.z = 10
      @hard_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
      @hard_sprite.bitmap = Cache.picture("mm_hard")
      @hard_sprite.x = 50
      @hard_sprite.y = 0
      @hard_sprite.z = 2
      if Mastermind_Options::Side == true
        @side_sprite = Sprite.new
        @side_sprite.bitmap = Cache.picture("mm_side")
        @side_sprite.x = 420 + (146 - @side_sprite.width) / 2
        @side_sprite.y = (410 - @side_sprite.height) / 2
        @side_sprite.z = 1
      end
      @color_sprite = []
      @peg_sprite = []
      @guess = []
      @guess_used = []
      @answer = []
      @answer_used = []
      @color_index = 0
      @peg_index = 0
      @game_mode = "start"
    end
    #--------------------------------------------------------------------------
    # * Wait
    #--------------------------------------------------------------------------
    def wait(duration)
        for i in 0...duration
            Graphics.update
        end
    end
    #--------------------------------------------------------------------------
    # * Pre-termination Processing
    #--------------------------------------------------------------------------
    def pre_terminate
        super
        close_command_window_2
    end
    #--------------------------------------------------------------------------
    # * Termination Processing
    #--------------------------------------------------------------------------
    def terminate
        super
        @board_sprite.dispose
        @answer_sprite.dispose
        @hard_sprite.dispose
        @side_sprite.dispose if Mastermind_Options::Side == true
        if @color_index != 0
            for i in 0...@color_index
                @color_sprite[i].dispose
            end
            for i in 0...@peg_index
                @peg_sprite[i].dispose
            end
        end
        if Mastermind_Options::Game_Music == true
            @last_bgm.play
            @last_bgs.play
        end
    end
    #--------------------------------------------------------------------------
    # * Frame Update
    #--------------------------------------------------------------------------
    def easy_terminate
        @hard_sprite.dispose
    end
  
    def update
        super
        if @game_mode == "start"
          $game_switches[Mastermind_Options::Win] == false
          Sound.play_ok
          cover_answer
          if $game_switches[Mastermind_Options::Difficulty] != true
            easy_terminate
          end
        elsif @game_mode == "color"
          if Input.trigger?(:C)
            if @guess_index != 4
              Sound.play_ok
              @go = @command_window_2.index
              @guess[@guess_index] = @go
              @color_sprite[@color_index] = Sprite.new
              @color_sprite[@color_index].bitmap=Cache.picture("mm_color"[email hidden]_s)
              @color_sprite[@color_index].x = 278 + (@guess_index * 35)
              @color_sprite[@color_index].y = 360 - (@round_index * 40)
              @color_sprite[@color_index].z = 2
              @guess_index += 1
              @color_index += 1
              if @guess_index == 4
                  @game_mode = "peg"
                  close_command_window_2
                  @command_window_2.index = 0
                  wait(15)
                  check_colors
              end
            end
          end
          if Input.trigger?(:B)
            if @guess_index == 0
              Sound.play_cancel
              close_command_window_2
              @game_mode = "quit"
            else
              case @guess_index
              when 1
                @guess[0] = -1
              when 2
                @guess[1] = -1
              when 3
                @guess[2] = -1
              end
              @guess_index -= 1
              @color_index -= 1
              Sound.play_cancel
              @color_sprite[@color_index].dispose
            end
          end
        elsif @game_mode == "quit"
          Sound.play_cancel
          SceneManager.return
        elsif @game_mode == "lose"
          Sound.play_cancel
          wait(8)
          if $game_variables[Mastermind_Options::Lives] > 0
            open_command_window_2
            @game_mode = "color"
            $game_variables[Mastermind_Options::Lives] -= 1
            for i in 0...@color_index
              @color_sprite[i].dispose
            end
            for i in 0...@peg_index
              @peg_sprite[i].dispose
            end
            wait(10)
            cover_answer
            @hard_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
            @hard_sprite.bitmap = Cache.picture("mm_hard")
            @hard_sprite.x = 1
            @hard_sprite.y = 5
            @hard_sprite.z = 2
            if $game_switches[Mastermind_Options::Difficulty] != true
              easy_terminate
            end
          else
            Sound.play_cancel
            SceneManager.return
          end
      elsif @game_mode == "win"
        Sound.play_use_skill
        $game_message.add(sprintf(Mastermind_Options::Victory, @actor))
        $game_switches[Mastermind_Options::Win] = true
        SceneManager.return
      end
    end
    #--------------------------------------------------------------------------
    # * Game Start
    #--------------------------------------------------------------------------
    def cover_answer
      if $game_switches[Mastermind_Options::Difficulty] == true
        @round_index = 2
      else
        @round_index = 0
      end
      @color_index = 0
      @peg_index = 0
      @guess[0] = -1
      @guess[1] = -1
      @guess[2] = -1
      @guess[3] = -1
      @guess_used[0] = false
      @guess_used[1] = false
      @guess_used[2] = false
      @guess_used[3] = false
      @guess_index = 0
      @answer[0] = -1
      @answer[1] = -1
      @answer[2] = -1
      @answer[3] = -1
      @answer_used[0] = false
      @answer_used[1] = false
      @answer_used[2] = false
      @answer_used[3] = false
      @peg_hole = 0
      @j = 0
      @k = 0   
      @distance = 50 - (@answer_sprite.y)
      @iindex = 0
      RPG::ME.stop
      RPG::SE.stop
      for i in 0..3
        Sound.play_cursor
        temp_answer = rand(5)
        @color_sprite[i] = Sprite.new
        @color_sprite[i].bitmap=Cache.picture("mm_color"+temp_answer.to_s)
        @color_sprite[i].x = 277 + (i * 35)
        @color_sprite[i].y = 28
        @color_sprite[i].z = 2
        @color_index += 1
        wait(10)
      end
      while @distance > 0
        @answer_sprite.y += 1
        temp_answer = rand(5)
        @color_sprite[@iindex].bitmap=Cache.picture("mm_color"+temp_answer.to_s)
        @iindex += 1
        if @iindex == 4
          @iindex = 0
        end
        @distance = 20 - (@answer_sprite.y)
        Sound.play_cursor
        wait(2)
      end
      for i in 0..$game_variables[Mastermind_Options::Colours] - 1
        pick = rand(5)
        if [email protected]?(pick)
          @colours << pick if @colours.size != $game_variables[Mastermind_Options::Colours]
        end
        if (i == $game_variables[Mastermind_Options::Colours]) && (@colours.size != $game_variables[Mastermind_Options::Colours])
          i -= 1
        end
      end
      for i in 0..3
        count = @colours.size
        number = rand(count)
        setcolour = @colours[number]
        @answer[i] = setcolour
        @color_sprite[i].bitmap=Cache.picture("mm_color"+@answer[i].to_s)
        @color_sprite[i].z = 2
      end
      open_command_window_2
      @game_mode = "color"
    end
    #--------------------------------------------------------------------------
    # * Game End
    #--------------------------------------------------------------------------
    def uncover_answer
      begin
        @answer_sprite.y -= 1
        wait(2)
      end until @answer_sprite.y == -25
      wait(60)
    end
    #--------------------------------------------------------------------------
    # * Round End
    #--------------------------------------------------------------------------
    def check_colors
      for i in 0...4
        if @guess[i] == @answer[i]
          @guess_used[i] = true
          @answer_used[i] = true
          @peg_sprite[@peg_index] = Sprite.new
          @peg_sprite[@peg_index].bitmap = Cache.picture("mm_black")
          case @peg_hole
          when 0
            @peg_sprite[@peg_index].x = 234
            @peg_sprite[@peg_index].y = 357 - (@round_index * 40)
          when 1
            @peg_sprite[@peg_index].x = 248
            @peg_sprite[@peg_index].y = 357 - (@round_index * 40)
          when 2
            @peg_sprite[@peg_index].x = 234
            @peg_sprite[@peg_index].y = 371 - (@round_index * 40)
          when 3
            @peg_sprite[@peg_index].x = 248
            @peg_sprite[@peg_index].y = 371 - (@round_index * 40)
          end
          @peg_sprite[@peg_index].z = 2
          @peg_index += 1
          @peg_hole += 1
          if @peg_hole == 4
            @game_mode = "win"
          end
        end
      end
      while @j <= 3
        if @j != @k
          if @guess[@j] == @answer[@k]
            if @guess_used[@j] == false
              if @answer_used[@k] == false
                @guess_used[@j] = true
                @answer_used[@k] = true
                @peg_sprite[@peg_index] = Sprite.new
                @peg_sprite[@peg_index].bitmap = Cache.picture("mm_white")
                case @peg_hole
                when 0
                  @peg_sprite[@peg_index].x = 234
                  @peg_sprite[@peg_index].y = 357 - (@round_index * 40)
                when 1
                  @peg_sprite[@peg_index].x = 248
                  @peg_sprite[@peg_index].y = 357 - (@round_index * 40)
                when 2
                  @peg_sprite[@peg_index].x = 234
                  @peg_sprite[@peg_index].y = 371 - (@round_index * 40)
                when 3
                  @peg_sprite[@peg_index].x = 248
                  @peg_sprite[@peg_index].y = 371 - (@round_index * 40)
                end
                @peg_sprite[@peg_index].z = 2
                @peg_index += 1
                @peg_hole += 1
              end
            end
          end
        end
        @k += 1
        if @k == 4
          @j += 1
          @k = 0
        end
      end
      @guess[0] = -1
      @guess[1] = -1
      @guess[2] = -1
      @guess[3] = -1
      @guess_used[0] = false
      @guess_used[1] = false
      @guess_used[2] = false
      @guess_used[3] = false
      @guess_index = 0
      @answer_used[0] = false
      @answer_used[1] = false
      @answer_used[2] = false
      @answer_used[3] = false
      @peg_hole = 0
      @j = 0
      @k = 0
      wait(15)
      if @round_index == 7 and @game_mode != "win"
        @game_mode = "lose"
        if Mastermind_Options::Loss_Sound_Type == "SE"
          temp_sound = "Audio/SE/" + Mastermind_Options::Loss_Sound
          Audio.se_play(temp_sound, 100, 100)
        elsif Mastermind_Options::Loss_Sound_Type == "ME"
          temp_sound = "Audio/ME/" + Mastermind_Options::Loss_Sound       
          Audio.me_play(temp_sound, 100, 100)
        end
        uncover_answer
        if $game_variables[Mastermind_Options::Lives] > 0
          update
          @lives.refresh
        else
          Sound.play_cancel
          SceneManager.return
        end
      elsif @game_mode == "win"
        if Mastermind_Options::Win_Sound_Type == "SE"
          temp_sound = "Audio/SE/" + Mastermind_Options::Win_Sound
          Audio.se_play(temp_sound, 100, 100)
        elsif Mastermind_Options::Win_Sound_Type == "ME"
          temp_sound = "Audio/ME/" + Mastermind_Options::Win_Sound       
          Audio.me_play(temp_sound, 100, 100)
        end
          uncover_answer
      else
        @round_index += 1
        open_command_window_2
        @game_mode = "color"
      end
    end
    #--------------------------------------------------------------------------
    # * Create Command Window Two
    #--------------------------------------------------------------------------
    def create_command_window_2
      @command_window_2 = Window_MastermindCommand_Color.new(0, 0)
      @command_window_2.x = (200 - @command_window_2.width) / 2
      @command_window_2.height = @command_window_2.fitting_height(6)
      @command_window_2.y = 210
      @command_window_2.openness = 0
      @command_window_2.active = false
    end
    #--------------------------------------------------------------------------
    # * Open Command Window Two
    #--------------------------------------------------------------------------
    def open_command_window_2
      @command_window_2.open
      @command_window_2.active = true
      @command_window_2.refresh
    end
    #--------------------------------------------------------------------------
    # * Close Command Window Two
    #--------------------------------------------------------------------------
    def close_command_window_2
      @command_window_2.close
      @command_window_2.active = false
      @command_window_2.refresh
    end
end
You still get the same combination of colors after you've lost a life. That doesn't make much sense because you already know the combination by then. How's it possible that every time you lose a life, you get a different combination?
You still get the same combination of colors
Hmmm.
Ok, checked it again and hopefully this is good.
Spoiler: script
Ruby:
#==============================================================================
#  Mastermind (VX)
#  Version: 1.0
#  Author: Zylos (rmrk.net)
#  Date: March 21, 2011
#------------------------------------------------------------------------------
#  Description:
#
#   This script sets up a classic Mastermind minigame, in which the player must
#   try to guess the secret sequence of colors that the opponent has chosen.
#   Each turn, the player selects a four piece sequence using six different
#   colors, and the opponent responds by giving the player black and white
#   pegs accordingly. A black peg means that the player has a right color piece
#   in the right position, while a white peg means that the player has a right
#   color piece but in the wrong position. The game ends when the player either
#   guesses correctly or has failed to figure it out after eight turns.
#
#------------------------------------------------------------------------------
#  Instructions:
#   
#     - Place this script in the materials section, above Main.
#
#     - Copy the game board and piece graphics to your game's pictures folder.
#       If you do not already have them, they can be found at:
#       http://rmrk.net/index.php/topic,42143.0.html
#
#     - Check the script options below these instructions to tweak the game's
#       appearance to your likings or change the winning and losing sounds.
#
#     - To start the minigame, simply call it with an event by using the
#       script command and entering "call_mastermind" without the quotation
#       marks. It'll automatically initiate the game.
#
#==============================================================================

module Mastermind_Options
#============================================================================
# EDITABLE REGION:
#============================================================================

Side = true                           # Show the side decoration graphic
Black_Background = true              # Show a black background
Game_Music = false                    # Plays a different BGM during game
Game_BGM = ""              # BGM played during the game
Win_Sound = ""            # Sound played when game is won
Win_Sound_Type = ""                 # Type of sound Win_Sound is (ME/SE)
Loss_Sound = ""          # Sound played when game is lost
Loss_Sound_Type = ""                # Type of sound Loss_Sound is (ME/SE)
Difficulty = 1                      # switch used to set the difficulty
Colours = 1  # Values from 1 - 6 # variable used to set how many colours used
# value equals how many colors. 2 = 2 colors. Will exit if 0.
Lives = 2                 # variable used to set how many chances (lives)
Win = 2                   # switch turns on when player wins
Victory = "Congradulations! You're smater than the average bear."
# message shown after winning
#============================================================================
# END EDITABLE REGION
#============================================================================
end

#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Adding the mastermind command.
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Call Mastermind
  #--------------------------------------------------------------------------
  def call_mastermind
    SceneManager.call(Scene_Mastermind)
  end
end

#==============================================================================
# ** Window_MastermindRatio
#------------------------------------------------------------------------------
#  This window displays yours wins versus your losses in Mastermind.
#==============================================================================

class Window_MastermindLives < Window_Base
    #--------------------------------------------------------------------------
    # * Object Initialization
    #     x : window X coordinate
    #     y : window Y coordinate
    #--------------------------------------------------------------------------
    def initialize(x, y)
        super(x, y, 135, 50)
        refresh
    end
    #--------------------------------------------------------------------------
    # * Refresh
    #--------------------------------------------------------------------------
    def refresh
        self.contents.clear
        self.contents.font.color = system_color
        self.contents.draw_text(4, 0, 90, line_height, "Lives:")
        self.contents.font.color = normal_color
        self.contents.draw_text(4, 0, 90, line_height, $game_variables[Mastermind_Options::Lives], 2)
    end
end

#==============================================================================
# ** Window_MastermindCommand_Color
#------------------------------------------------------------------------------
#  This window displays your colors to use in the game.
#==============================================================================
class Window_MastermindCommand_Color < Window_Command
  def initialize(x, y)
    super(x, y)
  end
 
  def make_command_list
    s1 = "Red"
    s2 = "Orange"
    s3 = "Yellow"
    s4 = "Green"
    s5 = "Blue"
    s6 = "Purple"
    add_command(s1, :s1a)
    add_command(s2, :s2a)
    add_command(s3, :s3a)
    add_command(s4, :s4)
    add_command(s5, :s5)
    add_command(s6, :s6)
  end
 
  def process_handling
      
  end
 
  def visible_line_number
    return 6
  end
  
end


#==============================================================================
# ** Scene_Mastermind
#------------------------------------------------------------------------------
#  This class performs the Mastermind screen processing.
#==============================================================================

class Scene_Mastermind < Scene_MenuBase
    #--------------------------------------------------------------------------
    # * Start processing
    #--------------------------------------------------------------------------
    def start
      if $game_variables[Mastermind_Options::Colours] == 0
        error = "Colors are set to 0!"
        $game_message.add(sprintf(error, @actor))
        SceneManager.return
      end
      super
      @colours = []
      if Mastermind_Options::Game_Music == true
        @last_bgm = RPG::BGM::last
        @last_bgs = RPG::BGS::last
        RPG::BGS.stop
        temp_sound = "Audio/BGM/" + Mastermind_Options::Game_BGM
        Audio.bgm_play(temp_sound, 100, 100)
      end
      create_background if Mastermind_Options::Black_Background == false
      create_command_window_2
      @lives = Window_MastermindLives.new(30, 30)
      @board_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
      @board_sprite.bitmap = Cache.picture("mm_board")
      @board_sprite.x = 50
      @board_sprite.y = 0
      @board_sprite.z = 1
      @answer_sprite = Sprite.new
      @answer_sprite.bitmap = Cache.picture("mm_answer")
      @answer_sprite.x = 260
      @answer_sprite.y = -25
      @answer_sprite.z = 10
      @hard_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
      @hard_sprite.bitmap = Cache.picture("mm_hard")
      @hard_sprite.x = 50
      @hard_sprite.y = 0
      @hard_sprite.z = 2
      if Mastermind_Options::Side == true
        @side_sprite = Sprite.new
        @side_sprite.bitmap = Cache.picture("mm_side")
        @side_sprite.x = 420 + (146 - @side_sprite.width) / 2
        @side_sprite.y = (410 - @side_sprite.height) / 2
        @side_sprite.z = 1
      end
      @color_sprite = []
      @peg_sprite = []
      @guess = []
      @guess_used = []
      @answer = []
      @answer_used = []
      @color_index = 0
      @peg_index = 0
      @game_mode = "start"
    end
    #--------------------------------------------------------------------------
    # * Wait
    #--------------------------------------------------------------------------
    def wait(duration)
        for i in 0...duration
            Graphics.update
        end
    end
    #--------------------------------------------------------------------------
    # * Pre-termination Processing
    #--------------------------------------------------------------------------
    def pre_terminate
        super
        close_command_window_2
    end
    #--------------------------------------------------------------------------
    # * Termination Processing
    #--------------------------------------------------------------------------
    def terminate
        super
        @board_sprite.dispose
        @answer_sprite.dispose
        @hard_sprite.dispose
        @side_sprite.dispose if Mastermind_Options::Side == true
        if @color_index != 0
            for i in 0...@color_index
                @color_sprite[i].dispose
            end
            for i in 0...@peg_index
                @peg_sprite[i].dispose
            end
        end
        if Mastermind_Options::Game_Music == true
            @last_bgm.play
            @last_bgs.play
        end
    end
    #--------------------------------------------------------------------------
    # * Frame Update
    #--------------------------------------------------------------------------
    def easy_terminate
        @hard_sprite.dispose
    end
  
    def update
        super
        if @game_mode == "start"
          $game_switches[Mastermind_Options::Win] == false
          Sound.play_ok
          cover_answer
          if $game_switches[Mastermind_Options::Difficulty] != true
            easy_terminate
          end
        elsif @game_mode == "color"
          if Input.trigger?(:C)
            if @guess_index != 4
              Sound.play_ok
              @go = @command_window_2.index
              @guess[@guess_index] = @go
              @color_sprite[@color_index] = Sprite.new
              @color_sprite[@color_index].bitmap=Cache.picture("mm_color"[email hidden]_s)
              @color_sprite[@color_index].x = 278 + (@guess_index * 35)
              @color_sprite[@color_index].y = 360 - (@round_index * 40)
              @color_sprite[@color_index].z = 2
              @guess_index += 1
              @color_index += 1
              if @guess_index == 4
                  @game_mode = "peg"
                  close_command_window_2
                  @command_window_2.index = 0
                  wait(15)
                  check_colors
              end
            end
          end
          if Input.trigger?(:B)
            if @guess_index == 0
              Sound.play_cancel
              close_command_window_2
              @game_mode = "quit"
            else
              case @guess_index
              when 1
                @guess[0] = -1
              when 2
                @guess[1] = -1
              when 3
                @guess[2] = -1
              end
              @guess_index -= 1
              @color_index -= 1
              Sound.play_cancel
              @color_sprite[@color_index].dispose
            end
          end
        elsif @game_mode == "quit"
          Sound.play_cancel
          SceneManager.return
        elsif @game_mode == "lose"
          Sound.play_cancel
          wait(8)
          if $game_variables[Mastermind_Options::Lives] > 0
            open_command_window_2
            @game_mode = "color"
            $game_variables[Mastermind_Options::Lives] -= 1
            for i in 0...@color_index
              @color_sprite[i].dispose
            end
            for i in 0...@peg_index
              @peg_sprite[i].dispose
            end
            @colours = []
            wait(10)
            cover_answer
            @hard_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
            @hard_sprite.bitmap = Cache.picture("mm_hard")
            @hard_sprite.x = 1
            @hard_sprite.y = 5
            @hard_sprite.z = 2
            if $game_switches[Mastermind_Options::Difficulty] != true
              easy_terminate
            end
          else
            Sound.play_cancel
            SceneManager.return
          end
      elsif @game_mode == "win"
        Sound.play_use_skill
        $game_message.add(sprintf(Mastermind_Options::Victory, @actor))
        $game_switches[Mastermind_Options::Win] = true
        SceneManager.return
      end
    end
    #--------------------------------------------------------------------------
    # * Game Start
    #--------------------------------------------------------------------------
    def cover_answer
      if $game_switches[Mastermind_Options::Difficulty] == true
        @round_index = 2
      else
        @round_index = 0
      end
      @color_index = 0
      @peg_index = 0
      @guess[0] = -1
      @guess[1] = -1
      @guess[2] = -1
      @guess[3] = -1
      @guess_used[0] = false
      @guess_used[1] = false
      @guess_used[2] = false
      @guess_used[3] = false
      @guess_index = 0
      @answer[0] = -1
      @answer[1] = -1
      @answer[2] = -1
      @answer[3] = -1
      @answer_used[0] = false
      @answer_used[1] = false
      @answer_used[2] = false
      @answer_used[3] = false
      @peg_hole = 0
      @j = 0
      @k = 0   
      @distance = 50 - (@answer_sprite.y)
      @iindex = 0
      RPG::ME.stop
      RPG::SE.stop
      for i in 0..3
        Sound.play_cursor
        temp_answer = rand(5)
        @color_sprite[i] = Sprite.new
        @color_sprite[i].bitmap=Cache.picture("mm_color"+temp_answer.to_s)
        @color_sprite[i].x = 277 + (i * 35)
        @color_sprite[i].y = 28
        @color_sprite[i].z = 2
        @color_index += 1
        wait(10)
      end
      while @distance > 0
        @answer_sprite.y += 1
        temp_answer = rand(6)
        @color_sprite[@iindex].bitmap=Cache.picture("mm_color"+temp_answer.to_s)
        @iindex += 1
        if @iindex == 4
          @iindex = 0
        end
        @distance = 20 - (@answer_sprite.y)
        Sound.play_cursor
        wait(2)
      end
      until @colours.size == $game_variables[Mastermind_Options::Colours]
        pick = rand(6)
        if [email protected]?(pick)
          @colours << pick
        end
      end
      for i in 0..3
        count = @colours.size
        number = rand(count)
        setcolour = @colours[number]
        @answer[i] = setcolour
        @color_sprite[i].bitmap=Cache.picture("mm_color"+@answer[i].to_s)
        @color_sprite[i].z = 2
      end
      open_command_window_2
      @game_mode = "color"
    end
    #--------------------------------------------------------------------------
    # * Game End
    #--------------------------------------------------------------------------
    def uncover_answer
      begin
        @answer_sprite.y -= 1
        wait(2)
      end until @answer_sprite.y == -25
      wait(60)
    end
    #--------------------------------------------------------------------------
    # * Round End
    #--------------------------------------------------------------------------
    def check_colors
      for i in 0...4
        if @guess[i] == @answer[i]
          @guess_used[i] = true
          @answer_used[i] = true
          @peg_sprite[@peg_index] = Sprite.new
          @peg_sprite[@peg_index].bitmap = Cache.picture("mm_black")
          case @peg_hole
          when 0
            @peg_sprite[@peg_index].x = 234
            @peg_sprite[@peg_index].y = 357 - (@round_index * 40)
          when 1
            @peg_sprite[@peg_index].x = 248
            @peg_sprite[@peg_index].y = 357 - (@round_index * 40)
          when 2
            @peg_sprite[@peg_index].x = 234
            @peg_sprite[@peg_index].y = 371 - (@round_index * 40)
          when 3
            @peg_sprite[@peg_index].x = 248
            @peg_sprite[@peg_index].y = 371 - (@round_index * 40)
          end
          @peg_sprite[@peg_index].z = 2
          @peg_index += 1
          @peg_hole += 1
          if @peg_hole == 4
            @game_mode = "win"
          end
        end
      end
      while @j <= 3
        if @j != @k
          if @guess[@j] == @answer[@k]
            if @guess_used[@j] == false
              if @answer_used[@k] == false
                @guess_used[@j] = true
                @answer_used[@k] = true
                @peg_sprite[@peg_index] = Sprite.new
                @peg_sprite[@peg_index].bitmap = Cache.picture("mm_white")
                case @peg_hole
                when 0
                  @peg_sprite[@peg_index].x = 234
                  @peg_sprite[@peg_index].y = 357 - (@round_index * 40)
                when 1
                  @peg_sprite[@peg_index].x = 248
                  @peg_sprite[@peg_index].y = 357 - (@round_index * 40)
                when 2
                  @peg_sprite[@peg_index].x = 234
                  @peg_sprite[@peg_index].y = 371 - (@round_index * 40)
                when 3
                  @peg_sprite[@peg_index].x = 248
                  @peg_sprite[@peg_index].y = 371 - (@round_index * 40)
                end
                @peg_sprite[@peg_index].z = 2
                @peg_index += 1
                @peg_hole += 1
              end
            end
          end
        end
        @k += 1
        if @k == 4
          @j += 1
          @k = 0
        end
      end
      @guess[0] = -1
      @guess[1] = -1
      @guess[2] = -1
      @guess[3] = -1
      @guess_used[0] = false
      @guess_used[1] = false
      @guess_used[2] = false
      @guess_used[3] = false
      @guess_index = 0
      @answer_used[0] = false
      @answer_used[1] = false
      @answer_used[2] = false
      @answer_used[3] = false
      @peg_hole = 0
      @j = 0
      @k = 0
      wait(15)
      if @round_index == 7 and @game_mode != "win"
        @game_mode = "lose"
        if Mastermind_Options::Loss_Sound_Type == "SE"
          temp_sound = "Audio/SE/" + Mastermind_Options::Loss_Sound
          Audio.se_play(temp_sound, 100, 100)
        elsif Mastermind_Options::Loss_Sound_Type == "ME"
          temp_sound = "Audio/ME/" + Mastermind_Options::Loss_Sound       
          Audio.me_play(temp_sound, 100, 100)
        end
        uncover_answer
        if $game_variables[Mastermind_Options::Lives] > 0
          update
          @lives.refresh
        else
          Sound.play_cancel
          SceneManager.return
        end
      elsif @game_mode == "win"
        if Mastermind_Options::Win_Sound_Type == "SE"
          temp_sound = "Audio/SE/" + Mastermind_Options::Win_Sound
          Audio.se_play(temp_sound, 100, 100)
        elsif Mastermind_Options::Win_Sound_Type == "ME"
          temp_sound = "Audio/ME/" + Mastermind_Options::Win_Sound       
          Audio.me_play(temp_sound, 100, 100)
        end
          uncover_answer
      else
        @round_index += 1
        open_command_window_2
        @game_mode = "color"
      end
    end
    #--------------------------------------------------------------------------
    # * Create Command Window Two
    #--------------------------------------------------------------------------
    def create_command_window_2
      @command_window_2 = Window_MastermindCommand_Color.new(0, 0)
      @command_window_2.x = (200 - @command_window_2.width) / 2
      @command_window_2.height = @command_window_2.fitting_height(6)
      @command_window_2.y = 210
      @command_window_2.openness = 0
      @command_window_2.active = false
    end
    #--------------------------------------------------------------------------
    # * Open Command Window Two
    #--------------------------------------------------------------------------
    def open_command_window_2
      @command_window_2.open
      @command_window_2.active = true
      @command_window_2.refresh
    end
    #--------------------------------------------------------------------------
    # * Close Command Window Two
    #--------------------------------------------------------------------------
    def close_command_window_2
      @command_window_2.close
      @command_window_2.active = false
      @command_window_2.refresh
    end
end
Thanks a lot for your effort, Ronny. 🙂
One more question: Whenever I try to add icons to the choice list (draw_icon(icon_index, x, y, enabled = true)), I get an disposed window error, dunno why. If I try to add icons directly like \\I[icon_index] Red, it simply doesn't work.

How can I make icons for the choices?
add icons
Keep the ideas coming man! I love your brain. You come up with the ideas and I'll do my best to change scripts to make it work.
I'm totally using all of this. I had the script in my game, but not a good way to utilize it, but I can see a way forward. Thanks

Spoiler: Final attempt #1
Ruby:
#==============================================================================
#  Mastermind (VXA)
#  Version: 2.0
#  Author: Zylos
#  Date: March 21, 2011
#  Mod by Roninator2
#  Updated 4 Sep 2020
#------------------------------------------------------------------------------
#  Description:
#
#   This script sets up a classic Mastermind minigame, in which the player must
#   try to guess the secret sequence of colors that the opponent has chosen.
#   Each turn, the player selects a four piece sequence using six different
#   colors, and the opponent responds by giving the player black and white
#   pegs accordingly. A black peg means that the player has a right color piece
#   in the right position, while a white peg means that the player has a right
#   color piece but in the wrong position. The game ends when the player either
#   guesses correctly or has failed to figure it out after eight turns.
#
#------------------------------------------------------------------------------
#  Instructions:
#  
#     - Place this script in the materials section, above Main.
#
#     - Copy the game board and piece graphics to your game's pictures folder.
#       If you do not already have them, they can be found at:
#       http://rmrk.net/index.php/topic,42143.0.html
#
#     - Check the script options below these instructions to tweak the game's
#       appearance to your likings or change the winning and losing sounds.
#
#     - To start the minigame, simply call it with an event by using the
#       script command and entering "call_mastermind" without the quotation
#       marks. It'll automatically initiate the game.
#
#==============================================================================

module Mastermind_Options
#============================================================================
# EDITABLE REGION:
#============================================================================

Side = true                           # Show the side decoration graphic
Black_Background = true              # Show a black background
Game_Music = false                    # Plays a different BGM during game
Game_BGM = ""              # BGM played during the game
Win_Sound = ""            # Sound played when game is won
Win_Sound_Type = ""                 # Type of sound Win_Sound is (ME/SE)
Loss_Sound = ""          # Sound played when game is lost
Loss_Sound_Type = ""                # Type of sound Loss_Sound is (ME/SE)
Difficulty = 1                      # switch used to set the difficulty
Colours = 1  # Values from 1 - 6 # variable used to set how many colours used
# value equals how many colors. 2 = 2 colors. Will exit if 0.
Lives = 2                 # variable used to set how many chances (lives)
Win = 2                   # switch turns on when player wins
Victory = "Congradulations! You're smater than the average bear."
# message shown after winning
# icons used for commands
ICONS = [106,107,108,109,110,111]
Use_Icons = true      # whether or not to use icons
#============================================================================
# END EDITABLE REGION
#============================================================================
end

#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Adding the mastermind command.
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Call Mastermind
  #--------------------------------------------------------------------------
  def call_mastermind
    SceneManager.call(Scene_Mastermind)
  end
end

#==============================================================================
# ** Window_MastermindRatio
#------------------------------------------------------------------------------
#  This window displays yours wins versus your losses in Mastermind.
#==============================================================================

class Window_MastermindLives < Window_Base
    #--------------------------------------------------------------------------
    # * Object Initialization
    #     x : window X coordinate
    #     y : window Y coordinate
    #--------------------------------------------------------------------------
    def initialize(x, y)
        super(x, y, 135, 50)
        refresh
    end
    #--------------------------------------------------------------------------
    # * Refresh
    #--------------------------------------------------------------------------
    def refresh
        self.contents.clear
        self.contents.font.color = system_color
        self.contents.draw_text(4, 0, 90, line_height, "Lives:")
        self.contents.font.color = normal_color
        self.contents.draw_text(4, 0, 90, line_height, $game_variables[Mastermind_Options::Lives], 2)
    end
end
#==============================================================================
# ** Window_MastermindCommand_Color
#------------------------------------------------------------------------------
#  This window displays your colors to use in the game.
#==============================================================================
class Window_MastermindCommand_Color < Window_Command
  def initialize(x, y, ci)
    @ci = []
    @ci = Mastermind_Options::ICONS
    super(x, y)
  end

  alias r2_MMicon_draw_9274hv   draw_item
  def draw_item(index)
    if Mastermind_Options::Use_Icons == true
      rect = item_rect(index)
      draw_icon(@ci[index], rect.x + 3, rect.y, true)
    else
      r2_MMicon_draw_9274hv(index)
    end
  end

  def make_command_list
    if Mastermind_Options::Use_Icons == true
      @ci.each {|i| add_command(i, i) }
    else
      s1 = "Red"
      s2 = "Orange"
      s3 = "Yellow"
      s4 = "Green"
      s5 = "Blue"
      s6 = "Purple"
      add_command(s1, :s1a)
      add_command(s2, :s2a)
      add_command(s3, :s3a)
      add_command(s4, :s4)
      add_command(s5, :s5)
      add_command(s6, :s6)
    end
  end

  def window_width
    if Mastermind_Options::Use_Icons == true
      return 60
    else
      return 100
    end
  end

  def process_handling
  end

  def visible_line_number
    return 6
  end
 
end


#==============================================================================
# ** Scene_Mastermind
#------------------------------------------------------------------------------
#  This class performs the Mastermind screen processing.
#==============================================================================

class Scene_Mastermind < Scene_MenuBase
    #--------------------------------------------------------------------------
    # * Start processing
    #--------------------------------------------------------------------------
    def start
      if $game_variables[Mastermind_Options::Colours] == 0
        error = "Colors are set to 0!"
        $game_message.add(sprintf(error, @actor))
        SceneManager.return
      end
      super
      @colours = []
      if Mastermind_Options::Game_Music == true
        @last_bgm = RPG::BGM::last
        @last_bgs = RPG::BGS::last
        RPG::BGS.stop
        temp_sound = "Audio/BGM/" + Mastermind_Options::Game_BGM
        Audio.bgm_play(temp_sound, 100, 100)
      end
      create_background if Mastermind_Options::Black_Background == false
      create_command_window_2
      @lives = Window_MastermindLives.new(30, 30)
      @board_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
      @board_sprite.bitmap = Cache.picture("mm_board")
      @board_sprite.x = 50
      @board_sprite.y = 0
      @board_sprite.z = 1
      @answer_sprite = Sprite.new
      @answer_sprite.bitmap = Cache.picture("mm_answer")
      @answer_sprite.x = 260
      @answer_sprite.y = -25
      @answer_sprite.z = 10
      @hard_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
      @hard_sprite.bitmap = Cache.picture("mm_hard")
      @hard_sprite.x = 50
      @hard_sprite.y = 0
      @hard_sprite.z = 2
      if Mastermind_Options::Side == true
        @side_sprite = Sprite.new
        @side_sprite.bitmap = Cache.picture("mm_side")
        @side_sprite.x = 420 + (146 - @side_sprite.width) / 2
        @side_sprite.y = (410 - @side_sprite.height) / 2
        @side_sprite.z = 1
      end
      @color_sprite = []
      @peg_sprite = []
      @guess = []
      @guess_used = []
      @answer = []
      @answer_used = []
      @color_index = 0
      @peg_index = 0
      @game_mode = "start"
    end
    #--------------------------------------------------------------------------
    # * Wait
    #--------------------------------------------------------------------------
    def wait(duration)
        for i in 0...duration
            Graphics.update
        end
    end
    #--------------------------------------------------------------------------
    # * Pre-termination Processing
    #--------------------------------------------------------------------------
    def pre_terminate
        super
        close_command_window_2
    end
    #--------------------------------------------------------------------------
    # * Termination Processing
    #--------------------------------------------------------------------------
    def terminate
        super
        @board_sprite.dispose
        @answer_sprite.dispose
        @hard_sprite.dispose
        @side_sprite.dispose if Mastermind_Options::Side == true
        if @color_index != 0
            for i in 0...@color_index
                @color_sprite[i].dispose
            end
            for i in 0...@peg_index
                @peg_sprite[i].dispose
            end
        end
        if Mastermind_Options::Game_Music == true
            @last_bgm.play
            @last_bgs.play
        end
    end
    #--------------------------------------------------------------------------
    # * Frame Update
    #--------------------------------------------------------------------------
    def easy_terminate
        @hard_sprite.dispose
    end
 
    def update
        super
        if @game_mode == "start"
          $game_switches[Mastermind_Options::Win] == false
          Sound.play_ok
          cover_answer
          if $game_switches[Mastermind_Options::Difficulty] != true
            easy_terminate
          end
        elsif @game_mode == "color"
          if Input.trigger?(:C)
            if @guess_index != 4
              Sound.play_ok
              @go = @command_window_2.index
              @guess[@guess_index] = @go
              @color_sprite[@color_index] = Sprite.new
              @color_sprite[@color_index].bitmap=Cache.picture("mm_color"[email hidden]_s)
              @color_sprite[@color_index].x = 278 + (@guess_index * 35)
              @color_sprite[@color_index].y = 360 - (@round_index * 40)
              @color_sprite[@color_index].z = 2
              @guess_index += 1
              @color_index += 1
              if @guess_index == 4
                  @game_mode = "peg"
                  close_command_window_2
                  @command_window_2.index = 0
                  wait(15)
                  check_colors
              end
            end
          end
          if Input.trigger?(:B)
            if @guess_index == 0
              Sound.play_cancel
              close_command_window_2
              @game_mode = "quit"
            else
              case @guess_index
              when 1
                @guess[0] = -1
              when 2
                @guess[1] = -1
              when 3
                @guess[2] = -1
              end
              @guess_index -= 1
              @color_index -= 1
              Sound.play_cancel
              @color_sprite[@color_index].dispose
            end
          end
        elsif @game_mode == "quit"
          Sound.play_cancel
          SceneManager.return
        elsif @game_mode == "lose"
          Sound.play_cancel
          wait(8)
          if $game_variables[Mastermind_Options::Lives] > 0
            open_command_window_2
            @game_mode = "color"
            $game_variables[Mastermind_Options::Lives] -= 1
            for i in 0...@color_index
              @color_sprite[i].dispose
            end
            for i in 0...@peg_index
              @peg_sprite[i].dispose
            end
            @colours = []
            wait(10)
            cover_answer
            @hard_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
            @hard_sprite.bitmap = Cache.picture("mm_hard")
            @hard_sprite.x = 1
            @hard_sprite.y = 5
            @hard_sprite.z = 2
            if $game_switches[Mastermind_Options::Difficulty] != true
              easy_terminate
            end
          else
            Sound.play_cancel
            SceneManager.return
          end
      elsif @game_mode == "win"
        Sound.play_use_skill
        $game_message.add(sprintf(Mastermind_Options::Victory, @actor))
        $game_switches[Mastermind_Options::Win] = true
        SceneManager.return
      end
    end
    #--------------------------------------------------------------------------
    # * Game Start
    #--------------------------------------------------------------------------
    def cover_answer
      if $game_switches[Mastermind_Options::Difficulty] == true
        @round_index = 2
      else
        @round_index = 0
      end
      @color_index = 0
      @peg_index = 0
      @guess[0] = -1
      @guess[1] = -1
      @guess[2] = -1
      @guess[3] = -1
      @guess_used[0] = false
      @guess_used[1] = false
      @guess_used[2] = false
      @guess_used[3] = false
      @guess_index = 0
      @answer[0] = -1
      @answer[1] = -1
      @answer[2] = -1
      @answer[3] = -1
      @answer_used[0] = false
      @answer_used[1] = false
      @answer_used[2] = false
      @answer_used[3] = false
      @peg_hole = 0
      @j = 0
      @k = 0  
      @distance = 50 - (@answer_sprite.y)
      @iindex = 0
      RPG::ME.stop
      RPG::SE.stop
      for i in 0..3
        Sound.play_cursor
        temp_answer = rand(5)
        @color_sprite[i] = Sprite.new
        @color_sprite[i].bitmap=Cache.picture("mm_color"+temp_answer.to_s)
        @color_sprite[i].x = 277 + (i * 35)
        @color_sprite[i].y = 28
        @color_sprite[i].z = 2
        @color_index += 1
        wait(10)
      end
      while @distance > 0
        @answer_sprite.y += 1
        temp_answer = rand(6)
        @color_sprite[@iindex].bitmap=Cache.picture("mm_color"+temp_answer.to_s)
        @iindex += 1
        if @iindex == 4
          @iindex = 0
        end
        @distance = 20 - (@answer_sprite.y)
        Sound.play_cursor
        wait(2)
      end
      until @colours.size == $game_variables[Mastermind_Options::Colours]
        pick = rand(6)
        if [email protected]?(pick)
          @colours << pick
        end
      end
      for i in 0..3
        count = @colours.size
        number = rand(count)
        setcolour = @colours[number]
        @answer[i] = setcolour
        @color_sprite[i].bitmap=Cache.picture("mm_color"+@answer[i].to_s)
        @color_sprite[i].z = 2
      end
      open_command_window_2
      @game_mode = "color"
    end
    #--------------------------------------------------------------------------
    # * Game End
    #--------------------------------------------------------------------------
    def uncover_answer
      begin
        @answer_sprite.y -= 1
        wait(2)
      end until @answer_sprite.y == -25
      wait(60)
    end
    #--------------------------------------------------------------------------
    # * Round End
    #--------------------------------------------------------------------------
    def check_colors
      for i in 0...4
        if @guess[i] == @answer[i]
          @guess_used[i] = true
          @answer_used[i] = true
          @peg_sprite[@peg_index] = Sprite.new
          @peg_sprite[@peg_index].bitmap = Cache.picture("mm_black")
          case @peg_hole
          when 0
            @peg_sprite[@peg_index].x = 234
            @peg_sprite[@peg_index].y = 357 - (@round_index * 40)
          when 1
            @peg_sprite[@peg_index].x = 248
            @peg_sprite[@peg_index].y = 357 - (@round_index * 40)
          when 2
            @peg_sprite[@peg_index].x = 234
            @peg_sprite[@peg_index].y = 371 - (@round_index * 40)
          when 3
            @peg_sprite[@peg_index].x = 248
            @peg_sprite[@peg_index].y = 371 - (@round_index * 40)
          end
          @peg_sprite[@peg_index].z = 2
          @peg_index += 1
          @peg_hole += 1
          if @peg_hole == 4
            @game_mode = "win"
          end
        end
      end
      while @j <= 3
        if @j != @k
          if @guess[@j] == @answer[@k]
            if @guess_used[@j] == false
              if @answer_used[@k] == false
                @guess_used[@j] = true
                @answer_used[@k] = true
                @peg_sprite[@peg_index] = Sprite.new
                @peg_sprite[@peg_index].bitmap = Cache.picture("mm_white")
                case @peg_hole
                when 0
                  @peg_sprite[@peg_index].x = 234
                  @peg_sprite[@peg_index].y = 357 - (@round_index * 40)
                when 1
                  @peg_sprite[@peg_index].x = 248
                  @peg_sprite[@peg_index].y = 357 - (@round_index * 40)
                when 2
                  @peg_sprite[@peg_index].x = 234
                  @peg_sprite[@peg_index].y = 371 - (@round_index * 40)
                when 3
                  @peg_sprite[@peg_index].x = 248
                  @peg_sprite[@peg_index].y = 371 - (@round_index * 40)
                end
                @peg_sprite[@peg_index].z = 2
                @peg_index += 1
                @peg_hole += 1
              end
            end
          end
        end
        @k += 1
        if @k == 4
          @j += 1
          @k = 0
        end
      end
      @guess[0] = -1
      @guess[1] = -1
      @guess[2] = -1
      @guess[3] = -1
      @guess_used[0] = false
      @guess_used[1] = false
      @guess_used[2] = false
      @guess_used[3] = false
      @guess_index = 0
      @answer_used[0] = false
      @answer_used[1] = false
      @answer_used[2] = false
      @answer_used[3] = false
      @peg_hole = 0
      @j = 0
      @k = 0
      wait(15)
      if @round_index == 7 and @game_mode != "win"
        @game_mode = "lose"
        if Mastermind_Options::Loss_Sound_Type == "SE"
          temp_sound = "Audio/SE/" + Mastermind_Options::Loss_Sound
          Audio.se_play(temp_sound, 100, 100)
        elsif Mastermind_Options::Loss_Sound_Type == "ME"
          temp_sound = "Audio/ME/" + Mastermind_Options::Loss_Sound      
          Audio.me_play(temp_sound, 100, 100)
        end
        uncover_answer
        if $game_variables[Mastermind_Options::Lives] > 0
          update
          @lives.refresh
        else
          Sound.play_cancel
          SceneManager.return
        end
      elsif @game_mode == "win"
        if Mastermind_Options::Win_Sound_Type == "SE"
          temp_sound = "Audio/SE/" + Mastermind_Options::Win_Sound
          Audio.se_play(temp_sound, 100, 100)
        elsif Mastermind_Options::Win_Sound_Type == "ME"
          temp_sound = "Audio/ME/" + Mastermind_Options::Win_Sound      
          Audio.me_play(temp_sound, 100, 100)
        end
          uncover_answer
      else
        @round_index += 1
        open_command_window_2
        @game_mode = "color"
      end
    end
    #--------------------------------------------------------------------------
    # * Create Command Window Two
    #--------------------------------------------------------------------------
    def create_command_window_2
      @command_window_2 = Window_MastermindCommand_Color.new(0, 0, @ci)
      @command_window_2.x = (200 - @command_window_2.width) / 2
      @command_window_2.height = @command_window_2.fitting_height(6)
      @command_window_2.y = 210
      @command_window_2.openness = 0
      @command_window_2.active = false
    end
    #--------------------------------------------------------------------------
    # * Open Command Window Two
    #--------------------------------------------------------------------------
    def open_command_window_2
      @command_window_2.open
      @command_window_2.active = true
      @command_window_2.refresh
    end
    #--------------------------------------------------------------------------
    # * Close Command Window Two
    #--------------------------------------------------------------------------
    def close_command_window_2
      @command_window_2.close
      @command_window_2.active = false
      @command_window_2.refresh
    end
end
Keep the ideas coming man! I love your brain. You come up with the ideas and I'll do my best to change scripts to make it work.
I'm totally using all of this. I had the script in my game, but not a good way to utilize it, but I can see a way forward. Thanks

Thanks a lot. 🙂 I think we should have both icons AND text. Format would be "\i[redicon] Red".
both icons AND text
I don't need to recreate that. Yanfly Command Window Icons
I don't need to recreate that. Yanfly Command Window Icons
EDIT: Managed to do it. Thanks for this useful hint.
Managed to do it
Good stuff. I figured it out as well.
I also added (into my version - using luna engine at 640x480) multiple victory lines. Don't know if you would be interested in that.
Its just setting 6 different lines Victory1, Victory2, etc. and the text for that line.
Then the code under "win" is a case comparison against the colour variable
Ruby:
      elsif @game_mode == "win"
        Sound.play_use_skill
        case $game_variables[Mastermind_Options::Colours]
        when 1
          $game_message.add(sprintf(Mastermind_Options::Victory1, @actor))
        when 2
          $game_message.add(sprintf(Mastermind_Options::Victory2, @actor))
        when 3
          $game_message.add(sprintf(Mastermind_Options::Victory3, @actor))
        when 4
          $game_message.add(sprintf(Mastermind_Options::Victory4, @actor))
        when 5
          $game_message.add(sprintf(Mastermind_Options::Victory5, @actor))
        when 6
          $game_message.add(sprintf(Mastermind_Options::Victory6, @actor))
        end
        $game_switches[Mastermind_Options::Win] = true
        SceneManager.return
      end
I also edited the Lives window
1599314399097.png

Under mastermindlives window
Ruby:
    def refresh
        self.contents.clear
        self.contents.font.color = system_color
        self.contents.draw_text(4, 0, 90, line_height, "Lives")
        self.contents.draw_text(4, 24, 90, line_height, "Remaining:")
        self.contents.font.color = normal_color
        self.contents.draw_text(14, 24, 90, line_height, $game_variables[Mastermind_Options::Lives], 2)
    end
oh and change the window height to 100 or something that works for you
super(x, y, 135, 100)
That's cool. I make sure to try it.

I made some changes for me as well. There was a bug of showing the hard mode overlay not right in time. I found a proper way to fix it. Just find the parts in the script where it says...
Code:
@hard_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
@hard_sprite.bitmap = Cache.picture("mm_hard")
@hard_sprite.x = 50
@hard_sprite.y = 0
@hard_sprite.z = 2

...and change them to...
Code:
if $game_switches[Mastermind_Options::Difficulty] == true
@hard_sprite = Sprite.new(Viewport.new(0, 0, 640, 480))
@hard_sprite.bitmap = Cache.picture("mm_hard")
@hard_sprite.x = 50
@hard_sprite.y = 0
@hard_sprite.z = 2
 end

... and that's it.

Be sure to add this condition as well every time the hard window ("mm_hard") gets disposed, else you'll run into an disposed window error.
showing the hard mode overlay not right in time
True it was there even if the mode was easy. good work.
I also did a similar thing with the Lives window.
I moved it down to the "start" section after cover_answer so that it is only shown at the start after the colours are hidden and the command window shows up.
@lives = Window_MastermindLives.new(30, 30)
Also
add this condition as well every time
I just realized that the hard mode sprite only needs to be created if you have the switch on. so it only needs to be there once.
under def start I set it to the condition for the switch like you said and under terminate I added after the @hard_sprite.dispose if switch is on.
I also did a similar thing with the Lives window.
I moved it down to the "start" section after cover_answer so that it is only shown at the start after the colours are hidden and the command window shows up.

Good idea. For now as you saying it, I will do this as well.

Maybe we could do that the command window and the live window disappear while loosing a life and are re-opened after colors are re-rolled. I think we have to add it to this section somehow:
Code:
$game_variables[Mastermind_Options::Lives] -= 1
 update

Original thread: https://forums.rpgmakerweb.com/threads/mastermind-script-edit.126621/