Conditional Branch+

Discussion in 'RGSS3 Scripts (RMVX Ace)' started by mjshi, Jun 18, 2016.

  1. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    Conditional Branch+ v1.0 (VX Ace)
    by mjshi- OK for use in all projects with credit
    Get it here! (direct link)

    MV version also available.
    The MV version is 1 update ahead of this, but don't worry, I'll get to updating this as well.
    Eventually.

    In the past, if you wanted to see if the player has more than 10 potions in their inventory, you would have to open up a new event and do the following:
    Control Variables > Variable 1 > Set > Game Data > Item "Potion" In Inventory > OK > OK > ENTER > Conditional Branch > Variable 1 is > Greater than or equal to > "10" > OK

    How tedious! If only there was a simpler, more efficient way...
    Well. Look no further. Lazy- er, efficient people, rejoice! For the future is now, and with Conditional Branch+, you can replace that lengthy process with one that looks like this:
    Conditional Branch > Script > "Check.has_more(1, 10)" > OK

    Features
    - No longer do you need a bazillion nested conditional branches to check if the player has multiple items!
    Check.has(list of item ids) does that for you.
    - No more must you abuse the else branch to see if the player has either one item or another!
    Check.has_any(list of item ids) does that for you.
    - And the above apply for switches and variables as well, along with much, much more. A full list of functions can be found below:

    # 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.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.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.
    #==============================================================================

    Installation
    Paste this script anywhere above Main, it's not too picky about where it should be.

    Credit
    mjshi
     
    Last edited: Feb 5, 2017
    #1
    GummyHelix likes this.
  2. LunarPanda

    LunarPanda Warper Member

    Messages:
    1
    Likes Received:
    0
    First Language:
    English
    Hi, thank you for this!  :cutesmile:


    It seems like it'd be very useful, but I'm having a problem with it, and I don't know if it's me or if it's the script.  :unsure:


    Whenever I use it, I put in the script call from the conditional branch window:


    [​IMG]


    But then when I actually play test I get this error after activating the event:


    [​IMG]


    Any help would be greatly appreciated! :3


    EDIT BECAUSE I'M SOOOO STUPID!!!


    I just figured out that I had to use quotes in the script call. X_X


    I'm so sorry... :c You didn't use quotes in the example script calls that you put into the actual script so I didn't know. xD


    Anyways, I'm sorry again, and thanks (once again)! /)w(\
     
    Last edited by a moderator: Nov 5, 2016
    #2
  3. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @LunarPanda


    No... you shouldn't need quotes in the script call. That would be a bug-- it's not your problem, it's mine. Thank you for reporting it to me! Hang on, I'll see if I can't fix this.


    edit: the fix is fairly simple, the bug appeared because this was developed simultaneously for MV and Ace.


    It should be fixed now, check the pastebin link again (and make sure version is 1.01) or click this: http://pastebin.com/0yXdjtHJ
     
    Last edited by a moderator: Nov 5, 2016
    #3

Share This Page