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,699
    Likes Received:
    1,152
    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.
    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: Sep 25, 2019
    #1
    monolette, atoms, Dreadshadow and 6 others like this.
  2. mlogan

    mlogan Global Moderators Global Mod

    Messages:
    13,795
    Likes Received:
    7,616
    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
    atoms likes this.
  3. AceOfAces_Mod

    AceOfAces_Mod Engineering to infinity! Veteran

    Messages:
    1,699
    Likes Received:
    1,152
    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
    atoms likes this.
  4. Poryg

    Poryg Dark Lord of the Castle of Javascreeps Veteran

    Messages:
    3,927
    Likes Received:
    9,917
    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
    atoms and Acetonide like this.
  5. AceOfAces_Mod

    AceOfAces_Mod Engineering to infinity! Veteran

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

    TakeHomeTheCup Veteran Veteran

    Messages:
    242
    Likes Received:
    458
    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,699
    Likes Received:
    1,152
    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,699
    Likes Received:
    1,152
    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,291
    Likes Received:
    1,262
    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,699
    Likes Received:
    1,152
    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,291
    Likes Received:
    1,262
    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,699
    Likes Received:
    1,152
    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:
    635
    Likes Received:
    751
    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,699
    Likes Received:
    1,152
    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,699
    Likes Received:
    1,152
    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,291
    Likes Received:
    1,262
    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 Dark Lord of the Castle of Javascreeps Veteran

    Messages:
    3,927
    Likes Received:
    9,917
    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
  18. AceOfAces_Mod

    AceOfAces_Mod Engineering to infinity! Veteran

    Messages:
    1,699
    Likes Received:
    1,152
    First Language:
    Greek
    Primarily Uses:
    RMVXA
    Released a new update:

    UI
    • Minor text fix.
    CLI
    Changelog:
    • Command Line Arguments have been added.
    • The compiler will compile in serial mode (you can compile in parallel mode by adding the –Parallel command line argument).
    • Slight Text improvements.
    • Switched to .NET Core 2.2.
    • Fixed a bug where the compiler would compress the files, even though the user asked not to.
    Known issues:
    • In Parallel mode, some files aren’t processed correctly on Linux.

    I'll post a tutorial video on how to use the command line arguments. For now, here's a quick how-to:
    To compile the project: nwjsCookToolCLI.exe --SDKLocation "<put the location of the SDK here>" --ProjectLocation "<put the location of the project here>"
    Or in Linux: ./nwjsCookToolCLI --SDKLocation "<put the location of the SDK here>" --ProjectLocation "<put the location of the project here>"
    (Yes, you need the quotes there.)

    Command Line Arguments:
    --SDKLocation: Sets the location of the SDK.
    --ProjectLocation: Sets the location of the project.
    --FileExtension: Sets the File Extension for the compiled files. It's used like this: --FileExtension <insert file extension here>
    --Parallel: Turns on Parallel mode. You can use it without the previous two arguments as well.
    --ReleaseMode: Removes the JavaScript files after compiling.
    --CompressProject: Compress project after compiling. "--CompressProject Final" (without quotes) removes the files after compression. Only works with the ReleaseMode flag.
    --TestMode: Test the game after compiling. Cannot work when the CompressProject argument is in place.
     
    #18
  19. AceOfAces_Mod

    AceOfAces_Mod Engineering to infinity! Veteran

    Messages:
    1,699
    Likes Received:
    1,152
    First Language:
    Greek
    Primarily Uses:
    RMVXA
    I released a new update for the tool. It adds the option to cancel the compilation and it improves the code that handles the UI updates, thus eliminating the lock-ups during the compilation.

    And the command line version skips the wait for pressing Enter/Return to exit if you started compiling via command line arguments.
     
    #19
  20. AceOfAces_Mod

    AceOfAces_Mod Engineering to infinity! Veteran

    Messages:
    1,699
    Likes Received:
    1,152
    First Language:
    Greek
    Primarily Uses:
    RMVXA
    I am pretty close to release a new update to the tool. The UI version will have a built-in tool to edit the game's package.json. You can adjust aspects of NW.js (such as the game's resolution, turning on/off NodeJS and others). Here's the demo of it:


    And there's now the option to adjust the compression of the package.
     
    #20

Share This Page