RPG Maker MV Cook Tool

Discussion in 'Useful Development Tools' started by AceOfAces_Mod, Sep 26, 2018.

  1. AceOfAces_Mod

    AceOfAces_Mod Engineering to infinity! Veteran

    Messages:
    1,646
    Likes Received:
    1,075
    First Language:
    Greek
    Primarily Uses:
    RMVXA
    What is this?
    This tool automates the compilation of JavaScript files with NW.js' compiler. The compiler creates binary versions of the files, ensuring protection of the source code. The tool also packages the code (and the assets) on an archive that Nw.js can read.

    How do I use it?
    First of, you'll need to do a few modifications to the project. I've included the replacement code you need to apply to your project (after deploying it, of course). After that, it's pretty simple: Tell the tool where the nwjc.exe file is (RPG Maker MV has the SDK as well, which includes nwjc, but you can download a different version from https://nwjs.io) and the project you want to compile. In a few minutes, you can upload the game to the public.

    Do note: once you compile it, you can only use the same version of nwjs for the same operating system. So, if you compiled the game with SDK Version 0.30.4 (for example) on Windows, you can only use the code with Standard Version 0.30.4 on Windows.

    System Requirements:
    Windows 7 Service Pack 1 or newer.

    Microsoft .NET Framework 4.7.2

    Any computer that can run RPG Maker MV games, practically speaking.

    NW.js SDK. You can use any version you want (preferably 0.22.x or newer (RPG Maker MV 1.6.1 ships with 0.29.0), as 0.21.x and older have a bug where the compiled versions ran 30% slower).

    FAQ:
    Can I use it on Linux with WINE (or Proton or <insert a compatibility layer here>)?
    Depends. If it is to make the Windows version of your game, then yes (assuming that it can run .NET Framework apps). If you want to use the tool to make the Linux version, then no. You can use the Console App.

    Can I use it on my current project?
    The tool is a wrapper for the nwjc. I have used the tool for my project and I haven't noticed any issues. So, it has a "go-live" license (as in, it's OK to use it on your projects).

    Screenshots:
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]

    Video tutorial:

    Download:
    itch.io
    Gumroad
    Microsoft Store

    Source Code
     
    Last edited: Dec 7, 2018
    #1
  2. mlogan

    mlogan Global Moderators Global Mod

    Messages:
    12,713
    Likes Received:
    6,931
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV
    So this is an encryption tool? Just trying to understand what it is supposed to do.
     
    #2
  3. AceOfAces_Mod

    AceOfAces_Mod Engineering to infinity! Veteran

    Messages:
    1,646
    Likes Received:
    1,075
    First Language:
    Greek
    Primarily Uses:
    RMVXA
    @mlogan , quoting the nwjs documentation:

    "The JavaScript source code of your application can be protected by compiling to native code and loaded by NW.js. You only have to distribute the compiled code with your app for production."

    So... it's like compiling an app written in C++. Making the source code you wrote to work on a computer. Except that it's readable by nwjs only. It's not encryption, but it helps to protect the game's source code.

    EDIT: Yes, it does protect the game's source code, but it's not the same as encryption.
     
    Last edited: Sep 26, 2018
    #3
  4. Poryg

    Poryg Pixie of the Emvee kingdom Veteran

    Messages:
    2,893
    Likes Received:
    6,683
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    @mlogan It's compilation of Javascript code into nw.js bytecode. Each version of nw.js also uses a slightly different compilation, so as a result the finished files are neither cross-platform nor cross-version compatible as mentioned in the OP. It's an additional layer of security, which also doesn't leave <script> tags inside dev tools, making html files more secure, although due to the open source nature of nw.js it's not that hard to break into the code.

    It'd be better to mention it as a warning that prior to nw.js 0.22.x (effectively prior to rpg maker mv 1.6.x) it's not advised to use, because the execution speed of the compiled code is only 30% compared to the later versions (where this issue has been rectified).
     
    #4
  5. AceOfAces_Mod

    AceOfAces_Mod Engineering to infinity! Veteran

    Messages:
    1,646
    Likes Received:
    1,075
    First Language:
    Greek
    Primarily Uses:
    RMVXA
    Got it.
     
    #5
  6. TakeHomeTheCup

    TakeHomeTheCup Veteran Veteran

    Messages:
    241
    Likes Received:
    443
    First Language:
    English
    So, does it make our games run or load up faster?
     
    #6
  7. AceOfAces_Mod

    AceOfAces_Mod Engineering to infinity! Veteran

    Messages:
    1,646
    Likes Received:
    1,075
    First Language:
    Greek
    Primarily Uses:
    RMVXA
    Unfortunately, no. nwjs' compilation doesn't optimize the games. The implementation is simply a security layer. However, you can optimize the game's JS files with tools (such as Google's Closure compiler) before running the tool, optimizing the assets and enabling some chromium flags by inserting this to package.json:
    Code:
        "chromium-args": "--enable-gpu-rasterization --enable-gpu-memory-buffer-video-frames --enable-native-gpu-memory-buffers --enable-zero-copy --enable-gpu-async-worker-context",
    
    Although ANGLE (Google's implementation of WebGL support) can apply workarounds which will result in slower performance.

    One thing to note as well: if the game runs on version 1.5.2 or older, you'll have to use a newer version of nwjs. There's a bug where the game will run slower when the compiled JS files are used.
     
    #7
  8. AceOfAces_Mod

    AceOfAces_Mod Engineering to infinity! Veteran

    Messages:
    1,646
    Likes Received:
    1,075
    First Language:
    Greek
    Primarily Uses:
    RMVXA
    I released the update a few days ago. I wanted to make a video as well to show of the changes, but I scrapped it.

    Changelog:
    • Re-worked Compiler logic.
    • Vastly improved compilation times.
    • Automatic removal of the binaries.
    • Improved UI.
      • Both the Quick and Batch compiling show which file is being compiled at the moment.
    • Minor bug fixes and tweaks.
    • Moved part of the logic to a separate library.
    Known issues
    • The UI locks up when compiling.
    I've also included an experimental version of the Console App of the tool as well. This was written in .NET Core and it runs on both Linux and Windows (sorry Mac users, but I don't have a Mac to test it. So... you can try compiling the code on Github). The tool works (at least on Windows and in the Windows Subsystem for Linux) but it lacks the command line arguments (which I'll add in at a later date).

    Quick note: Gumroad doesn't have the Console App.
     
    #8
  9. Tuomo L

    Tuomo L Oldbie Veteran

    Messages:
    2,237
    Likes Received:
    1,169
    Location:
    Finland!
    First Language:
    Finnish
    Primarily Uses:
    RMMV
    Does this work with Dragonbones? I get errors when I try and use dragonbones with it.
     
    #9
  10. AceOfAces_Mod

    AceOfAces_Mod Engineering to infinity! Veteran

    Messages:
    1,646
    Likes Received:
    1,075
    First Language:
    Greek
    Primarily Uses:
    RMVXA
    @Tuomo L , did you do the necessary edits to the project after deploying? If it isn't done right, the game may fail to load and show error. Check if the rpg_managers.js and index.html files are edited correctly. If they still don't work, can you send me a screenshot of the errors?
     
    #10
  11. Tuomo L

    Tuomo L Oldbie Veteran

    Messages:
    2,237
    Likes Received:
    1,169
    Location:
    Finland!
    First Language:
    Finnish
    Primarily Uses:
    RMMV
    I am sure that I did but as soon as I boot

    Uncaught ReferenceError: dragonBones is not defined
     
    #11
  12. AceOfAces_Mod

    AceOfAces_Mod Engineering to infinity! Veteran

    Messages:
    1,646
    Likes Received:
    1,075
    First Language:
    Greek
    Primarily Uses:
    RMVXA
    Now, this is a speculation, but you may have not included the DragonBones libraries in the index.html file. The Dragonbones plugin needs two libraries to be loaded. Check if the two libraries (dragonBones and dragonBonesPixi) are in the index.html. If they aren't, insert this bit of code underneath the pixi-pictures line:
    Code:
    <script>nw.Window.get().evalNWBin(null, "www/js/libs/dragonBones.bin");</script>
    <script>nw.Window.get().evalNWBin(null, "www/js/libs/dragonBonesPixi-.bin");</script>
    
     
    #12
  13. Isabella Ava

    Isabella Ava Veteran Veteran

    Messages:
    579
    Likes Received:
    644
    First Language:
    English
    @AceOfAces_Mod how safe is this method? Can someone with advance knowledge may reverse it?
     
    #13
  14. AceOfAces_Mod

    AceOfAces_Mod Engineering to infinity! Veteran

    Messages:
    1,646
    Likes Received:
    1,075
    First Language:
    Greek
    Primarily Uses:
    RMVXA
    @Isabella Ava , I can't say for sure. The most dedicated hackers will defeat any encryption. The compiler itself (nwjc, to be exact) works as an additional layer of protection. It is pretty safe, but since nwjs is open source, it wouldn't take a long time to figure out how to reverse engineer. That is, if they know that the game is wrapped with nwjs.
     
    #14
  15. AceOfAces_Mod

    AceOfAces_Mod Engineering to infinity! Veteran

    Messages:
    1,646
    Likes Received:
    1,075
    First Language:
    Greek
    Primarily Uses:
    RMVXA
    And a new update is live:

    Core:
    Changelog:
    • Moved the packaging code to the core library.
    • Slight tweaks.
    UI
    Changelog:
    • Added the option to test the game after compiling.
    • Added the option to remove the game's files after packaging.
    • Added Greek Translation.
    • Added code to prevent crashing (or unintended behavior) by locking the settings when workload is done.
    • UI fixes.
    Known Issues:
    • The UI locks up during compilation.

    CLI
    Changelog:
    • Added the option to test a game.
    • Added the option to package the game (along with removing the files after packaging).
    Known issues:
    • Linux: Some files aren't compiled. Possibly an issue with the parallel loop on Linux?

    EDIT: This just in: The tool is now on the Microsoft Store.
     
    Last edited: Dec 7, 2018
    #15
  16. Tuomo L

    Tuomo L Oldbie Veteran

    Messages:
    2,237
    Likes Received:
    1,169
    Location:
    Finland!
    First Language:
    Finnish
    Primarily Uses:
    RMMV
    Nope, I made sure to include it and literally copy pasted that too and dragonbones gets the error.

    EDIT: Huh, redoing it again after the update did fix it after 2nd try.
     
    Last edited: Dec 10, 2018
    #16
  17. Poryg

    Poryg Pixie of the Emvee kingdom Veteran

    Messages:
    2,893
    Likes Received:
    6,683
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    @Isabella Ava This method by itself would be much safer if MV didn't use NWjs version XYZ.
    The compiler will cut out not only cross platformingness of the app, but also the cross version compatibility. The reason is, every version of NWjs compiles the files under a different key (not sure if they also use a slightly different procedure) for additional security. Of course someone advanced or even someone with the knowledge of the program will be able to figure out the solution. However, you can never stop people from being able to break through your game, that's what you need to remember. If nothing else, I can always mess with the game inside memory, which however requires knowledge of low level languages and possibly understanding of assembler.
    So I would say it's safe against a normal mortal. But I advise you to update the nwjs app to a non-MV version for additional security.
     
    #17

Share This Page