Started by ForeverZer0, August 06, 2010, 12:27:55 pm
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=# Message Choice Window# Author: ForeverZer0# Version: 1.0# Date: 8.5.2010#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=## Introduction:# This script will allow you to set up more than the 4 choices that RPGXP# limits you to. The window will behave much like the default window and is # very easy to use.## Features:# - Set up as many choices as you need (within reason)# - Custom window width, x, and y, or have it center automatically # - Can allow/disallow the player from canceling out of window# - Uses a single script call# - Does not effect the Window_Message class ## Instructions:# - Configuration is just below.# - Use this script call:## Choices.setup(WIDTH, CHOICES, CANCEL?, X, Y)## WIDTH = width of window# CHOICES = Array of choices that will be shown. These must be written as a# string. ex. ['one', 'two', 'three', 'four']# CANCEL? = Allowed player to cancel with B button? (true/false)# X, Y = The x and y that the window will be displayed at. ## - Not all of these arguments have to be used. The only two that are required# are the WIDTH and CHOICES array. The rest can be omitted.# - If the CANCEL? argument is not supplied, it will be true by default.# - If the X or Y argument is not supplied, the window will auto-center on# the omitted axis.## - What happens is when a choice is selected, it will set a variable to the# that choice's number (first choice is 1, second is 2, etc., etc.)# - If the player is allowed to cancel and the B button is pressed, the # variable will be set to 0# - Now all you must do is create conditional branches below the script call# with the condition for each being your variable equal to the respective# choice's number.##=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=#===============================================================================# ** Choices#===============================================================================module Choices # CONFIGURATION #------------------------------------------------------------------------ Variable_ID = 15 # ID of variable you would like to use for choices. Window_Opacity = 160 # Opacity of choice window (160 is Window_Message default) #------------------------------------------------------------------------ # DO NOT CONFIGURE ANYTHING BELOW THIS LINE def self.setup(width, choices, cancel = true, x = nil, y = nil) return unless $scene.is_a?(Scene_Map) $game_system.map_interpreter.message_waiting = true $game_temp.choice_cancel_type = cancel $scene.choice_window = Window_Command.new(width, choices) $scene.choice_window.x = x == nil ? (640 - $scene.choice_window.width)/2 : x $scene.choice_window.y = y == nil ? (480 - $scene.choice_window.height)/2 : y $scene.choice_window.back_opacity = Window_Opacity endend#===============================================================================# ** Scene_Map#===============================================================================class Scene_Map attr_accessor :choice_window alias zer0_choice_window_main main def main zer0_choice_window_main @choice_window.dispose if @choice_window != nil end alias zer0_choice_window_upd update def update if @choice_window != nil && @choice_window.active @choice_window.update update_choice_window end zer0_choice_window_upd end def update_choice_window if Input.trigger?(Input::B) unless $game_temp.choice_cancel_type $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.cancel_se) $game_variables[Choices::Variable_ID] = 0 terminate_choice_window elsif Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) $game_variables[Choices::Variable_ID] = @choice_window.index + 1 terminate_choice_window end end def terminate_choice_window $game_system.map_interpreter.message_waiting = false @choice_window.dispose @choice_window = nil endend#===============================================================================# ** Interpreter#===============================================================================class Interpreter attr_accessor :message_waitingend
Quote from: game_guy on August 06, 2010, 05:43:32 pmFor the cancel thing, add a cancel choice index like RPGXP does.In the show choices command it says Cance Index or something.
Quote from: ForeverZer0 on August 10, 2010, 05:07:52 pmQuote from: game_guy on August 06, 2010, 05:43:32 pmFor the cancel thing, add a cancel choice index like RPGXP does.In the show choices command it says Cance Index or something.@g_gAll you have to do is not set a condition for the option you want to be the "cancel". It will not do anything and have the exact same effect. For example, say you have 2 options (yes and no), only set a condition for "yes" if you want it to be a cancel if the player selects "no". Thats why there is no "Cancel Option".
Play a song?Battle Theme < only appears if the player has CD_Battle Theme item in their inventoryOverworld Theme < only appears if the player has CD_Overworld Theme item in their inventoryTown Theme < etc..
$songs = 
Item in inventory $songs.push("Battle Theme")else $songs.delete("Battle Theme")end
Quote$IanSchoolPeople = $IanSchoolPeople.clearif $game_switches == truethen$IanSchoolPeople.push("Ask About\ Bartholomew")end
if $game_self_switches[[2, 8, "B"]] == true
Quote@>Script: $chosen = $game_variables - 1@>Conditional Branch: Script: $IanSchoolPeople[$chosen] == "Ask About Bartholomew" @>Show Text: Bartholomew doesn't seem very interested in @> : his classes, does he? @> : Branch End@>Label: JumpHereToSkipChoices@>