console.log() is the best script!

Discussion in 'RPG Maker MV Tutorials' started by Internetomancer, Mar 3, 2016.

  1. Internetomancer

    Internetomancer Veteran Veteran

    Likes Received:
    First Language:
    Hello!  :)

    I'm pretty new here.  I just wanted to point out to other newbies the most useful newbie thing I've learned:

    The console is [SIZE=12.8px]essential for:[/SIZE]

    1) writing code.

    2) debugging code

    3) play-testing any game.

    You can get to the console anytime while playing by pressing f8.
    For now, I suggest you look at it in a Battle Test...

    (Click on game database, then on troops, then at the top right there's the battle test button that let's you do pretend battles)

    Then press f8 and there's the console.

    You should see a > cursor where you can type things.

    Type:      console.log($

    At this point you'll see a little drop down list.

    Some of the things on the list will begin $data; like $dataItems   or  $dataMonsters... these are permanent things in your database.

    Other things will begin $game -- like $gameParty or $gameTroop or $gameVariables... these are things going on in your current game-- like who's in your party right now, and who are the monsters that you're fighting right now.

    But for now, just go with.   console.log($gameTroop)   And press enter.  And don't forget to add the ")"  

    You'll see something that looks like nonsense.

    Now click on that line somewhere with your mouse...

    And you'll get something like this:

    Which still looks like nonsense....

    But you'll notice a couple things--

    _troopId: is the Id of the troop you're fighting.

    _TurnCount is what turn it is.

    Go ahead on click where it says  >enemies: Array[]

    And again you'll get a drop down...


    These are the enemies you're fighting right now.

    Go ahead and click on one.

    And boom, a whole lot of details!!!  Including all the stats, and states, and everything!

    Next, you can also skip the above steps if you type something like this:

    Basically, each time you want to dig deeper, just add a period, and then type in the next part.

    (By the way, if you hit the up arrow, on an empty console box, you'll see the last thing you just typed.  Which is makes the whole typing thing go a lot faster!)

    "Okay.. neat... but what do I do with this?"  I hear you say.

    Well for one thing you can see some data that aren't visible to the player, like the monster MP.  

    (also any $gameVariables, $gameSwitches, other variables, arrays, plugins, invisible states, etc. etc..  ie. anything funky you do behind the scenes.)

    So if in your game, you hit a switch but you need to know if that switch is actually hit, this will tell you.

    It's also a great first step to writing code, because now you know the names of all the variables!  
    Anything you write in your console, you can also write in an event script.  And anything you write in an event script, can also be written in the console.  They both just execute code.

    So for example if you type in the console (or an event script):

    The first enemy will suddenly have 5 hp.  Which is great if your sitting around punching an enemy and you want to get to the next part.

    If you combine this with the most basic java script knowledge-- if(){}... for(){}.. you'll be able to do whatever you want!

    [SIZE=12.8px]So for example, maybe you could add that to a common event script that runs every round, and now you get to know how much life your enemies have every round.[/SIZE]


    Now during a play-test you don't have to wait to the end of the battle to see how you're doing.

    In other words-- with a tiny bit of scripting skill-- you can give yourself a sort of God Mode, allowing you to test everything in the game without having to slog through the whole game.
    Last edited by a moderator: Mar 13, 2016
    activspam, boomy, Astfgl66 and 4 others like this.
  2. bmwd Gaming

    bmwd Gaming Villager Member

    Likes Received:
    First Language:
    I've heard of the console.log but never knew anything about it. I will have to play around with it and learn more on JavaScripting, but it definitively helps further my understand. Thank you for this.
  3. Tenaar Feiri

    Tenaar Feiri Warper Member

    Likes Received:
    First Language:
    Thanks a lot for posting this!

    This is going speed up learning to script for this engine a ton! Figuring out variables to target for specific things will become much easier!
    Last edited by a moderator: May 1, 2016
  4. Crispy-Ghee

    Crispy-Ghee The Crispy One Veteran

    Likes Received:
    First Language:
    Thanks for the info! This is going to be super useful in really getting to understand the RPG Maker engine code. This is great

    ACECORP Founder & Entrepreneur Veteran

    Likes Received:
    First Language:
    Primarily Uses:
    Does this also work for IOS exported games, by writing to the IOS Console? It would be great to be able to use a iPhone tool like iConsole to see RPGMMV errors and console messages in IOS. Very good for bug testing an IOS build.
    Last edited by a moderator: Jul 13, 2016
  6. Skunk

    Skunk Melody Master Veteran

    Likes Received:
    The Island
    First Language:
    Primarily Uses:

    This is intended only for during game development, and this is an ooold post.
    "necro posting" is against forum rules.

Share This Page