Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-------------------------------------------------------------------------------
- # Conditional Branch+ v1.01
- #-- Extends the functionality of what a conditional branch can check.
- #-- By mjshi
- #-------------------------------------------------------------------------------
- # Installation: Put above Main, otherwise, location doesn't matter
- #-------------------------------------------------------------------------------
- # How to use:
- # On a conditional branch, go to the fourth tab and select the "Script" option.
- # Type in desired thing to check. See below...
- #===============================================================================
- # Asterisk (*) means multiple inputs are accepted.
- #===============================================================================
- # Combining Checks
- # Use "&&", "||", and "()" to combine several checks in a conditional branch.
- # && = this AND that are true
- # || = this OR that are true
- # () = order of operations, check innermost parentheses first
- # ! = translates to NOT. EX. !Check.has(1) checks if player DOESN'T have it.
- #
- #-- EX: (Check.has(1) && Check.greater(1 , 0)) || Check.has(2)
- #-- Checks if player has item 1 and variable 1 > 0, or player has item 2.
- #===============================================================================
- # Possible Checks
- #-------------------------------------------------------------------------------
- # Items
- #-------------------------------------------------------------------------------
- # Check.has(*items)
- #-- EX: Check.has(1, 3, 4)
- #-- checks if player has items 1, 3, and 4 in inventory.
- #
- # Check.has_more(*items, number)
- #-- EX: Check.has_more(1, 2, 3, 4, 5)
- #-- checks if player has at least five (includes 5) of items 1, 2, 3, 4.
- #
- # Check.has_less(*items, number)
- #-- EX: Check.has_less(1, 2, 3, 4, 5)
- #-- checks if player has at most five (includes 5) of items 1, 2, 3, 4.
- #
- # Check.has_any(*items)
- #-- EX: Check.has_any(1, 3, 4)
- #-- checks if player has either item 1, 3, or 4 in inventory.
- #
- # Check.each_more(*[item, number])
- #-- EX: Check.each_more([1, 2], [2, 4])
- #-- checks if there are at least 2 of item 1 and at least 4 of item 2.
- #
- # Check.each_less(*[item, number])
- #-- EX: Check.each_less([1, 2], [2, 4])
- #-- checks if there are at most 2 of item 1 and at most 4 of item 2.
- #-------------------------------------------------------------------------------
- # Variables
- #-------------------------------------------------------------------------------
- # Check.is_any(variable, *values)
- #-- EX: Check.is_any(1, 3, 4, 5)
- #-- checks if variable 1 is either 3, 4, or 5
- #
- # Check.greater(*variables, value)
- #-- EX: Check.greater(1, 2, 3, 5)
- #-- checks if variables 1, 2, and 3 are at least 5.
- #
- # Check.lesser(*variables, value)
- #-- EX: Check.lesser(1, 2, 3, 5)
- #-- checks if variables 1, 2, and 3 are at most 5.
- #
- # Check.in_range(*variables, start, stop)
- #-- EX: Check.in_range(1, 3, 4, 5)
- #-- checks if variable 1 AND 3 are between 4 and 5, including 4 and 5.
- #
- # Check.any_inrange(*variables, start, stop)
- #-- EX: Check.any_inrange(1, 3, 4, 5)
- #-- checks if variable 1 OR 3 are between 4 and 5, including 4 and 5.
- #
- # Check.each_is(*[variable, value])
- #-- EX: Check.each_is([1, 3], [4, 5])
- #-- checks if variable 1 is 3, and variable 4 is 5.
- #
- # Check.each_greater(*[variable, value])
- #-- EX: Check.each_greater([1, 3], [4, 5])
- #-- checks if variable 1 is at least 3 and variable 4 is at least 5.
- #
- # Check.each_lesser(*[variable, value])
- #-- EX: Check.each_lesser([1, 3], [4, 5])
- #-- checks if variable 1 is at most 3 and variable 4 is at most 5.
- #
- # Check.each_inrange(*[variable, start, stop])
- #-- EX: Check.in_range([1, 3, 5], [3, 1, 4])
- #-- checks if variable 1 is between 3 and 5, and variable 3 is between 1 and 4.
- #-------------------------------------------------------------------------------
- # Switches
- #-------------------------------------------------------------------------------
- # Check.all_true(*switches)
- #-- EX: Check.all_true(1, 2, 3)
- #-- checks if switches 1, 2, 3 are true
- #
- # Check.any_true(*switches)
- #-- EX: Check.any_true(1, 2, 3)
- #-- checks if either of switches 1, 2, 3 are true
- #
- # Check.all_false(*switches)
- #-- EX: Check.all_false(1, 2, 3)
- #-- checks if switches 1, 2, 3 are false
- #
- # Check.any_false(*switches)
- #-- EX: Check.any_false(1, 2, 3)
- #-- checks if either of switches 1, 2, 3 are false
- #
- # Check.each_switch(*[switch, on/off])
- # If on, put 1. If off, put 0.
- #===============================================================================
- module Check
- #-----------------------------------------------------------------------------
- # Items
- #-----------------------------------------------------------------------------
- def self.has(*items)
- items.each do |item|
- return false if !$game_party.has_item?($data_items[item])
- end
- return true
- end
- def self.has_more(*items, number)
- items.each do |item|
- return false if $game_party.item_number($data_items[item]) < number
- end
- return true
- end
- def self.has_less(*items, number)
- items.each do |item|
- return false if $game_party.item_number($data_items[item]) > number
- end
- return true
- end
- def self.has_any(*items)
- items.each do |item|
- return true if $game_party.has_item?($data_items[item])
- end
- return false
- end
- def self.each_more(*item_number_array)
- item_number_array.each do |array|
- return false if $game_party.item_number($data_items[array[0]]) < array[1]
- end
- return true
- end
- def self.each_less(*item_number_array)
- item_number_array.each do |array|
- return false if $game_party.item_number($data_items[array[0]]) > array[1]
- end
- return true
- end
- #-----------------------------------------------------------------------------
- # Variables
- #-----------------------------------------------------------------------------
- def self.is_not(id, *values)
- values.each do |value|
- return false if $game_variables[id] == value
- end
- return true
- end
- def self.is_any(id, *values)
- values.each do |value|
- return true if $game_variables[id] == value
- end
- return false
- end
- def self.greater(*ids, value)
- ids.each do |id|
- return false if $game_variables[id] < value
- end
- return true
- end
- def self.lesser(*ids, value)
- ids.each do |id|
- return false if $game_variables[id] > value
- end
- return true
- end
- def self.in_range(*ids, start, stop)
- ids.each do |id|
- return false if ($game_variables[id] < start) || ($game_variables[id] > stop)
- end
- return true
- end
- def self.any_inrange(*ids, start, stop)
- ids.each do |id|
- return true if ($game_variables[id] >= start) && ($game_variables[id] <= stop)
- end
- return false
- end
- def self.each_is(*variable_array)
- variable_array.each do |array|
- return false if $game_variables[array[0]] != array[1]
- end
- return true
- end
- def self.each_greater(*variable_array)
- variable_array.each do |array|
- return false if $game_variables[array[0]] < array[1]
- end
- return true
- end
- def self.each_lesser(*variable_array)
- variable_array.each do |array|
- return false if $game_variables[array[0]] > array[1]
- end
- return true
- end
- def self.each_inrange(*variable_array)
- variable_array.each do |array|
- return false if ($game_variables[array[0]] < array[1]) || ($game_variables[array[0]] > array[2])
- end
- return true
- end
- #-----------------------------------------------------------------------------
- # Switches
- #-----------------------------------------------------------------------------
- def self.all_true(*switches)
- switches.each do |switch|
- return false if !$game_switches[switch]
- end
- return true
- end
- def self.any_true(*switches)
- switches.each do |switch|
- return true if $game_switches[switch]
- end
- return false
- end
- def self.all_false(*switches)
- switches.each do |switch|
- return false if $game_switches[switch]
- end
- return true
- end
- def self.any_false(*switches)
- switches.each do |switch|
- return true if !$game_switches[switch]
- end
- return false
- end
- def self.each_switch(*switches_array)
- switches_array.each do |array|
- return false if $game_switches[array[0]] != array[1]
- end
- return true
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement