Silver: Show Important Local Variables, Extensible Research

Discussion in 'JS Plugins In Development' started by Joy Diamond, Dec 4, 2017.

  1. Joy Diamond

    Joy Diamond Talkative Veteran

    Messages:
    135
    Likes Received:
    172
    First Language:
    English
    Primarily Uses:
    RMMV
    Greetings,

    Summary:
    • This plugin is intended solely to learn JavaScript, not to really use.
    • It is my hope the community will help with the development of this Plugin, thus learning JavaScript together.
    Details:

    A great way of learning is to look at code & print it out the console.
    • That is all this plugin does! :cool:
    • The first version will help teach you the 'Utils' class in RPG Maker MV CoreScript.
    • Future versions will look at other modules to help teach them.
    Output:

    upload_2017-12-3_15-41-4.png

    upload_2017-12-3_15-42-24.png

    Downloadable:
    You can download the plug in from this link: Silver.js
    Version 0.0.1:
    Version 0.0.1 - Partial showing of Util's class from rpg_core.js
    (Will be updated in the future).​

    Please let me know if you would like to learn JavaScript & help with this module.​

    Thanks,

    Joy Diamond.

    Code:
    
    //
    //  Copyright (c) 2017 Joy Diamond.  Licensed under the MIT License.
    //  Copyright (c) 2015 KADOKAWA CORPORATION./YOJI OJIMA.  Licensed under the MIT License.
    //  Silver: Show Important Local Variables, Extensible Research
    //
    //  NOTE:
    //      This copies some code form rpg_core.js which is "Copyright (c) 2015 KADOKAWA CORPORATION./YOJI OJIMA."
    //      Lines that are from rpg_core.js are marked with: // <copied: rpg_core.js />
    //
    (function(){
       "use strict"                                            //  Strict mode helps catch JavaScript errors, very useful!
    
    
       function Silver() {}
    
    
       var Silver = Window.Silver                              //  Create, or reuse, global variable `Silver`
                || (new (function GemModule() {})())
    
    
       Silver.name        = 'Silver'                           //  Name of module
       Silver.version     = '0.0.1'                            //  Version 0.0.1
       Silver.debug       = true                               //  Set Silver debug mode to true
       Silver.debug_clear = true                               //  Only meaningful if .debug is also set
    
    
       //----------------------------------+
       //  Summary: produce module Silver  |
       //----------------------------------+
    
    
       function summary() {
           clear_console()
           cleanup()
           show_Utils()
           development()
           show_version()
       }
    
    
       //----------------------------------+
       //  Details: produce module Silver  |
       //----------------------------------+
    
    
       //  Imports
       var define_property     = Object.defineProperty
       var define_properties   = Object.defineProperties
       var set_prototype_of    = Object.setPrototypeOf
       var create_Object       = Object.create
       var create_Pattern       = RegExp
       var console              = window.console || null
    
    
       //  Copy members from $, to local variables (for code clarity below)
       var $           = Silver                                //  Create easier to read `$` alias for `Silver`
       var debug       = $.debug
       var debug_clear = $.debug_clear
    
    
       //  empty_procedure
       function empty_procedure() {                           //  empty_procedure: does nothing, except avoid errors
       }
    
    
       //  group_closed
       if (console && console.groupCollapsed) {
           var group_closed = function group_closed(/*...*/) {//  group_closed: Easier to type `console.groupCollapsed`
               console.groupCollapsed.apply(console, arguments)
           }
       } else {
           var group_closed = function group_closed(/*...*/) {}
       }
    
    
       //  group_end                    
       if (console && console.groupEnd) {
           var group_end = function group_end() {              //  group_end: Easier to type `console.groupEnd`
               console.groupEnd()
           }
       } else {
           var group_end = function group_start(/*...*/) {}
       }
    
    
       //  group_start
       if (console && console.group) {
           var group_start = function group_start(/*...*/) {   //  group_start: Easier to type `console.group`
               console.group.apply(console, arguments)
           }
       } else {
           var group_start = function group_start(/*...*/) {}
       }
    
    
       //  log
       if (console && console.log) {
           var log = function log(/*...*/) {                   //  Easier to type 'log' instead of 'console.log'
               if (console) {
                   console.log.apply(console, arguments)
               }
           }
       } else {
           var log = function log(/*...*/) {}
       }
    
    
       //  clear_console
       function clear_console() {                              //  Clear console, *IF* in debug mode
           if (debug) {
               if (debug_clear) {
                   if (console) {
                       console.clear()
                   }
               }
           }
       }
    
    
       function group_path(header, path, line_number, comment) {
           if (comment) {
               group_start('%c%s%c: %s %c(from %s, line #%d)%c',
                           'color: green', header, 'color: none',
                           comment,
                           'color: grey', path, line_number, 'color: none')
    
               return
           }
    
           group_start('%c%s%c %c(from %s, line #%d)%c',
                       'color: green', header, 'color: none',
                       'color: grey', path, line_number, 'color: none')
       }
    
       function group_nested(header, line_number, comment) {
           if (comment) {
               group_closed('%c%s%c; %s %c#%d%c',
                            'color: green', header, 'color: none',
                            comment,
                            'color: grey', line_number, 'color: none')
    
               return
           }
    
           group_closed('%c%s%c %c#%d%c',
                        'color: green', header, 'color: none',
                        'color: grey', line_number, 'color: none')
       }
    
    
       function show_value(header, value, line_number, comment) {
           if (comment) {
               log('%c%s%c: %c%s%c; %s %c#%d%c',
                   'color: green', header, 'color: none',
                   'font-weight: bold; color: orange', value, 'font-weight: none; color: none',
                   comment,
                   'color: grey', line_number, 'color: none')
    
               return
           }
    
           if (line_number) {
               log('%c%s%c: %c%s%c %c#%d%c',
                   'color: green', header, 'color: none',
                   'font-weight: bold; color: orange', value, 'font-weight: none; color: none',
                   'color: grey', line_number, 'color: none')
    
               return
           }
    
           log('%c%s%c: %c%s%c',
               'color: green', header, 'color: none',
               'font-weight: bold; color: orange', value, 'font-weight: none; color: none')
       }
    
    
       function show_code(f, line_number)
       {
           group_nested('Code', line_number)
           log(f)
           group_end()
       }
    
    
       //  cleanup
       function cleanup() {
           set_prototype_of(Silver.__proto__, null)
       }
    
    
       //  show_Utils
       function show_Utils() {
           group_path(
               'Utils', 'rpg_core.js', 157,
               'The static class that defines utility methods.'//,                 // <copied: rpg_core.js:157 />
           )
    
           show_value(
               'RPGMAKER_NAME', Utils.RPGMAKER_NAME, 166,
               "The name of the RPG Maker. 'MV' in the current version."//,        // <copied: rpg_core.js:166 />
           )
    
           show_value(
               'RPGMAKER_VERSION', Utils.RPGMAKER_VERSION, 176,
               'The version of the RPG Maker.'//,                                  // <copied: rpg_core.js:176 />
           )
    
           //  isOptionValid
           {
               group_nested(
                   'isOptionValid(name)', 186,
                   'Checks whether the option is in the query string.'//,          // <copied: rpg_core.js:186 />
               )
              
               log("Utils.isOptionValid('test') is used to check if running in debug mode.")
    
               show_value("Utils.isOptionValid('test')", Utils.isOptionValid('test'))
               show_value("Utils.isOptionValid('nonexistent')", Utils.isOptionValid('nonexistent'))
               show_code(Utils.isOptionValid, 193)
               group_end()
           }
    
           //  isNwjs
           {
               group_nested(
                   'isNwjs', 198,
                   'Checks whether the platform is NW.js.'//,                      // <copied: rpg_core.js:198 />
               )
              
               log('Utils.isNwjs is used to check if running under Node WebKit instead of a browser.')
               show_value("Utils.isNwJs()", Utils.isNwjs())
               show_code(Utils.isNwjs, 204)
               group_end()
           }
    
           log('%s %o', 'Utils.prototype:', Utils.prototype)
    
           group_end()
       }
    
    
       //  Development code
       function development() {
       }
    
    
       //  show_version
       function show_version() {
           var begin_font         = 'font-weight: bold'
           var end_color_and_font = 'font-weight: normal; color: none'
    
           log('%c%s%c %c%s%c %o',
               'color: green;  ' + begin_font, $.name,    end_color_and_font,
               'color: orange; ' + begin_font, $.version, end_color_and_font,
               $)
       }
    
    
       //  Finally: Run all the code in `Silver`
       summary()
    })()
    
    
    //--------------------------------------------------------+
    //  This code is formatted for clarity.                   |
    //  Hence this code does not use unnecessary semicolons.  |
    //  Reasoning: https://mislav.net/2010/05/semicolons/     |
    //--------------------------------------------------------+
    
    
    //
    //  The full MIT License, for the code by Joy Diamond, is available here:
    //      https://github.com/Rhodolite/Opal/blob/master/LICENSE
    //
    //  The full MIT License, for the code by 2015 KADOKAWA CORPORATION./YOJI OJIMA, is available here:
    //      https://github.com/rpgtkoolmv/corescript/blob/master/LICENSE
    //
    /*: @plugindesc Show Important Local Variables, Extensible Research */
    
     
    #1
    Jonforum, Poryg and Gamefall Team like this.
  2. Poryg

    Poryg Pixie of the Emvee kingdom Veteran

    Messages:
    2,608
    Likes Received:
    6,105
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    I have to agree, the best way to learn is to circle through code. -that is how I evebtually learned despite knowing just basics of javascript.
     
    #2
    Joy Diamond likes this.
  3. Joy Diamond

    Joy Diamond Talkative Veteran

    Messages:
    135
    Likes Received:
    172
    First Language:
    English
    Primarily Uses:
    RMMV
    Archeia,

    Summary:
    • I am trying to understand to what parts of the code I have a license to, to republish them, *WITHOUT* being part of a game; AND:
    • To which parts do I have a license to republish them, but *ONLY* as part of a game (or marketing for a game).
    Details:

    Regarding the discussion in Official Gacha Plugin Edit I think it's best to continue it here, so I don't end up hijacking the discussion there.

    You wrote:

    It's a good question, so let me explain what I am doing & what I am working on:
    • In the Silver project, I am doing it to teach JavaScript to my real life friends & also to my friends here on RPG Maker Forums.
    • I am publishing silver.js as both:
    • A plugin that works in RPG Maker MV;
    • A standalone JavaScript file that works without RPG Maker MV.
      • This way I can publish it on the web & my friends can quickly see it & play with it
    • I am publishing this on github, as an open source project, hence my current understanding is I can only publish resources that I have a license to use outside of a game.
    For example in the current silver.js, I have copied code from rpg_core.js & carefully documented that I have the right to do this according to the MIT License for RPG Maker MV CoreScript:

    upload_2017-12-7_21-55-27.png

    upload_2017-12-7_21-54-21.png

    upload_2017-12-7_21-56-45.png

    Now I want to extend the Silver project to cover the following:
    • nw.js -- The main "brower" engine that is used on Windows to run the game runs in.
    • pixi.js -- The 2d Rendering engine that display's the game in the HTML5 canvas (or WebGL)
    • Parts of JavaScript;
    • The rest of rpg_*.js
    • And also:
    What license do I have to Gacha?

    Thus, I am trying to understand what kind of license do I have to the Gacha plugin?
    • I fully understand that I "can use it commercially and edit it".
    • I don't understand if that is limited to only within a game (like game assets are), or if I can use it outside a game, publish it on github as part of the Silver project.
    My current sense is it's a mixture of both:
    • The *.js is probably usable outside of a game;
    • The game assets (i.e.: the cards) can only be used inside a game.
    My understanding of the RPG Maker MV EULA (End User License Agreement)

    As I understand it, the RPG Maker MV EULA (End User License Agreement) grants me the following (since I purchased a license to it):
    • (1) The right to use the tool to create games;
    • (2) The right to use game assets, but *ONLY* in games created with the RPG Maker MV tool (and also limited rights to use the game assets for marketing my game).
    The game itself, however, has a different license(s):
    • (3) rpg_*.js is part of RPG Maker MV CoreScript, and has a MIT License -- so I can copy that into my Silver.js project for documentation & publish silver.js as a plugin outside of game.
    • (4) All sorts of other parts of the game, like nw.js & pixi.js each have their own licenses ...
    Conclusion:

    Is the license I have to Gacha #2 (only inside a game) or #3 (outside a game)

    In particular I am trying to determine the license to:

    • js/plugins/Gacha.js
    • js/plugins/GachaBook.js
    • samples/Gacha Sample/img/gacha/card01.png
    • samples/Gacha Sample/img/gacha/card02.png
    • samples/Gacha Sample/img/gacha/card03.png
    • samples/Gacha Sample/img/gacha/card04.png
    • samples/Gacha Sample/img/gacha/card05.png

    The answer to the above question determines:
    • Can I edit & work on Gacha.js & GachaBook.js collaboratively with other people using github?
    • Can I document the Gacha.js & GachaBook.js as part of the Silver project?
    • Will I help Sissel Cabenala with the changes she wants to Gacha.js? (which is much more likely if I can do it with the above two bullet points).
    Hopefully this explains what I am trying to do, and why I am concerned about licensing do much.

    Sincerely,

    Joy Diamond.
     
    #3
  4. Archeia

    Archeia Level 99 Demi-fiend Staff Member Developer

    Messages:
    13,915
    Likes Received:
    12,724
    Location:
    Game Dev Salt Mines
    First Language:
    Filipino
    Primarily Uses:
    VNM
    You can only use it in RPG Maker.
     
    #4
    Joy Diamond likes this.
  5. Joy Diamond

    Joy Diamond Talkative Veteran

    Messages:
    135
    Likes Received:
    172
    First Language:
    English
    Primarily Uses:
    RMMV
    Thanks for the clarification, much appreciated :smile:
    • I will avoid including any of Gacha in the Silver project.
     
    #5
  6. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,468
    Likes Received:
    1,181
    Location:
    Canada / Qu├ębec
    First Language:
    French
    Primarily Uses:
    RMMV
    very pretty and clean. i take it , i very like it.

    just some sugest here for fun.
    *avoid clear() console at start, this remove custom console.log registered when booting.
    * maybe add PIXI.settings and global window (i know its huge but..:beard)
    * to be even more user-friendly, there is also the method console.tab, it can be cool in some case.

    [​IMG]

    :rock-left:
     
    #6

Share This Page