Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Options Screen script needed

Description:

If the title didn't give it away, what I basically need here is the design of an options screen... or at least to get started along my way. I've never before scripted my own scene from scratch with all the needed windows and fucntionality and everything... and looking at other scripts didn't really clue me in, so I guess I'll need to tell someone exactly what I need and see how it's done to figure out how to do similar in the future.

So here's the deal... in the game I'm creating, I have an "Options" command that I added in to the menu. Right now, it does nothing, because I haven't made or obtained an Options scene for it yet. I don't really know of many things that can be set, so this will be a fairly simple options screen, but I most likely can expand it on my own if need be once it's created.

The screen should basically consist of two windows. A thinner, command window on the left side and then the right side should have the options available for the selected command. Sort of like how the Menu has the menu commands on the left and Menu_Status on the right.

The left-hand commands should consist of:

"Message Speed"
"Window Color"
"Party Display"

(like I said, not much)

When Message Speed is selected, the right window should have "1,2,3,4,5" as selectable options. Don't worry about having the numbers actually do anything. As long as the indexes are 0-4 for them, I think I can build the case statement that actually changes the message speed based upon the option.

Window Color is a tricky one, because it depends on what is possible in RMXP. If anyone knows of a way to change the hue of the current Window Skin, I would just want a set of RGB sliders that sets the Window Skin color to whatever color is picked. However, if the only way to change the color is by picking a different window skin entirely that's just the same thing recolored, then the options available should just read: "Blue", "Purple", "Green", "Red". I can take care of the code that actually changes the Windowskin myself.

Last (so far anyway), we have the Party Display Option. The choices here should be "Face" and "Sprite". I can take care of the code behind the choices, once again.

Screen shot:

options_screen.png


That's actually a shot of as far as I got on it trying to do it myself before giving up. I couldn't get it to dynamically display the options on the right according to what option was selected on the left (should I even be bothering? that's a minor detail) and I also couldn't get it to just select one of the numbers, it just grabbed everything as being part of that index (maybe it's better to make the options drop down vertically instead of horizontally so they can gain indexes naturally?)

and since I couldn't select individual options, I was lost at where to put the code that handles what they do.

if anyone is interested, here's the actual script that shows what I was trying:

Code:
# ** Window_Options

class Window_Options < Window_Selectable

 

    def initialize

        super(0,8,468,128)

        self.contents = Bitmap.new(width - 32, height - 32)

        refresh

        self.active = false

        self.index = -1

    end

 

    def refresh

        self.contents.clear

        x = 32

        y = 0

        self.contents.draw_text(x, y, 32, 22, "1")

        self.contents.draw_text(x + 32, y, 32, 22, "2")

        self.contents.draw_text(x + 64, y, 32, 22, "3")

        self.contents.draw_text(x + 96, y, 32, 22, "4")

        self.contents.draw_text(x + 128, y, 32, 22, "5")

    end

    

    # * Cursor update

    def update_cursor_rect

        if @index < 0

            self.cursor_rect.empty

        else

            self.cursor_rect.set(0, @index * 22, self.width - 32, 22)

        end

    end

end

 

# ** Scene_Options

class Scene_Options

 

    def initialize(menu_index = 0)

        @menu_index = menu_index

    end

    

    def main

        # commands

        s1 = "Message Speed"

        s2 = "Window Color"

        s3 = "Party Display"

        # left window

        @command_window = Window_Command.new(156, [s1, s2, s3])

        @command_window.x = 8

        @command_window.y = 8

        @command_window.index = @menu_index

        # right window

        @options_window = Window_Options.new

        @options_window.x = 164

        @options_window.y = 8

    @options_window.height = @command_window.height

        

        Graphics.transition

        

        loop do

            Graphics.update

            Input.update

            update

            

            if $scene != self

                break

            end

        end

        

        Graphics.freeze

        

        @command_window.dispose

        @options_window.dispose

    end

    

    # * Frame Update

    def update

        # Update windows

        @command_window.update

        @options_window.update

        # If command window is active

        if @command_window.active

            update_command

            return

        end

        # If options window is active

        if @options_window.active

            update_options

            return

        end

    end

    # * Frame Update (when command window is active)

    def update_command

        # If B is pressed

        if Input.trigger?(Input::B)

            # Play cancel SE

            $game_system.se_play($data_system.cancel_se)

            # Back to Menu

            $scene = Scene_Menu.new(5)

            return

        end

        # If C is pressed

        if Input.trigger?(Input::C)

            #  Make options window active

            @command_window.active = false

            @options_window.active = true

            @options_window.index = 0

        end

    end

    # * Frame Update (when options window is active)

    def update_options

        # If B is pressed

        if Input.trigger?(Input::B)

            # Play cancel SE

            $game_system.se_play($data_system.cancel_se)

            # Make command window active

            @command_window.active = true

            @options_window.active = false

            @options_window.index = -1

            return

        end

        # If C is pressed

        if Input.trigger?(Input::C)

            # Branch by command window cursor position

            case @command_window.index

            when 0 # Message Speed

                # Play decision SE

                $game_system.se_play($data_system.decision_se)

                #  Code for selecting Message Speed (1-5)

 

            when 1 # Window Color

                # Play decision SE

                $game_system.se_play($data_system.decision_se)

                #  Code for picking Window Color

                

            when 2 # Party Display

                # Play decision SE

                $game_system.se_play($data_system.decision_se)

                #  Code for selecting Face or Sprite

            end

            return

        end

    end

end

Other Details:

-I prefer that this script be Non-SDK. SDK scripts usually just give me errors, whereas ones that do not rely on it more often tend to work just fine.
-If you ABSOLUTELY have to use SDK methods in order to accomplish the script, just don't make the script rely on the MaCL. I can throw SDK part 1 (and maybe even the other parts) in my game just fine if need be... but I know for certain that MACL will break my other scripts, so it can't be installed.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top