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.

Confirmation box

I'm having a headache figuring out how to make a confirmation box. Like, for example, I'm making a forging system and a player have to confirm their decision before forging begins.

I tried setting the .active of selection window to false and .visible&.active of confirm window to true. What happened was that the cursor in the selection window became inactive (it flickers~) but there is no cursor in the confirmation window  :dead:

Do I need to put them in different viewport? I just can't figure out how other people are doing it XD

Thanks very muchly  :blush:
 

poccil

Sponsor

Here's the system I use to confirm choices from a player.  Put the script below in the Materials section, after all other scripts.
Code:
def pbShowChoices(text,choices,cancelType)
    messageWindow=Window_Message.new
    messageWindow.z=100000
    retval=-2
    $game_message=Game_Message.new if !$game_message
    if !$data_system
      $data_system=load_data("Data/System.rvdata") rescue RPG::System.new
    end
    $game_message.texts.push(text)
    if $game_message.texts.size <= 4 - choices.size
      $game_message.choice_start = 1
      $game_message.choice_max = choices.length
      for s in choices
        $game_message.texts.push(s)
      end
      $game_message.choice_cancel_type = cancelType
      $game_message.choice_proc = Proc.new { |n| retval=n }
    end
    while retval==-2
      Graphics.update
      Input.update
      messageWindow.update
    end
    messageWindow.dispose
    return retval
end

def pbConfirm(text)
  return pbShowChoices(text,["Yes","No"],2)==0
end
def pbConfirmCancel(text)
  return pbShowChoices(text,["Yes","No","Cancel"],3)
end
That script defines two methods
  • pbConfirm(X) - for simple Yes/No questions.
  • pbConfirmCancel(X) - for Yes/No questions, where the player can choose not to answer.

Here are examples of their use:

Code:
if pbConfirm("Are you sure?")
   # Do it
end

Code:
code=pbConfirmCancel("Are you sure?")
if code==0
  # Do it and exit
elsif code==1
  # Don't do it and exit
else
  # Do nothing
end
 

poccil

Sponsor

Your problem here is that the cursor still needed to be set in the confirmation window.  If the window derives from Window_Selectable, that normally involves setting the index (for example: "mywindow.index=0" ).

In my script above, however, I use the built-in message system that RPG Maker VX's default scripts offer.  That means that all features for text messages can be used here.
 

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