Jump to Label

Discussion in 'JS Plugin Releases (RMMV)' started by Shaz, Jan 14, 2018.

  1. Shaz

    Shaz Veteran Veteran

    Messages:
    35,827
    Likes Received:
    10,121
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Jump to Label
    2018.01.14
    by Shaz

    Introduction
    This plugin provides a more flexible Jump to Label command, where the label can be the result of a formula.

    How to use
    Add plugin to your js/plugins folder - name must be Shaz_JumpToLabel.js.
    Add to plugin manager and set parameter for case sensitivity.
    Enter JumpToLabel as a plugin command, followed by the label, which can be the result of a formula.
    I suggest adding some sort of catch-all after the plugin command, just in case the label couldn't be found - another JumpT o Label (actual event command) to go back to a previous point, or an Exit Event Processing command.

    Example
    JumpToLabel $this._mapId - searches for a label with the current map number
    JumpToLabel $gameParty.leader().name() - searches for a label with actor names
    JumpToLabel $gameVariables.value(3) + $gameVariables.value(4) - searches for a label with the sum of whatever is in variables 3 and 4

    Plugin
    Download from pastebin
    make sure to save it as Shaz_JumpToLabel.js

    Credit
    - Shaz

    Terms
    - free for use in commercial games
    - do not post elsewhere - link back to this page

    Notes
     
    #1
  2. Eliaquim

    Eliaquim Veteran Veteran

    Messages:
    114
    Likes Received:
    17
    Location:
    Brazil - Rio de Janeiro
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    Hey there!
    I'm just curious what can i do with this plugin. I also use the command Label in a test game that i made. I use it in for of substitute for changing pages of an event. Its not the same thing, but, i'm just curious.
    What ideas you have while you are making this plugin?
     
    #2
  3. Shaz

    Shaz Veteran Veteran

    Messages:
    35,827
    Likes Received:
    10,121
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Sure, I'll give you a couple of examples ...

    I have two common events that are set up for all maps - one of them runs when you first enter a map, and one of them runs when you're about to exit. They do things like moving events to certain positions, changing the BGM or the screen tint or the weather depending on what's happened in the game. I do a JumpToLabel this._mapId so it goes to the block of code to be run for the current map. If I don't have any commands for the current map, nothing gets executed. Previously I would create individual events on each map to do this, but sometimes it wasn't convenient to put them all in a default location and I'd lose them, and sometimes I'd get confused between all the pages they had, and sometimes I'd have to have more than one on a map. Putting them all in a single common event means there is ONE place where I have to look for them.

    Another one I've come across a few times is where I want to do a Show Choices, but my choice options are variable, or if I want to check if a group of conditions are met, but want to do different things depending on which are, and which aren't. Let's say I have a quest to bring an apple, a fish and a puppy to a single NPC, and if I've only brought one thing, they will say I need the other two, and if I've brought two things, they'll say I need the other one. I could do this by using a bucketload of IF tests for all the different combinations, or I could do one IF test for each item, and build a string based on the results of the test (something like Apple if I have the apple, then concatenate Fish if I have the fish, then concatenate Puppy if I have the puppy). Using just 3 tests, I'll end up with Apple, Fish, Puppy, AppleFish, ApplePuppy, FishPuppy, or AppleFishPuppy, and can then do a JumpToLabel with the variable I've built. A 3-way check may not be so bad, done with conditional branches, but what if you have 5 or 6 items? Gets a lot more complicated and messy then. But I can do it with just the addition of two or three extra tests, appending to the variable for each one. Then I just create one label for each combination with the appropriate commands.
     
    Last edited: Nov 12, 2018 at 4:20 PM
    #3
    Eliaquim likes this.
  4. Eliaquim

    Eliaquim Veteran Veteran

    Messages:
    114
    Likes Received:
    17
    Location:
    Brazil - Rio de Janeiro
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    HHHHMMMMMMM!!!!
    Makes sense!! I already have come to this difficult making a lot of conditional branches to chek something. Then this will be come in handy! When i make something i will show here!
     
    #4
    Shaz likes this.

Share This Page