Conditional Branch+

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

  1. deathsia

    deathsia Pegisister Veteran

    Messages:
    618
    Likes Received:
    52
    First Language:
    English
    okay, I was a dummy, I forgot to put in a Check.has(51, 52) && !Check.has(53) in my event code. >.<
     
    #21
  2. Jeysonmcfly

    Jeysonmcfly Just a random Joe Schmoe Veteran

    Messages:
    54
    Likes Received:
    15
    Location:
    Soon to be Canadian
    First Language:
    English
    Sorry if this is a necro post, but would it be possible to add in functionality for skill or item usage checks? Not just if an item is in the inventory, or how many the player has, but if the item is being used. Same for skills.

    I was hoping to implement a shield points system in my game, but unfortunately, the barrier points plugin I was hoping to use doesn't work the way I was hoping.
     
    #22
  3. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @Jeysonmcfly hi there! No worries, you didn't necropost ^^

    What you want should already be doable in MV with eventing. Go check the troop page conditions, and try setting up something with variables, or have that skill call a common event that does the whole checking thing.

    I mean, of course it's possible to code the thing you wanted, but that isn't really what the point of this plugin. The point of this plugin is to do batch checks of conditions, mostly for usage in quests, not for adding battle functionalities or to act as a substitute for other plugins. If you want a shield points plugin you should try asking the Plugin Requests forum or the author of the plugin you'd originally intended to use.
     
    #23
  4. Jeysonmcfly

    Jeysonmcfly Just a random Joe Schmoe Veteran

    Messages:
    54
    Likes Received:
    15
    Location:
    Soon to be Canadian
    First Language:
    English
    Ah, I see. Thank you for your reply! I guess I didn't think of using common events! Many thanks for telling me this!
     
    #24
  5. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    Thanks to @Neo Soul Gamer for pointing these issues out!

    update v1.2
    Fixed issues with Check.greater and Check.lesser, updated help file.
     
    #25
  6. Rhino

    Rhino ~Inactive~ Veteran

    Messages:
    482
    Likes Received:
    784
    First Language:
    English
    Primarily Uses:
    RMMV
    Is this/can this be made to work with the select item command? :kaoluv:

    It stores the item id in a variable so I don't know how different that is to checking in the inventory.
     
    #26
  7. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @Rhino You mean select key item, the one that stores item ids in a variable?
    As long as it's a variable it'll work. In fact, this even works with some Yanfly plugins, since some of them run code directly from the notes box.
     
    #27
    Rhino likes this.
  8. Rhino

    Rhino ~Inactive~ Veteran

    Messages:
    482
    Likes Received:
    784
    First Language:
    English
    Primarily Uses:
    RMMV
    You reply so quick! I was just about to make an edit saying I noticed the check variable for multiple values which should work for what I want. This plugin has so many features, I just glanced over them instead of reading the full description :kaoeh: It's such an amazing plugin though! Thanks for writing this!!!!

    Sorry for bothering you!
     
    #28
  9. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @Rhino It's not a problem at all. I'm glad I was able to help!
     
    #29
  10. Tea's Jams

    Tea's Jams I'm human Veteran

    Messages:
    776
    Likes Received:
    1,962
    First Language:
    English
    Primarily Uses:
    RMMV
    This is a really cool plug in, thank you for sharing!! :D :D :D
     
    #30
    mjshi likes this.
  11. CatFish21sm

    CatFish21sm Villager Member

    Messages:
    12
    Likes Received:
    0
    First Language:
    English
    Primarily Uses:
    RMMV
    This is a little late, but something I try to do quite often is to check to see if there has been a change in a variable. I usually end up creating multiple conditional branches inside of conditional branches, beside conditional branches, and you get it just to check if a variable or switch has changed. Not a specific change just a general change
    One example I have is I have a variable that can go up to 8, so I have to create 8 conditional branches to check what number it's on at all times just to check if the variable has experienced a change.
    A change meaning that it went up any number of values, down any number of values, or in this case just changed in general.
    It works, but it's sloppy and if there is a tiny issue I have to practically erase the whole thing and redo it from start.
    This became an even larger issue with my newest project in which I needed to check for a change in a variable that had a literal infinite number of possible values... I could spend months creating conditional branches and doing math and even cut the number of branches in half and still not even be close to being finished. All I need to do is check to see if a variable has changed I don't know why that's so hard...

    I actually use this for quite a bit of functionality in my game, and it sucks because there is no simple solution and I often end up having to find a work around.

    I don't know if it would be possible to create a plugin with this functionality but this seems like the closest thing I've found so far, so I figured I'd make a post and see how it goes...
     
    #31
  12. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @CatFish21sm That sounds like a nightmare xD What are you checking variable changes for? Is all of that in a parallel event or something? There might be an easier way.
     
    #32
  13. CatFish21sm

    CatFish21sm Villager Member

    Messages:
    12
    Likes Received:
    0
    First Language:
    English
    Primarily Uses:
    RMMV

    Yes nightmare it is. I found plugins so far that are great work arounds. But none of them do more than one or two scenes.
    The latest was a step counter, I wanted to play a common event for every time a step was taken. I had another event that would add or subtract from a variable depending on the action taken. I wanted another variable to count every time there was a change in the first variable. If the first variable met certain conditions it would trigger an event. Then if both met certain conditions it would trigger another event. The variables counted decisions made by the player (I'm making a game that offers a lot of decisions) While this was a simple one I just had to make two variables and add a conditional branch for each for every action, I just ended up using switches for these to add a little more flexibility.
    I have several interlocked decisions that are only available if a certain condition is met and they all impact each other. So one variable might add or detract depending on your answer to a question, another variable might add 1 whenever that variable adds or detracts. Then another variable might detract from the second whenever a certain condition is met. So on and so forth. So by the time I get everything said and done it ends up being a dozen conditional branches in a few common events. When I could just set the variables to measure changes in each other rather than having to do an ( I=x blah, else if=a blah, else=y blah else... etc.)
    A simple example to explain what I mean. Say I have variable x, y and z. I want variable y to measure whenever I have a change in variable x or variable z (Positive or negative) Instead of adding an extra command to every option that would cause any change with either variable, I could simply create a single common event that searches for a change in either variable and run one instance of it as a parallel event to every area where those choices are present. So instead of having to keep up with a dozen y's and adding them to every event that would effect another variable that influences them I could simply create a single simple common event that handles all of them and run it in a parallel process on every map that could cause a change in a variable (Every map basically).

    It's not so much an issue on most of them because most are short and sweet, but the issue comes in having to do the big things when it could be simplified to a medium thing, and a thousand little things when it could be simplified to 250 little things :p

    I'm actually working on a parody game. Something like Disgaea, but much less battle intensive. There are battles, but most are a joke meant to make fun. The real game-play comes with the story and the decisions. I'm recording every decision that's made, even the number of times you use certain spells, skills, items, etc. And I'm hiding a slew of Easter eggs.

    I'm even going to have multiple story archs with not just multiple endings but entirely different stories with different main characters and etc depending on the decisions you make and the paths you take. I'll probably even end up creating entire worlds only usable in a certain arch under certain conditions. I've already got plans for several towns that are going to be different depending on the choices you've made until you reach them. It's a big project I'm probably going to get bored with and finish a few years down the road when MV is no longer the newest version :p

    As of right now I'm solving most of my problems with 30 plugins, that could be simplified to 30 variables that don't risk crashing my game if placed in the wrong order LOL.
    I also have half of a town and half of a dungeon... and even with the plugins, the variables and switches are piling up... The only thing I can say is thank God for yanfly and self switches :p (Nothing against the other plugin makers they are all GREAT! but 90% of my list is yanfly and a lot of their plugins can't be replaced)
    I'm using multiple plugins for unintended uses just to side step a few variables. That's always fun... finding out which two or three will work together to accomplish a certain task a certain way lol.

    Anyway my whole project is a nightmare (I literally have nightmares about it) but it's really fun, except this frigging variable thing!

    The ironic part is I know html like the back of my hand. I can make html do things that my coding teachers thought were impossible... but I SUCK at JS. I've been slowly studying it piece by piece for the past five years and can't even write a single line. Which is weird because I can read it with ease, and even find errors in it. But when it comes to writing it I just can't. So I'm fully dependent on people like you making these awesome plugins!
    I can say I am improving a lot faster since getting MV though... Still cant write, but I can read it better! That's something... I think...
    Anyway I'm going to shut up before I get blabbering on about a completely unrelated topic like fishing...
    Come to think of it a fishing mini-game would be......
    Really complicated and completely screw me over probably....
    SO I'm going to shut up now and hit that little post button.
     
    Last edited: Oct 13, 2017
    #33
  14. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @CatFish21sm Woah, long post xD

    This doesn't really sound like something you could put a conditional branch check to, not without modifying some base code. All the functions in Conditional Branch+ exist independently of any built-in-functions (as in, they don't overwrite or modify anything in the source files) and are simply shorthands for much longer things. Everything included in this plugin could technically work if you pasted them in the conditional branch's script box, so your suggestion isn't really a feature I'd add to the main script.

    However, since you know a bit of coding yourself, you could set up something using the functions in rpg_objects.js. I'm a bit busy this weekend, so I won't have the time to actually sit down and write anything until next week. Hopefully if you know where to look you'll be able to figure something out by yourself-- otherwise, I'll try my best to help you next week.

    Code:
    Game_Variables.prototype.setValue = function(variableId, value) {
        if (variableId > 0 && variableId < $dataSystem.variables.length) {
            if (typeof value === 'number') {
                value = Math.floor(value);
            }
    //add stuff here to keep track of how much something has changed
    //ex, set switch 1 to true whenever variable 1 is changed
            this._data[variableId] = value;
            this.onChange();
        }
    };
    
    Game_Variables.prototype.onChange = function() {
    //add stuff here to keep track of when variables are changed
        $gameMap.requestRefresh();
    };
     
    #34
  15. CatFish21sm

    CatFish21sm Villager Member

    Messages:
    12
    Likes Received:
    0
    First Language:
    English
    Primarily Uses:
    RMMV

    Thanks for the quick replies! And thanks for the explanation, this seems like a good excuse to study up on JS a little.
    I'll give it a try :p
    That's one of the reasons that I bought MV really, to help me learn JS, but I didn't have a clue where to even start here so thanks!
    PS You can probably tell I'm still a complete noob at JS lol :p
     
    #35
  16. Sashi

    Sashi Villager Member

    Messages:
    10
    Likes Received:
    2
    First Language:
    English
    Primarily Uses:
    RMMV
    Hey this is a fantastic script!! it has cut down on so much BS in my events. Was wondering if there is a way to make things even shorter by calling all ids in a row with just "check.has(1..30)"? This way it can look for a list of items without having to type out: 1, 2, 3, 4, etc...
    Also wanted to add this: "if (!Check.has_any(104,107,110)) {....;}" for those that want to make everything just one line in event script command. (no "") makes everything take up even less space.
     
    Last edited: Dec 1, 2017
    #36
  17. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @Sashi That sounds like a really useful feature, I'll see what I can do!

    Only thing is, Conditional Branch++ operates based on script call, and when you're calling a function you can't have things like periods in them. You'd probably have to pass it a string, like so: Check.has_any("1...4"), Check.has_any("1 to 4"), Check.has_any("1...4", "7...13")

    Between "..." and "to", which do you think would be better for something like this?
     
    #37
  18. tony keyes

    tony keyes Warper Member

    Messages:
    2
    Likes Received:
    0
    First Language:
    english
    Primarily Uses:
    RMMV
    I think “x to x” would be better. That way it could read (“x to x”, x, x). Easier to see any typos this way.
     
    #38
  19. Joy Diamond

    Joy Diamond Talkative Veteran

    Messages:
    135
    Likes Received:
    172
    First Language:
    English
    Primarily Uses:
    RMMV
    mjshi,
    Regular expression syntax in JavaScript uses [1-4] so I suggest this syntax instead of either ' to ' or '...':
    • It is more consistent with the underlying language, and will be recognizable.
    • (I mean easier for the user of the plugin to recognize. It will be only very slightly harder to program)
    So I suggest:
    • Check.has_any("[1-4]"), Check.has_any("[1-4]", "[7-13]")
    Joy Diamond.

    NOTE:
    • Of course in regular expressions [1-40] would mean characters '[1-4]' followed by a '0', but we'll ignore that.
    • Users of your plugin would understand it is dealing with integer not characters, and I am not suggesting let them pass in a regular expression, just copying part of it's recognizable syntax.
    upload_2017-12-6_11-46-45.png

    P.P.S.: Ranges are notoriously tricky in languages:
    • For example in python, a range does not include the ending value:
    upload_2017-12-6_11-44-5.png
    • The same is true in JavaScript with the .slice operator:
    upload_2017-12-6_11-40-58.png
    • Thus my suggesting basing this on Regular Expressions is very carefully thought out:
    • I picked something from JavaScript that *DOES* include the ending index.
    • (I.e.: It is not just a random suggestion)
     
    Last edited: Dec 7, 2017
    #39
  20. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    910
    Likes Received:
    721
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @tony keyes Yeah, I was thinking "to" because of it being a more natural structure in language, and "..." because it's a more natural structure in math and it's used to express ranges in a couple programming languages.

    @Joy Diamond Thank you for your very thourough input!
    True, using "-" would be more consistent with other code stuff but you know, it seems that people have a lot of different thoughts on what they want as a delimiter. Perhaps I should use regex to capture two digit groups separated by a non-digit group. That would work better and be more general, though possibly slightly slower.

    How would that work for you all?
     
    #40

Share This Page