LOGIN
SEARCH
PROFILE
keys: ↑ ↓
LOGOUT
INDEX
MEMBERS
keys: ↑ ↓
HOME
PORTAL
PLAY ALONG
PLAY with WORDS
PLAY with GRAPHICS
PLAY with SOUNDS
PLAY with CODES
PLAY with PROJECTS
keys: ← →
Guest Access
Register:
Members:



View previous topic View next topic Go down Message [Page 1 of 1]

Administrator
Administrator
#1 RMMV - Plugin Sample
Loading

G@MeF@Ce

Administrator
Administrator
Administrator
profile
For those of you who are excited for RMMV and to all of you who play with code,
here's a sample of a javascript plugin:

Code:

/*
* adjust height, width, and position of command prompt in title_scene
*/

(function () {
 var parameters = PluginManager.parameters['TitleCommandPosition'];
 var offsetX = Number(parameters['Offset X'] || 30);
 var offsetY = Number(parameters['Offset Y'] || 30);
 var width = Number(parameters['Width'] || 240);
 var background = Number(parameters['Background'] || 0);

 var _Window_TitleCommand_updatePlacement = Window_TitleCommand.prototype.updatePlacement

 Window_TitleCommand.prototype.updatePlacement = function () {
 _Window_TitleCommand_updatePlacement.call(this);
 this.x = offsetX;
 this.y = offsetY;
 this.setBackgroundType(background);
 };

 Window_TitleCommand.prototype.windowWidth = function () {
 return width;
 };

})();

If you are interested in learning some basic javascript, go here ~> CA.JS

This official tutorial video displays how to install a plugin into your project



When RMMV launches on the 23rd of this month, there will be over 40 plugins made by scripters from the RPG Maker community who had the privilege to work with the beta of RPG Maker MV.

From what I gathered, there are a lot of programmers who are disappointed with the switch from ruby to js, but I must say cross platform and speed has got me pumped for projects! This will also bring Mac and PC users into the same maker community to make games for just about every device and browser that supports HTML5 +
Administrator
https://www.dropbox.com/sh/i47rig99qhrvn8s/4m5HvsM2fD http://g4m3f4c3.deviantart.com https://www.facebook.com//pages/Gameface101/332331300127008 https://twitter.com//mr_gameface101 https://soundcloud.com/schurr http://www.youtube.com/user/MrGameface101?feature=watch
EVENTALIST
EVENTALIST
#2 Re: RMMV - Plugin Sample
Loading

mr_wiggles

EVENTALIST
 EVENTALIST
EVENTALIST
profile
Going to do some reading myself. Smile
EVENTALIST
Show Signature
EVENTALIST
Administrator
Administrator
#3 Re: RMMV - Plugin Sample
Loading

G@MeF@Ce

Administrator
Administrator
Administrator
profile
mr_wiggles wrote:Going to do some reading myself. Smile
we need WABS and XPLAT for our RMMV projects <3:+:

13 out of 37 plugins have been revealed


lots of questions answered
Administrator
https://www.dropbox.com/sh/i47rig99qhrvn8s/4m5HvsM2fD http://g4m3f4c3.deviantart.com https://www.facebook.com//pages/Gameface101/332331300127008 https://twitter.com//mr_gameface101 https://soundcloud.com/schurr http://www.youtube.com/user/MrGameface101?feature=watch
EVENTALIST
EVENTALIST
#4 Re: RMMV - Plugin Sample
Loading

mr_wiggles

EVENTALIST
 EVENTALIST
EVENTALIST
profile
In your example plugin, what is the purpose of the "()" block at the end?
Code:
})();

Could it be?
Code:
});

What purpose does that block serve? Still haven't done much reading into Java waiting on getting my hands on MV.

Been playing in the tutorial, picked java up fairly fast, took about 20 mins to get to this part in the tutorial. https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/1/4?curriculum_id=506324b3a7dffd00020bf661
Code:

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
 computerChoice = "rock";
} else if(computerChoice <= 0.67) {
 computerChoice = "paper";
} else {
 computerChoice = "scissors";
};

console.log("Computer: " + computerChoice);

var compare = function(choice1, choice2) {
  if (choice1 === choice2) {
    return "The result is a tie!";
  } else if (choice1 === "rock") {
      if (choice2 === "scissors") {
          return "rock wins";
      } else {
          "paper wins";
      };
  } else if (choice1 === "paper") {
       if (choice2 === "rock") {
          return "paper wins";
      } else {
          "scissors wins";
      };
  } else if (choice1 === "scissors") {
       if (choice2 === "paper") {
          return "scissors wins";
      } else {
          "rock wins";
      };
  };
};

console.log(compare(userChoice, computerChoice))
EVENTALIST
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
#5 Re: RMMV - Plugin Sample
Loading

mr_wiggles

EVENTALIST
 EVENTALIST
EVENTALIST
profile
It is not very far off from ruby from what I'm seeing so far, this is going to be fun.
EVENTALIST
Show Signature
EVENTALIST
Administrator
Administrator
#6 Re: RMMV - Plugin Sample
Loading

G@MeF@Ce

Administrator
Administrator
Administrator
profile
remember there's a difference between java and javascript

with javascript parenthesis are mainly used for execution/self-execution for a function or expres​sion(similar to an argument) here a great reference on stackoverflow

http://stackoverflow.com/questions/440739/what-do-parentheses-surrounding-a-javascript-object-function-class-declaration-m
Administrator
https://www.dropbox.com/sh/i47rig99qhrvn8s/4m5HvsM2fD http://g4m3f4c3.deviantart.com https://www.facebook.com//pages/Gameface101/332331300127008 https://twitter.com//mr_gameface101 https://soundcloud.com/schurr http://www.youtube.com/user/MrGameface101?feature=watch
EVENTALIST
EVENTALIST
#7 Re: RMMV - Plugin Sample
Loading

mr_wiggles

EVENTALIST
 EVENTALIST
EVENTALIST
profile
so, its basically the same as
Code:
var example = funtion() {
console.log("executed this with assistance of a call.");
};
example();

Code:
(function() {
console.log("executed this with out the need for a call.")
})();

The "()" is the call for the expression.

No?

[edited] ----------------

I read some more and it seems to help with scoping when using variables and other names.
Code:
var add_gen = function(n) {
  return function(x) {
    return n + x;
  };
};
var add2 = add_gen(2);
add2(3); // result is 5

Pulled from the page you linked, it, to me, looks like a class in a class like how modules are used in Ruby. Its like the first arguments are the "initialize" ones. So "add_gen" is function set out side call anonymous inside function. Picturing it as an array in a way as well. So would this:
Code:
var add_break = add2(3); // result will always be 5 when variable add2 is called, and can not be called with an argument anymore.

So you can potentially make functions in classes, classes themselves wrapped in layers? like a hand off if you wanted to, or by accedent?
Code:

var test = function(num1) {
  function(num2) {
     function(num3) {
      return (num3 + num2 + num1);
    };
  };
};
var layer1 = test(1);
var layer2 = layer1(2);
var layer3 = layer2(3);
var inside_function_layer3 = layer3;

Trying to see how that would be useful, course this isn't related anymore just thinking out loud.
[/edited]
EVENTALIST
Show Signature
EVENTALIST
Administrator
Administrator
#8 Re: RMMV - Plugin Sample
Loading

G@MeF@Ce

Administrator
Administrator
Administrator
profile
yep top code you have set your variable and it's function (similar to defining a method)
and called it at the end

bottom code you basically made a self-executing function

wiggles you are getting me excited +
Administrator
https://www.dropbox.com/sh/i47rig99qhrvn8s/4m5HvsM2fD http://g4m3f4c3.deviantart.com https://www.facebook.com//pages/Gameface101/332331300127008 https://twitter.com//mr_gameface101 https://soundcloud.com/schurr http://www.youtube.com/user/MrGameface101?feature=watch
EVENTALIST
EVENTALIST
#9 Re: RMMV - Plugin Sample
Loading

mr_wiggles

EVENTALIST
 EVENTALIST
EVENTALIST
profile
I'm excited to start programming some stuff. Very Happy
EVENTALIST
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
#10 Re: RMMV - Plugin Sample
Loading

mr_wiggles

EVENTALIST
 EVENTALIST
EVENTALIST
profile
I was playing around with it today, been crash coursing threw Java script. Here is what i have thrown together so far, just getting use to the new syntax.

Code:
//=============================================================================
// Sample.js
//=============================================================================
/*   Author: Mr_Wiggles
 *   Date: 10/23/15
 *   Version: 0.0
 * ----------------------------------------------------------------------------
 *  Object.create java information.
 *  https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create
 */ //=========================================================================

//----------------------------------------------------------------------------
// Auto run: Sets plugin items that are user defined in RMMV.
//----------------------------------------------------------------------------
(function() {
    var parameters = PluginManager.parameters('Sample'); // Define plugin name.
    // Set interactive variable settings to show in plugin manager.
    var sampleSetting = String(parameters['Sample Setting'] || 'Defualt value');
    //------------------------------------------
    // Define plugin commands that are called from event task.
    //------------------------------------------
    var _Game_Interpreter_pluginCommand =
            Game_Interpreter.prototype.pluginCommand;
    // add in custom flags for your plugin.        
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
      _Game_Interpreter_pluginCommand.call(this, command, args);
      if (command === 'eventSamplePluginCommand') {
        switch (args[0]) {
        case 'commandOne':
          // For an example, calling the scene is something that can be done here.
          SceneManager.goto(Scene_Sample);
          break;
        }
      }
    };
//----------------------------------------------------------------------------
// Scene Sample
//----------------------------------------------------------------------------
    function Scene_Sample() { // Set function call initialize before object is created.
      this.initialize.apply(this, arguments);
    }
    // Inherit parrent class functions.
    Scene_Sample.prototype = Object.create(Scene_Base.prototype);
    Scene_Sample.prototype.constructor = Scene_Sample;
    //------------------------------------------
    // Define funtion initialize for Scene_Sample.
    //------------------------------------------
    Scene_Sample.prototype.initialize = function() {
      Scene_MenuBase.prototype.initialize.call(this); // *super()
      // create variables before class object creation.
    };
    //------------------------------------------
    // This is java's object "initialize" and is ran when
    // the object is registered with the GC.
    //------------------------------------------
    Scene_Sample.prototype.create = function() {
      Scene_Base.prototype.create.call(this); // *super()
     // create variables after initialize.
    };
    //------------------------------------------
    // Example on returning scene to game map.
    //------------------------------------------
    Scene_Sample.prototype.returnToMap = function() {
      this.fadeOutAll();
      SceneManager.goto(Scene_Map);
    };
//----------------------------------------------------------------------------
// Window Sample
//----------------------------------------------------------------------------
    function Window_Sample() { // Set function call initialize before object is created.
        this.initialize.apply(this, arguments);
    }
    // Inherit parrent class functions.
    Window_Sample.prototype = Object.create(Window_Base.prototype);
    Window_Sample.prototype.constructor = Window_Sample;
    //------------------------------------------
    // (initialize) for Window_Sample.
    // Args*
    //   (x) = X window pos.
    //   (y) = Y window pos.
    //------------------------------------------
    Window_Sample.prototype.initialize = function(x, y) {
        var width  = 32;
        var height = 32;
        Window_Base.prototype.initialize.call(this, x, y, width, height); // *super()
        this.refresh(); // refresh window contients.
    };
    //------------------------------------------
    // (update) for Window_Sample.
    //------------------------------------------
    Window_Sample.prototype.update = function() {
        Window_Base.prototype.update.call(this); // *super()
        // do update procedures for object variables.
    };
    //------------------------------------------
    // (refresh) for Window_Sample.
    //------------------------------------------
    Window_Sample.prototype.refresh = function() {
        this.contents.clear();
        this.drawActorName(actor, x, y + lineHeight * 0, width);
        this.drawActorHp(actor, x, bottom - lineHeight * 3, width);
        this.drawActorMp(actor, x, bottom - lineHeight * 2, width);
    };
//=============================================================================
})(); // End of plugin block.

NOTE: I wasn't able to get around to adding in the exit function, its there but its never called in the script so there is no way out of the scene when called. Just wanted to share what i got done today. Smile

Still learning, I'll work on finishing up a nice sample script for creating plugins in the end though, especially when I have a helpful community like this one.
EVENTALIST
Show Signature
EVENTALIST
Administrator
Administrator
#11 Re: RMMV - Plugin Sample
Loading

G@MeF@Ce

Administrator
Administrator
Administrator
profile
right on wiggles, I'm still studying the main scripts in the js folder:
-main
-plugins
-rpg_core
-rpg_managers
-rpg_objects
-rpg_scenes
-rpg_sprites
-rpg_windows
-titlecommandposition

just to see what objects (similar to ruby classes) are being called and configured.

Administrator
https://www.dropbox.com/sh/i47rig99qhrvn8s/4m5HvsM2fD http://g4m3f4c3.deviantart.com https://www.facebook.com//pages/Gameface101/332331300127008 https://twitter.com//mr_gameface101 https://soundcloud.com/schurr http://www.youtube.com/user/MrGameface101?feature=watch
EVENTALIST
EVENTALIST
#12 Re: RMMV - Plugin Sample
Loading

mr_wiggles

EVENTALIST
 EVENTALIST
EVENTALIST
profile
Yea i haven been reading how the events are managed. The update loop for scenes seems to be in the 'SceneManager' object, haven't looked at that class yet; but i was going to try and create a projectile class and see about making a simple ABS. The event class layout is so similar to how it was in Ruby that i don't think it should be too difficult to figure out.

Similar in that game_event < game_character and then game_map still contains spritsetmap which holds character_sprite.

reading into what '.apply()' is for java script, its just call this function but with arguments.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply
EVENTALIST
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
#13 Re: RMMV - Plugin Sample
Loading

mr_wiggles

EVENTALIST
 EVENTALIST
EVENTALIST
profile
I did some reading and revised the sample i was creating.
Code:
//=============================================================================
// Sample.js
//=============================================================================
/*: @author Mr_Wiggles
 *   Date: 10/26/15
 *   Version: 0.1
 * ----------------------------------------------------------------------------
 * @plugindesc Just a sample lay out of a plugin script file.
 *
 *
 * @param Sample Param
 * @desc An exsample on how a plugin is set up to be shown correctly in the RMMV
 * plugin GUI.
 * @default 0
 *
 * @help This plugin does not provide plugin commands that are functional.
 *//* -------------------------------------------------------------------------
 * Object.create java information.
 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create
 */ //=========================================================================
//----------------------------------------------------------------------------
// Auto run: Sets plugin items that are user defined in RMMV.
//----------------------------------------------------------------------------
(function() {
    //------------------------------------------
    var parameters = PluginManager.parameters('Sample'); // Define plugin name.
    // Set interactive variable settings to show in plugin manager.
    var sampleSetting = String(parameters['Sample Param'] || 0);
    //------------------------------------------
    // Define plugin commands that are called from event task.
    //------------------------------------------
    // set alias for Game_Interpreter_pluginCommand
    var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    // add in custom flags for your plugin.        
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
      _Game_Interpreter_pluginCommand.call(this, command, args); // calls alias
      if (command === 'eventSamplePluginCommand') {
        switch (args[0]) {
        case 'commandOne':
          // For an example, calling the scene is something that can be done here.
          SceneManager.goto(Scene_Sample);
          break;
        }
      }
    };
//----------------------------------------------------------------------------
// Scene Sample
//----------------------------------------------------------------------------
    function Scene_Sample() { // Set function call initialize before object is created.
      this.initialize.apply(this, arguments);
    }
    // Inherit parrent class functions.
    Scene_Sample.prototype = Object.create(Scene_Base.prototype);
    Scene_Sample.prototype.constructor = Scene_Sample;
    //------------------------------------------
    Scene_Sample._classVariable = 0; // @variable
    //------------------------------------------
    // Define funtion initialize for Scene_Sample, it
    // is called !BEFORE! "create" has been.
    //------------------------------------------
    Scene_Sample.prototype.initialize = function() {
      Scene_Base.prototype.initialize.call(this); // *super()
      this._classVariable = 1;
      // create variables before class object creation.
    };
    //------------------------------------------
    // This is java's object "initialize" and is ran when
    // the object is registered with the GC which is
    // !AFTER! function "initialize" is called.
    //------------------------------------------
    Scene_Sample.prototype.create = function() {
      Scene_Base.prototype.create.call(this); // *super()
      Scene_Sample._active = true // Remember to set to active. *super
      if (this._classVariable > 0) {
        SoundManager.playBuzzer();
      } else {
        SoundManager.playOk();
      }
      //  create variables after initialize.
    };
    //------------------------------------------
    // Update loop processing for class. SceneManager
    // will look for "update" function and call it automatically
    // in a loop, to break just call another scene by using:
    // SceneManager.goto(Scene_Map)
    // Or similar.
    //------------------------------------------
    Scene_Sample.prototype.update = function() {
      Scene_Base.prototype.update.call(this); // *super()
      SoundManager.playCursor()
    };
    //------------------------------------------
    // Example on returning scene to game map.
    //------------------------------------------
    Scene_Sample.prototype.returnToMap = function() {
      this.fadeOutAll();
      SceneManager.goto(Scene_Map);
    };
//----------------------------------------------------------------------------
// Window Sample  SceneManager.set(Window_Sample(0,0))
//----------------------------------------------------------------------------
    function Window_Sample() { // Set function call initialize before object is created.
        this.initialize.apply(this, arguments);
    }
    // Inherit parrent class functions.
    Window_Sample.prototype = Object.create(Window_Base.prototype);
    Window_Sample.prototype.constructor = Window_Sample;
    //------------------------------------------
    // (initialize) for Window_Sample.
    // Args*
    //   (x) = X window pos.
    //   (y) = Y window pos.
    //------------------------------------------
    Window_Sample.prototype.initialize = function(x, y) {
        var width  = 32;
        var height = 32;
        Window_Base.prototype.initialize.call(this, x, y, width, height); // *super()
        this.refresh(); // refresh window contients.
    };
    //------------------------------------------
    // (update) for Window_Sample.
    //------------------------------------------
    Window_Sample.prototype.update = function() {
         Window_Base.prototype.update.call(this); // *super()
         // do update procedures for object variables.
    };
    //------------------------------------------
    // (refresh) for Window_Sample.
    //------------------------------------------
    Window_Sample.prototype.refresh = function() {
        this.contents.clear();
        this.drawActorName(actor, x, y + lineHeight * 0, width);
        this.drawActorHp(actor, x, bottom - lineHeight * 3, width);
        this.drawActorMp(actor, x, bottom - lineHeight * 2, width);
    };
//=============================================================================
})(); // End of plugin block.

It works, but as i said before it has no exit because i havent figured out how to use the Input class. i believe update functions are called atomatically, its threw the SceneManager object. To prove that it works i added a sound effect when its called.
EVENTALIST
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
#14 Re: RMMV - Plugin Sample
Loading

mr_wiggles

EVENTALIST
 EVENTALIST
EVENTALIST
profile
After many hours of stressful debugging i have produced a simple HUD plugin (its a script i know i wrote it, plugin makes sounds like it was simpler then it was)

This is one of the few requests i received from game face.

Code:
//================================================================================
// SimpleHUD.js
//================================================================================
/*: @author Mr_Wiggles
 *   Date: 10/27/15
 *   Version: 0.0
 * -------------------------------------------------------------------------------
 * @plugindesc Just a simple HUD script to get the ball rolling.
 *
 * @param Opacity
 * @desc Set the opacity of the HUD. A number range: (0 - 255)
 * @default 255
 *
 * @help This plugin is a simple HUD script to show what the bases are for doing such
 * in the user of the plugin games. You can use the event command 'HUD' with the
 * following arguments:
 *   'show' = show HUD; Example 'HUD hide'
 *   'hide' = hide HUD; Example 'HUD show'
 */ //============================================================================
//--------------------------------------------------------------------------------
// Auto run: Sets plugin items that are user defined in RMMV.
//--------------------------------------------------------------------------------
(function() {
  //------------------------------------------
  var parameters = PluginManager.parameters('SimpleHUD'); // Define plugin name.
  // Set interactive variable settings to show in plugin manager.
  var opacitySetting = String(parameters['Opacity'] || 255);
  //------------------------------------------
  // Define plugin commands that are called from event task.
  //------------------------------------------
  // set alias for Game_Interpreter_pluginCommand
  var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function(command, args) {
    _Game_Interpreter_pluginCommand.call(this, command, args); // calls alias
    // add in custom flags for your plugin.
    if (command === 'HUD') {
      switch (args[0]) {
      case 'hide':
        break;
      case 'show':
        SoundManager.playOk();
        break;
      }
    }
  };
//--------------------------------------------------------------------------------
// Scene_Map Additions/Edits
//--------------------------------------------------------------------------------
  //------------------------------------------
  // map update loop
  //------------------------------------------
  var _Scene_Map_pluginHUD_update = Scene_Map.prototype.update;
  Scene_Map.prototype.update = function() {
    if (this._HUDWindow) {
      this._HUDWindow.update
    } else {
      this._HUDWindow = new Window_HUD(0,0);
      this.addWindow(this._HUDWindow); // *parent function
      //throw new Error('Got to window adding!');
    };
    _Scene_Map_pluginHUD_update.call(this);
  };
  //------------------------------------------
  // Dispose of HUD window when scene is not map.
  //------------------------------------------
  var _Scene_Map_pluginHUD_stop = Scene_Map.prototype.stop;
  Scene_Map.prototype.stop = function() {
    this._HUDWindow.close(); // Dispose of window. *parent function
    _Scene_Map_pluginHUD_stop.call(this);
  };
//--------------------------------------------------------------------------------
// Window HUD
//--------------------------------------------------------------------------------
  function Window_HUD() { // Set function call initialize before object is created.
    this.initialize.apply(this, arguments);
  }
  // Inherit parrent class functions.
  Window_HUD.prototype = Object.create(Window_Base.prototype);
  Window_HUD.prototype.constructor = Window_HUD;
  // class variables
  //------------------------------------------
  // Initialize Window HUD object
  //------------------------------------------
  Window_HUD.prototype.initialize = function(x, y) {
    Window_Base.prototype.initialize.call(this, x, y, 256, 256); // *super()
    this._updateWait = 0;
    this.refresh(); // refresh window contients.
    this.activate(); // *@active = true
  };
  //------------------------------------------
  // Update HUD
  //------------------------------------------
  Window_HUD.prototype.update = function() {
    Window_Base.prototype.update.call(this); // *super()
    // throw new Error('Got to update!');
    if (this._updateWait <= 0) {
       this.refresh();
       this._updateWait = 10;
    } else {
      this._updateWait--; // subtract 1 each time called.
    }
    // SoundManager.playOk();
   };
  //------------------------------------------
  // Refresh HUD if changed
  //------------------------------------------
  Window_HUD.prototype.refresh = function() {
    if (this.contents) {
      if ($gameParty != null) {
        var actor = $gameParty.leader() // set to actor one (player sprite)
        //var actor = $gameParty.allMembers(1);
        //var actor = $gameParty.members(1)
        //throw new Error('Got this far! ' + actor._name);
      }
      var lineHeight = this.lineHeight();
      this.contents.clear();
      if (actor) { // check to make sure Game_Party has
        // enough time/ there is a party member to find in Party.
        this.drawActorName(actor, 0, 0, 100);
        this.drawActorHp(actor, 0, 32, 100);
        this.drawActorMp(actor, 0, 64, 100);
        //throw new Error('Got this far! ' + actor._name);
      }
    } else { // you have to check to make sure the object has been
      // added into the GC.
      SoundManager.playBuzzer();
    }
  };
 //================================================================================
})(); // End of plugin block.

RMMV has nothing to help you AT ALL with syntax errors and most often then not it will just go on pretending the plugin isn't even there if it detects an error but doesn't know how to tell you what error it really is, or even a line number it was found on in the file....

"console.log()" does NOT work you have to use "throw new Error()" instead and that STOPS everything to where you have to reboot the game again. You could also try to use audio cues like "SoundManager.playOk()" to LITERALLY hear if the script has gotten to certain parts (for intense checking if the window was added into the Scene base window manager). To sum it up, debugging scripts/plugins in RMMV looks like a futile effort.

All i've been using to write the code is Notepad + and it just colors key words. If anyone knows of a freeware java script compiler/ code checker, please inform me of it. :p
EVENTALIST
Show Signature
EVENTALIST
Administrator
Administrator
#15 Re: RMMV - Plugin Sample
Loading

G@MeF@Ce

Administrator
Administrator
Administrator
profile
@wiggles you are the man!

you could try http://jshint.com or http://jslint.com

paste and get your code checked

Thanks for mentioning
Code:
console.log()
for I would of never used
Code:
throw new Error()
or even a sound to indicate an error in my script for debugging...
I'm still reverse engineering these "plug-ins" like I did with RGSS scripts for RMXP.
When it comes to coding, I'm still a kid and you're like my favorite uncle LOL!

this simple HUD script is going to open the doors to so many customized HUDs!!!
Administrator
https://www.dropbox.com/sh/i47rig99qhrvn8s/4m5HvsM2fD http://g4m3f4c3.deviantart.com https://www.facebook.com//pages/Gameface101/332331300127008 https://twitter.com//mr_gameface101 https://soundcloud.com/schurr http://www.youtube.com/user/MrGameface101?feature=watch
EVENTALIST
EVENTALIST
#16 Re: RMMV - Plugin Sample
Loading

mr_wiggles

EVENTALIST
 EVENTALIST
EVENTALIST
profile
Sample scene with a sample window and a sample event call.

Code:
//================================================================================
// Sample.js
//================================================================================
/*: @author Mr_Wiggles
 *   Date: 10/28/15
 *   Version: 1.0
 * -------------------------------------------------------------------------------
 * @plugindesc Just a sample lay out of a plugin script file.
 *
 * @param Sample Param
 * @desc An exsample on how a plugin is set up to be shown correctly in the RMMV
 * plugin GUI.
 * @default 0
 *
 * @help This plugin does not provide plugin commands that are functional. You can
 * call the Scene using "eventSamplePluginCommand commandOne" in an event * using
 * the 'Plugin Command' task.
 *//* ----------------------------------------------------------------------------
 * When writing the help and you would like to prevent 'side' scrolling text in the
 * plugin GUI help page. Simply avoid typing past the edge of the line break lines.
 * You know, those lines that are mostly (---- and ====) they are set up to show the
 * margins of the help box boarders. To print information to screen during debug
 * you can use: "throw new Error('Some text ' + object + ' some more text.')"
 * -------------------------------------------------------------------------------
 * Object.create java information.
 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create
 */ //============================================================================
//--------------------------------------------------------------------------------
// Auto run: Sets plugin items that are user defined in RMMV.
//--------------------------------------------------------------------------------
(function() {
  //------------------------------------------
  var parameters = PluginManager.parameters('Sample'); // Define plugin name.
  // Set interactive variable settings to show in plugin manager.
  var sampleSetting = String(parameters['Sample Param'] || 0);
  //------------------------------------------
  // Define plugin commands that are called from event task.
  //------------------------------------------
  // set alias for Game_Interpreter_pluginCommand
  var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function(command, args) {
    _Game_Interpreter_pluginCommand.call(this, command, args); // calls alias
    // add in custom flags for your plugin.        
    if (command === 'eventSamplePluginCommand') { // First word in the box.
      switch (args[0]) { // second word in box.
      case 'commandOne':
        // For an example, calling the scene is something that can be done here.
        SceneManager.goto(Scene_Sample);
        break;
      case 'commandTwo':
        break;
      }
    }
  };
//--------------------------------------------------------------------------------
// Scene Sample
//--------------------------------------------------------------------------------
  function Scene_Sample() { // Set function call initialize before object is created.
    this.initialize.apply(this, arguments);
  }
  // Inherit parrent class functions.
  Scene_Sample.prototype = Object.create(Scene_Base.prototype);
  Scene_Sample.prototype.constructor = Scene_Sample;
  //------------------------------------------
  Scene_Sample._classVariable = 0; // @variable type 1
  //------------------------------------------
  // Define funtion initialize for Scene_Sample, it
  // is called !BEFORE! "create" has been.
  //------------------------------------------
  Scene_Sample.prototype.initialize = function() {
    Scene_Base.prototype.initialize.call(this); // *super()
    this._classVariable = 1; // @variable type 2
    // create variables before class object creation.
  };
  //------------------------------------------
  // This is java's object "initialize" and is ran when
  // the object is registered with the GC which is
  // !AFTER! function "initialize" is called.
  //------------------------------------------
  Scene_Sample.prototype.create = function() {
    Scene_Base.prototype.create.call(this); // *super()
    this.start(); // Remember to set to active. *super
    if (this._classVariable > 0) {
      // Will play this sound if 'create' call is before 'initialize'.
      SoundManager.playOk();
    } else {
      // Will play this sound if 'initialize' call is before 'create'.
      SoundManager.playBuzzer();
    }
  };
  //------------------------------------------
  // Create and add windows
  //------------------------------------------
  Scene_Sample.prototype.create_WindowSample = function() {
    this.createWindowLayer(); // create window pool.
    this._windowSample = new Window_Sample(0,0);
    //throw new Error('added window ' + this._WindowSample);
    this.addWindow(this._windowSample); // add window into window scene pool.
  };
  //------------------------------------------
  // Update loop processing for class. SceneManager
  // will look for "update" function and call it automatically
  // in a loop, to break just call another scene by using:
  // SceneManager.goto(Scene_Map)
  // Or similar.
  //------------------------------------------
  Scene_Sample.prototype.update = function() {
    // some reason windows add better when done threw
    // the update function in a plugin.
    if (this._windowSample) {
      this._windowSample.update();
    } else {
      this.create_WindowSample(0,0);
    }
    Scene_Base.prototype.update.call(this); // *super()
    // If check for 'or' statment
    if (Input.isTriggered('ok') || Input.isTriggered('menu')) {
      SoundManager.playOk();
      this.returnToMap();
    } else {
      SoundManager.playCursor(); // play sound when update called.
    }
  };
  //------------------------------------------
  // This is called to teminate the GC object.
  //------------------------------------------
  Scene_Sample.prototype.stop = function() {
    this._windowSample.close(); // Dispose of window. *parent function
    Scene_Base.prototype.stop.call(this); // *super()
  };
  //------------------------------------------
  // Example on returning scene to game map.
  //------------------------------------------
  Scene_Sample.prototype.returnToMap = function() {
    //this.fadeOutAll(); // scene tansition
    SceneManager.goto(Scene_Map); // scene management/layering
  };
//--------------------------------------------------------------------------------
// Window Sample  SceneManager.set(Window_Sample(0,0))
//--------------------------------------------------------------------------------
  function Window_Sample() { // Set function call initialize before object is created.
    this.initialize.apply(this, arguments);
  }
  // Inherit parrent class functions.
  Window_Sample.prototype = Object.create(Window_Base.prototype);
  Window_Sample.prototype.constructor = Window_Sample;
  //------------------------------------------
  // (initialize) for Window_Sample.
  // Args*
  //   (x) = X window pos.
  //   (y) = Y window pos.
  //------------------------------------------
  Window_Sample.prototype.initialize = function(x, y) {
    var width  = 256;
    var height = 256;
    this._updateWait = 0;
    Window_Base.prototype.initialize.call(this, x, y, width, height); // *super()
    this.refresh(); // refresh window contients.
    this.activate(); // *@active = true
  };
  //------------------------------------------
  // (update) for Window_Sample.
  //------------------------------------------
  Window_Sample.prototype.update = function() {
    Window_Base.prototype.update.call(this); // *super()
    if (this._updateWait <= 0) {
       this.refresh();
       this._updateWait = 10;
    } else {
      this._updateWait--; // subtract 1 each time called.
    }
    // do update procedures for object variables.
  };
  //------------------------------------------
  // (refresh) for Window_Sample.
  //------------------------------------------
  Window_Sample.prototype.refresh = function() {
    if (this.contents) {
      this.contents.clear();
      var width = 100;
      var actor = $gameParty.leader();
      this.drawActorName(actor, 0, 0, width);
      this.drawActorHp(actor, 0, 32, width);
      this.drawActorMp(actor, 0, 64, width);
    }
  }
//================================================================================
})(); // End of plugin block.

For those looking at how to lay out a scene and a window. Smile
EVENTALIST
Show Signature
EVENTALIST
#17 Re: RMMV - Plugin Sample
Loading

Sponsored content

profile

View previous topic View next topic Back to top Message [Page 1 of 1]

 

Chatbox system disabled
Personal messaging disabled