Confirmation box
Mon, 07 Jul 2008 15:30:35 -0400 - Author:
This script is designed for RPG Maker VX.
Here's the system I use to confirm choices from a player. Put the script below in the Materials section, after all other scripts.
That script defines two methods:
<ul> <li> pbConfirm(X) - for simple Yes/No questions. <li> pbConfirmCancel(X) - for Yes/No questions, where the player can choose not to answer. Here are examples of their use:
Here's the system I use to confirm choices from a player. Put the script below in the Materials section, after all other scripts.
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)
endThat script defines two methods:
<ul> <li> pbConfirm(X) - for simple Yes/No questions. <li> pbConfirmCancel(X) - for Yes/No questions, where the player can choose not to answer. Here are examples of their use:
if pbConfirm("Are you sure?")
# Do it
end
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
