Conditional Branch+

Discussion in 'JS Plugin Releases (RMMV)' started by mjshi, Jun 18, 2016.

  1. ChatS

    ChatS Villager Member

    Messages:
    8
    Likes Received:
    4
    First Language:
    French
    Primarily Uses:
    RMMV
    Hi mjshi, :)

    do you allow commercial use of your plugin?

    Thanks!
     
    #41
  2. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @ChatS All of my plugins are free to use for all projects regardless if commercial or noncommercial as long as you credit me (mjshi) ^^
     
    #42
    ChatS likes this.
  3. ChatS

    ChatS Villager Member

    Messages:
    8
    Likes Received:
    4
    First Language:
    French
    Primarily Uses:
    RMMV
    Okay that's good to know (And I just saw that it's written on your website!), excellent and thank you! No worries, I will give you credit. Do you wish to have your website linked into the credit list or just the mention of your name?
     
    #43
  4. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @ChatS I only require a mention of my name, but if you want to link my website as well, feel free to. I don't really mind or care either way xD
     
    #44
  5. Sashi

    Sashi Villager Member

    Messages:
    10
    Likes Received:
    2
    First Language:
    English
    Primarily Uses:
    RMMV
    Im not 100% sure how you would write the code for this so I wont comment on those specifics. If it doesn't matter what goes between the digits then I like "("1-3", 4, 5)". Which function would allow the digits to be written this way? for example
    * Check.has_more(1, 2, 3, 4, 5)
    written as Check.has_more("1-4",5)?
     
    #45
  6. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @Sashi Yeah, and you could write it as Check.has("1 to 4", 5) or even Check.has("1klsahjrklba4", 5). Any non-number character can be used as a separator and you don't even have to make it consistent.

    I will probably release it as an alternate version until I can ensure that everything is working as intended.
     
    #46
  7. Sashi

    Sashi Villager Member

    Messages:
    10
    Likes Received:
    2
    First Language:
    English
    Primarily Uses:
    RMMV
    @mjshi I like ("1 aefuhaufnquwd 4") haha thats interesting to know that anything can be placed in between the digits. you should call it CB 2.0 BETA because your right you have a perfect working script now. Im happy to test anything new you put out.
     
    #47
  8. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @Sashi I might take you up on that offer, haha. Right now I'm working on determining which of the Check calls should have the option. For example, Check.has obviously should have it, and Check.greater/Check.lesser as well. And all of the Check.each_ ones shouldn't because those are very specific. But the commands in the Equipment category? Now I'm not entirely sure. To add on to that, the Check.equipped code is super long and checks every actor, so it's going to be a huge pain to write it in since there are multiple points that need the thing.

    It doesn't help that when I was writing this I made some of the variable names different so now I have to make sure the variable names match when I'm writing in this new thing xD Which is why I'm hesitant to release this new version as an update (as in, replacing) the old one. I just know that I definitely copy/pasted something wrong or forgot to change a variable name somewhere.

    That said, I should probably have a working version of this soonish. A week or so from now at the very latest.
     
    #48
  9. Sashi

    Sashi Villager Member

    Messages:
    10
    Likes Received:
    2
    First Language:
    English
    Primarily Uses:
    RMMV
    I think you should also do:
    check.has_more/less/any
    I agree skip all the equips,
    check.armor/weapons (for inventory only, maybe?)
    check.is_any/not(variables)
    check.in/any_range (variables)
    check.all_true/false(switches)
    How about you alter the original post to have a version history? keep the link you currently have and then have a link that takes you to the newer version on your website.
    Variables create an endless list really quickly, I have a bad habit of just making new variables so I dont risk overlap but could clearly reuse some. Then by the end its just a huge mess.
    Looking forward to it!!
     
    #49
  10. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    It's done!

    Update 2.0 [download]
    * Added support for checking all ids or items in a given range.
    * Rather than Check.has(1, 2, 3, 4, 10), you can type Check.has("1-4", 10)
    * Simply type "1-4" or "1 to 4" or "1...4" or any variant you want, so long
    * as the separator between the start and stop is a non-digit character.

    @Sashi, may I ask that you test it out? I'll update this as the official version once I hear word back from you.
    Feedback from anyone who wants to pipe in is welcome as well.
     
    Last edited: May 18, 2018
    #50
    Joy Diamond likes this.
  11. Sashi

    Sashi Villager Member

    Messages:
    10
    Likes Received:
    2
    First Language:
    English
    Primarily Uses:
    RMMV
    @mjshi Hey Im glad to see you got this out so quickly. I am sorry to say this but I can not get the new feature to work. The original part of the script works fine: if (Check.has(50, 51)) {$gameParty.gainGold(5000);} but when I implement new feature: if (Check.has("50-51")) {$gameParty.gainGold(5000);} it doesn't work. Tried in a CBranch also
    ◆If:Script:Check.has("50-51")
    ◆Text:None, Window, Bottom
    : :Its all there

    :Else
    ◆Text:None, Window, Bottom
    : :Nope dont have

    :End
    Tried without "", "50 to 51", inside (), even gave #50/51 in weapons and armor, tried has_more, tried has_less, tried weapon checks, copied/pasted plugin, overwrought plugin, deleted/redownloaded script, tried on my senior project and a fresh project. I havnt had time to look into the script yet but I am getting no errors which is good and bad. Not sure why its not reading the command correctly.
     
    #51
  12. Nightblade50

    Nightblade50 Developer of "Delta Origins" Veteran

    Messages:
    2,062
    Likes Received:
    4,175
    Location:
    USA
    First Language:
    English, French
    Primarily Uses:
    RMVXA
    This is a big help.
     
    #52
  13. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    Last edited: Nov 10, 2018
    #53
    Nightblade50 likes this.
  14. Sashi

    Sashi Villager Member

    Messages:
    10
    Likes Received:
    2
    First Language:
    English
    Primarily Uses:
    RMMV
    @mjshi Nice! works perfectly now. I have tested most of the functions and all work perfectly. It reads and works very nicely. This will make life easy for anyone making overly complicated events (like me haha). What was the issue if you dont mind telling me?
    Before: !Check.has_any(50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74)
    Now: !Check.has_any("50-74")
     
    Last edited: Dec 20, 2017
    #54
  15. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @Sashi The "no error" thing was what really narrowed it down. Figured it must be because of me using some built in function in MV itself wrong, since those are usually written to handle errors more gracefully (that is, without displaying any errors). Found out that in all of the copy/pasted lines I made the same mistake-- I had interpreted the numbers perfectly and the loop was fine, just that I was using the wrong variable to call the MV check functions.

    To better explain it:
    IMG_7344.jpg

    Plus, whenever the index didn't exist it'd pass on an "undefined" along. The reason why it didn't error is that the MV built in function to check for items most likely has a safety net that makes sure the ID is a valid ID before doing stuff, and rejected any invalid IDs.
     
    #55
  16. Sashi

    Sashi Villager Member

    Messages:
    10
    Likes Received:
    2
    First Language:
    English
    Primarily Uses:
    RMMV
    Ahh makes sense. I wish they would show more in the debug window. Thats what its there for, Ive had other issues where nothing works but nothing is showing you where the problem. Turns into a hunt in the dark with no flashlight.
     
    #56
  17. Tonedawg181

    Tonedawg181 Tonedawg Gaming Veteran

    Messages:
    65
    Likes Received:
    19
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Thank you for this plugin @mjshi ! It's extremely helpful for my project :D
     
    #57
  18. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @Tonedawg181 You're very welcome ^^ I'm glad you find it helpful!
     
    #58
    Tonedawg181 likes this.
  19. ZiyaBeast

    ZiyaBeast Warper Member

    Messages:
    3
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    N/A
    I was able to make a 4 variable lottery thanks to this plugin. Here it is if anyone is interested. Watch out though, I used global variables because I'm not quite sure how to make functions like you did yet. This is no problem for me since I only intend on working on one game but if you want to use this then good luck lol.

    ◆Comment:Player has to correctly guess the position of 4 varied symbols 4 times.
    ◆Comment:Chances:
    : :Grand Prize: 0.39%
    : :3 of 4 or Higher: 1.56%
    : :2 of 4 or Higher: 6.25%
    : :1 of 4 or Higher: 25%
    ◆Text:None, Window, Bottom
    : :Would you like the play the lottery?
    ◆Show Choices:Yes, No (Window, Right, #1, #2)
    :When Yes
    ◆Control Switches:#0001..0008 = OFF
    ◆Control Variables:#0001 Lottery_Slot 1 = Random 1..4
    ◆If:Lottery_Slot 1 = 1
    ◆Control Variables:#0009 Lottery_Slot 1 Name = "Square"

    :End
    ◆If:Lottery_Slot 1 = 2
    ◆Control Variables:#0009 Lottery_Slot 1 Name = "Triangle"

    :End
    ◆If:Lottery_Slot 1 = 3
    ◆Control Variables:#0009 Lottery_Slot 1 Name = "Cross"

    :End
    ◆If:Lottery_Slot 1 = 4
    ◆Control Variables:#0009 Lottery_Slot 1 Name = "Circle"

    :End
    ◆Control Variables:#0002 Lottery_Slot 2 = Random 1..4
    ◆If:Lottery_Slot 2 = 1
    ◆Control Variables:#0010 Lottery_Slot 2 Name = "Square"

    :End
    ◆If:Lottery_Slot 2 = 2
    ◆Control Variables:#0010 Lottery_Slot 2 Name = "Triangle"

    :End
    ◆If:Lottery_Slot 2 = 3
    ◆Control Variables:#0010 Lottery_Slot 2 Name = "Cross"

    :End
    ◆If:Lottery_Slot 2 = 4
    ◆Control Variables:#0010 Lottery_Slot 2 Name = "Circle"

    :End
    ◆Control Variables:#0003 Lottery_Slot 3 = Random 1..4
    ◆If:Lottery_Slot 3 = 1
    ◆Control Variables:#0011 Lottery_Slot 3 Name = "Square"

    :End
    ◆If:Lottery_Slot 3 = 2
    ◆Control Variables:#0011 Lottery_Slot 3 Name = "Triangle"

    :End
    ◆If:Lottery_Slot 3 = 3
    ◆Control Variables:#0011 Lottery_Slot 3 Name = "Cross"

    :End
    ◆If:Lottery_Slot 3 = 4
    ◆Control Variables:#0011 Lottery_Slot 3 Name = "Circle"

    :End
    ◆Control Variables:#0004 Lottery_Slot 4 = Random 1..4
    ◆If:Lottery_Slot 4 = 1
    ◆Control Variables:#0012 Lottery_Slot 4 Name = "Square"

    :End
    ◆If:Lottery_Slot 4 = 2
    ◆Control Variables:#0012 Lottery_Slot 4 Name = "Triangle"

    :End
    ◆If:Lottery_Slot 4 = 3
    ◆Control Variables:#0012 Lottery_Slot 4 Name = "Cross"

    :End
    ◆If:Lottery_Slot 4 = 4
    ◆Control Variables:#0012 Lottery_Slot 4 Name = "Circle"

    :End
    ◆Text:None, Window, Bottom
    : :Pick 4 symbols
    ◆Show Choices:Square, Triangle, Cross, Circle (Window, Right, #1, -)
    :When Square
    ◆Control Variables:#0005 Lottery_Player Choice 1 = 1
    ◆Control Variables:#0013 Lottery_Player Choice 1 Name = "Square"

    :When Triangle
    ◆Control Variables:#0005 Lottery_Player Choice 1 = 2
    ◆Control Variables:#0013 Lottery_Player Choice 1 Name = "Triangle"

    :When Cross
    ◆Control Variables:#0005 Lottery_Player Choice 1 = 3
    ◆Control Variables:#0013 Lottery_Player Choice 1 Name = "Cross"

    :When Circle
    ◆Control Variables:#0005 Lottery_Player Choice 1 = 4
    ◆Control Variables:#0013 Lottery_Player Choice 1 Name = "Circle"

    :End
    ◆Show Choices:Square, Triangle, Cross, Circle (Window, Right, #1, -)
    :When Square
    ◆Control Variables:#0006 Lottery_Player Choice 2 = 1
    ◆Control Variables:#0014 Lottery_Player Choice 2 Name = "Square"

    :When Triangle
    ◆Control Variables:#0006 Lottery_Player Choice 2 = 2
    ◆Control Variables:#0014 Lottery_Player Choice 2 Name = "Triangle"

    :When Cross
    ◆Control Variables:#0006 Lottery_Player Choice 2 = 3
    ◆Control Variables:#0014 Lottery_Player Choice 2 Name = "Cross"

    :When Circle
    ◆Control Variables:#0006 Lottery_Player Choice 2 = 4
    ◆Control Variables:#0014 Lottery_Player Choice 2 Name = "Circle"

    :End
    ◆Show Choices:Square, Triangle, Cross, Circle (Window, Right, #1, -)
    :When Square
    ◆Control Variables:#0007 Lottery_Player Choice 3 = 1
    ◆Control Variables:#0015 Lottery_Player Choice 3 Name = "Square"

    :When Triangle
    ◆Control Variables:#0007 Lottery_Player Choice 3 = 2
    ◆Control Variables:#0015 Lottery_Player Choice 3 Name = "Triangle"

    :When Cross
    ◆Control Variables:#0007 Lottery_Player Choice 3 = 3
    ◆Control Variables:#0015 Lottery_Player Choice 3 Name = "Cross"

    :When Circle
    ◆Control Variables:#0007 Lottery_Player Choice 3 = 4
    ◆Control Variables:#0015 Lottery_Player Choice 3 Name = "Circle"

    :End
    ◆Show Choices:Square, Triangle, Cross, Circle (Window, Right, #1, -)
    :When Square
    ◆Control Variables:#0008 Lottery_Player Choice 4 = 1
    ◆Control Variables:#0016 Lottery_Player Choice 4 Name = "Square"

    :When Triangle
    ◆Control Variables:#0008 Lottery_Player Choice 4 = 2
    ◆Control Variables:#0016 Lottery_Player Choice 4 Name = "Triangle"

    :When Cross
    ◆Control Variables:#0008 Lottery_Player Choice 4 = 3
    ◆Control Variables:#0016 Lottery_Player Choice 4 Name = "Cross"

    :When Circle
    ◆Control Variables:#0008 Lottery_Player Choice 4 = 4
    ◆Control Variables:#0016 Lottery_Player Choice 4 Name = "Circle"

    :End
    ◆If:Lottery_Slot 1 = Lottery_Player Choice 1
    ◆Control Switches:#0001 Lottery_Correct 1 = ON

    :End
    ◆If:Lottery_Slot 2 = Lottery_Player Choice 2
    ◆Control Switches:#0002 Lottery_Correct 2 = ON

    :End
    ◆If:Lottery_Slot 3 = Lottery_Player Choice 3
    ◆Control Switches:#0003 Lottery_Correct 3 = ON

    :End
    ◆If:Lottery_Slot 4 = Lottery_Player Choice 4
    ◆Control Switches:#0004 Lottery_Correct 4 = ON

    :End
    ◆Text:None, Window, Bottom
    : :Correct Answer: \V[9] \V[10] \V[11] \V[12]
    : :Your Answer : \V[13] \V[14] \V[15] \V[16]
    ◆If:Script:Check.true(1,2,3,4)
    ◆Text:None, Window, Bottom
    : :You've won the Grand Prize
    ◆Control Switches:#0005 Lottery_Grand Prize = ON

    :Else
    ◆If:Script:Check.true(1,2,3) || Check.true(1,2,4) || Check.true(1,3,4) || Check.true(2,3,4)
    ◆Text:None, Window, Bottom
    : :You've matched 3 of the 4 symbols, here is your prize.
    ◆Control Switches:#0006 Lottery_3 of 4 = ON

    :Else
    ◆If:Script:Check.true(1,2) || Check.true(1,3) || Check.true(1,4) || Check.true(2,3) || Check.true(2,4) || Check.true (3,4)
    ◆Text:None, Window, Bottom
    : :You've matched 2 of the 4 symbols, here is your prize.
    ◆Control Switches:#0007 Lottery_2 of 4 = ON

    :Else
    ◆If:Script:Check.any_true(1,2,3,4)
    ◆Text:None, Window, Bottom
    : :You've matched only 1 of the 4 symbols, here is your
    : :prize.
    ◆Control Switches:#0008 Lottery_1 of 4 = ON

    :Else
    ◆Text:None, Window, Bottom
    : :None of your symbols matched.

    :End

    :End

    :End

    :End

    :When No
    ◆Text:None, Window, Bottom
    : :Okay

    :End
    ◆Comment:Prizes are shown as switches 5-8 from greatest to least. I will give the player a different
    : :reward depending on what environment they are in, which is why i didn't implement it in here.
    : :Switches 5-8 should be turned off after the player gets their prize.
     
    #59
    mjshi likes this.
  20. mishakoc

    mishakoc Professional Procrastinator Veteran

    Messages:
    115
    Likes Received:
    779
    First Language:
    Czech
    Primarily Uses:
    RMMV
    This is insanely helpful and makes keeping track of items very easy. Thank you very much for the plugin, @mjshi!
     
    #60
    mjshi likes this.

Share This Page