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.

How to add a confirmation window to an existing script

I've been trying to add something to an existing Quest script to make it act more of an accept/decline quest thing than just displaying the quest information.  However, I seem to be having problems with adding this function.

I've made a command window and with these lines:

Code:
class Window_Quest_Accept < Window_Commands
       def initialize
          super(0, 0, 300, 100)
          @commands = ["Accept", "Decline"]
          @item_max = @commands.size
          self.index = 0
          refresh
        end
        def refresh
           self.contents.clear
           for i in 0...@item_max
               x = 4
               y = i
           end
        end

I really don't know how to go about it since I am just starting to script, but if anyone can help me with this, it willl be greatly appreciated.
 

khmp

Sponsor

Why do want to create a custom window for this? Is there a reason for not just creating an instance of a Window_Command object?

Code:
@accept_decline = Window_Command.new(300, ['Accept', 'Decline'])

In the update of whatever Scene this class is held in:
Code:
def update

  .... # Other code you would have.

  # Don't update if we can't see the window.
  if @accept_decline.visible
    # Update the window.
    @accept_decline.update
    # See what the user selection was.
    if Input.trigger?(Input::C)
      case @accept_decline.index
      when 0 # Accept
        # The user has accepted the quest. Do work.
      when 1 # Decline
        # The user has declined the quest.
        @accept_decline.visible = false
      end
    end
  end

  .... # Other code you would have.

end

If you do want to stick with creating a new window for whatever reason.
Code:
class Window_Quest_Accept < Window_Command
  def initialize
    # Call out parent's initialize. We derive from Window_Command
    # which takes two parameters:
    #   width     : the width of the window.
    #   commands : the array of commands to present to the user.
    super(300, ['Accept', 'Decline'])
    
    # All of this stuff is already done in our parent's constructor.
    # @commands = ['Accept', 'Decline']
    # @item_max = @commands.size
    # self.index = 0
    # refresh
  end
  #--------------------------------------------------------------------------------
  # We don't really need to customize refresh unless you want to do something special.
  #--------------------------------------------------------------------------------
  #def refresh
  #  self.contents.clear
  #  for i in 0...@item_max
  #    x = 4
  #    y = i
  #  end
  #end
end

Good luck with it Sakura Martinez! :thumb:
 
Thanks, I just thought that it would be easier to manage if I make it per window... lol, although I did know about the instance thing, I didn't know what the correct syntax for it was since I only read about the Window_Base instance...

EDIT:
I tried doing that and editing what needs to be edited when I merged it with the script but I get an error:
Script 'Quest System' line 47: RGSSError occured
failed to create bitmap
 

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