Original Source
- Original title: Silver: Show Important Local Variables, Extensible Research
- Original author: Joy Diamond
- Original date: December 3, 2017
- Source thread: https://forums.rpgmakerweb.com/threads/silver-show-important-local-variables-extensible-research.88046/
- Source forum path: Game Development Engines > RPG Maker Javascript Plugins > JS Plugins In Development
Summary
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.
Archived First Post
- 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.
- That is all this plugin does!
- 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.
(Will be updated in the future).
Thanks,
Joy Diamond.
//
// 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 */
Downloads / Referenced Files
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadLicense / Terms Note
// 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 //
Creator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
Topic Summary
Loading summary...