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]

EVENTALIST
EVENTALIST
#1 Sample Plugin Script Empty Sample Plugin Script
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
This is a sample plugin laying out most of the default call functions you'll need to know to begin writing your very own plugins for RMMV.

Code:
//================================================================================
// Sample.js
//================================================================================
/*: @author Mr_Wiggles | Date: 1/7/15 | Version: 1.3
 * -------------------------------------------------------------------------------
 * The plugin flag @'plugindesc' is limited to about 128 characters.
 * flags for interactive plugin GUI parameters @'param' TheFollowingMust_BeOneWord
 * A @'desc' flag that follows a previously just defined parameter flag will write
 * a description for said parameter in that is limited to 128 characters that will
 * show up in the Plugin GUI for RMMV.
 * -------------------------------------------------------------------------------
 * @plugindesc Just a sample lay out of a plugin script file.
 *
 * @param SampleIntParam
 * @desc An example on how a plugin is set up to be shown correctly in the RMMV
 * plugin GUI.
 * @default 0
 *
 * @param SampleIStringParam
 * @desc An example on how a plugin is set up to be shown correctly in the RMMV
 * plugin GUI.
 * @default null
 *
 * @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.')" OR
 * you could also use audio cues by using this command: "SoundManager.playOk()"
 * Remember that functions regardless if they have no arguments must be called with
 * "()" on the end of the call command. Try to keep track of class variables by using
 * and underscore "_" before the name.
 * Be sure to check your code at http://jslint.com/ or http://jshint.com because
 * RMMV will barely inform you with information about Errors.
 * -------------------------------------------------------------------------------
 * Object.create java information.
 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create
 */ //============================================================================
//--------------------------------------------------------------------------------
// Define global variables
//--------------------------------------------------------------------------------
var $globalSample =  null;
//--------------------------------------------------------------------------------
// Auto run: Sets plugin items that are user defined in RMMV.
//--------------------------------------------------------------------------------
(function() {
  //--------------------------------------------------------------------------------
  // Create Global Objects.
  //--------------------------------------------------------------------------------
  var _Sample_makeObjects = DataManager.createGameObjects;
  DataManager.createGameObjects = function() {
    _Sample_makeObjects.call(this);
    $globalSample = new Scene_Sample();
  };
  //--------------------------------------------------------------------------------
  // Grab Plugin GUI defined variables.
  //--------------------------------------------------------------------------------
  var parameters = PluginManager.parameters('Scene_Sample'); // Define plugin name.
  // Set interactive variable settings to show in plugin manager.
  var sampleIntSetting = Number(parameters['SampleIntParam'] || 0); // list matches the ones defined above.
  var sampleStringSetting = String(parameters['SampleStringParam' || 'null'])
  //------------------------------------------
  // 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 === 'SampleCommand') { // First word in the box.
      switch (args[0]) { // second word in box.
      case 'argumentOne':
        // For an example, calling the scene is something that can be done here.
        SceneManager.goto(Scene_Sample);
        break;
      case 'argumentTwo':
        SceneManager.push(eval('Scene_Sample'));
        break;
      default: // error checking
        throw new Error('SamplePlugin : Command ' + args[0] + ' is not defined.')
      }
    }
  }; // only place ; after the whole functions been defined or after a single line.
//--------------------------------------------------------------------------------
// 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); // create base object class.
  Scene_Sample.prototype.constructor = Scene_Sample; // builds scene name above into object.
  //------------------------------------------
  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
    this.create_WindowSample(0,0); // create a window or more.
    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(90,100); // (X POS, Y POS)
    //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 {
      http://this.create_WindowSample(0,0); remember to use "this.start()".
    }
    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() {
    http://this.fadeOutAll(); // scene tansition
    SceneManager.goto(Scene_Map); // scene management/layering
  };
//--------------------------------------------------------------------------------
// Window Sample  SceneManager.set(Window_Sample(screen_x, screen_y))
//--------------------------------------------------------------------------------
  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); // create base object class.
  Window_Sample.prototype.constructor = Window_Sample; // builds scene name above into object.
  //------------------------------------------
  // (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 = 20; // in frames; 60 FPS
      SoundManager.playCursor(); // play sound when update called.
    } 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;
      // To get player ACTOR data use this:
      var actor = $gameParty.leader();
      // If you want to get Party actor data you can use this:
      var playerParty = $gameParty.members();
      var memberID = 0; // actor position in party. (0 = player)
      actor = playerParty[memberID];
      // some defualt Window_Base functions built into RMMV
      this.drawActorName(actor, 0, 0, width);
      this.drawActorHp(actor, 0, 32, width);
      this.drawActorMp(actor, 0, 64, width);
      // changing the font color.
      var color_num = 1;
      // color_num referse to its tile id
      // (counting top '0' to bottom right '31')
      // in the file "%GameProjec%\img\system\Window.png"
      var color = this.textColor(color_num)     
      // OR just use this to use the old RGBA color definitions.
      color = 'rgba(200,200,200,255)';
      // After making a color you can then use it to set the Text color:
      this.contents.textColor = color;
      // OR you can use this:
      this.changeTextColor(color);
      // OR look at the function color calls in file
      // "rpg_windows.js" lines 173 - 236
      // there you'll find preset color functions
      // to choose from.
      this.resetTextColor(); // resets color to defulat window setting.
      // To change font size BEFORE displaying text use:
      this.contents.fontSize = 18;
      // To reset to Default text use:
      this.contents.fontSize = this.standardFontSize();
      // To Display text:
      this.drawText('Just a sample!', 96, 96, width, 'center');
      // grab Bitmap from location
      try { // Attempt block, in case Error arises it know what to do next.
        var folder = 'img/System/'; // Directory to look in
        var filename = 'Baloon.png'; // Name of file + extention to load (.png)
        var hue =  0 ; // Numeric Range (0-255)
        var smooth = true; // Boolean value
        var bitmap = ImageManager.loadBitmap(folder, filename, hue, smooth)
        // show said bitmap in window
        var x = 0; // Screen X position
        var y = 0; // Screen Y position
        var pw = 48; // Width of Viewing rect.
        var ph = 48; // Height of Viewing rect.
        var cx = 240; // X Position of Viewing rect. Crop
        var cy =  432; // Y Position of Viewing rect. Crop
        this.contents.blt(bitmap, x, y, pw, ph, cx, cy)
      } catch(e) { // if there was an error displaying the Bitmap do Bellow:
      throw new Error('File for Bitmap not found. ' + filename)
      // This area can also be blank to "SKIP" the Attempt block if an Error happens.
      }
    }
 };
 //------------------------------------------
 // Set defualt font size for window
 //------------------------------------------
 Window_Sample.prototype.standardFontSize = function() {
  return 22;
  };
  //------------------------------------------
  // set window background opacity
  //------------------------------------------
  Window_Base.prototype.standardBackOpacity = function() {
    return 255; // # range (0- 255)
  };
//================================================================================
})(); // End of plugin block.

In this plugin it outlines how to go about creating a new Scene in RMMV and how to use the Window_Base script to start making a new Scene with its own Window class.

This plugin also outlines some of the basic rules for plugin layout and how to make descriptions and interactive settings in the RMMV plugin GUI.

A very good reference to all the built in class functions can be found here. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
EVENTALIST
Show Signature
EVENTALIST
Active Member
Active Member
#2 Sample Plugin Script Empty Re: Sample Plugin Script
Loading

handy333

handy333
Active Member
Active Member
Active Member
profile
I seem to have a problem understanding that alias thing. Like (_this_that_something). I don't know if it's a variable, a set of variables.
Active Member
Show Signature
Active Member
http://projectrisingsun.weebly.com/ http://soundcloud.com/handyfox https://www.youtube.com/channel/UCkBX7ZxqoXslAtqsdrmsn_w
EVENTALIST
EVENTALIST
#3 Sample Plugin Script Empty Re: Sample Plugin Script
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
Sorry didn't see this post until after i replied to this one.
http://gameface101.playogame.com/t2044-how-do-i-use-alias-in-rgssx#25587
EVENTALIST
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
#4 Sample Plugin Script Empty Re: Sample Plugin Script
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
Found a very useful link for all the information on the built in class functions JavaScript has to offer, i updated the first post with a link.
EVENTALIST
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
#5 Sample Plugin Script Empty Re: Sample Plugin Script
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
Some reason i can't for the life of me get plugins to work with each other. Like have this plugin call a function or use a class from this plugin. Nothing turned up online about it. I saw one scriptwriter using something like:
Code:
var Imported = Imported || {};
Imported.ObjectName = true;
Then useing a if statment to check and see if it was loaded in:
Code:

if (Imported.ObjectName) {
  // do this
};

But i STILL get nothing.. idk, head scratcher...
EVENTALIST
Show Signature
EVENTALIST
Administrator
Administrator
#6 Sample Plugin Script Empty Re: Sample Plugin Script
Loading

G@MeF@Ce

G@MeF@Ce
Administrator
Administrator
Administrator
profile
^ are you trying to use two plugins that don't work with eachother? or are you making these plugins but haven't got them to run right together??
Administrator
Show Signature
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 https://www.youtube.com/user/MrGameface101?feature=watch
EVENTALIST
EVENTALIST
#7 Sample Plugin Script Empty Re: Sample Plugin Script
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
One plugin is a utility plugin, its intention is to be used with other plugins. It's why i was looking at the Imported setup, so that you can check to make sure the plugin is installed or use plan B.

Plugin one is something like this:
Code:
var Imported = Imported || {}; // Hash pile that will check if other plugins that
Imported.SimpleColor = true;  // work with this script can run along side of it.
//--------------------------------------------------------------------------------
(function() {
  Game_Temp.prototype.getColor = function(string, opacity) {

  }
})();

Then plugin script two will use something like this.
Code:

var Imported = Imported || {}; // At the top of the file.
Imported.ThisName = true;

//... Some code.

if (Imported.SimpleColor) {
  SoundManager.playOk();
  _color1 = $gameTemp.getColor('red');
}

//.. some more code.

But Nothin.. :/ And yes i used proper order in the plugin GUI via RMMV. Top is read first down, instead of the RMXP bottom of the the list up. Least what i hear that is.. I tried both least twice. If the function isn't in the same script file as its being called in they just wont communicate to each other and share functions.

[edit]
As far as i can tell, even the 'Import' variable isn't carried into the next plugin either...

Much faster and less typing then using the 'Import' variable set up is just using:
Code:
PluginManager._scripts.contains('SimpleColor')

Its the container for all the loaded script names. So i went with that, but still saying no function found.

[edit2]
Code:

if (PluginManager._scripts.contains('SimpleColor')) {
  try {
    _color1 = $gameTemp.getColor('red');
  } catch(e) {
    throw new Error(e + ' : Still not working.');
  }
}

Still nothing, it says the script is loaded but yet the function is not found.
EVENTALIST
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
#8 Sample Plugin Script Empty Re: Sample Plugin Script
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
whelp, i got it.. was sorta just an issue with syntax error i didn't see in the first plugin. I should really run it threw a compiler more often and make sure its put together right.

For anyone wishing to do what i did and have a plugin that is meant to be used with other scripts you should use something along these lines:

Code:

if (PluginManager._scripts.contains('PluginName')) {
  try {
    var color = PluginObject.pluginFunction('red');
  } catch(e) {
    throw new Error(e + ' : Script function not found, Do you have the plugin script installed?');
  }
}

Works just fine for me, thanks for the insight game face101 ended up getting it to work in the end. Smile

If you want it to continue with a different option then using another script plugin and do not wish to show an error if it found one just use the sample bellow:
Code:

if (PluginManager._scripts.contains('PluginName')) {
  try {
    _color1 = PluginObject.pluginFunction('red');
  } catch(e) {}
}

In the catch block you can make it use 'plan B' if try {'plan A'} wasn't found.
EVENTALIST
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
#9 Sample Plugin Script Empty Re: Sample Plugin Script
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
The sample Plugin script was updated to include how to make Global Variables. It also includes a sample on how to set up and use a "try{}catch(){}" Block. Cleaned up how to get Party actor data and added more samples on how to set font size and color.
EVENTALIST
Show Signature
EVENTALIST
Administrator
Administrator
#10 Sample Plugin Script Empty Re: Sample Plugin Script
Loading

G@MeF@Ce

G@MeF@Ce
Administrator
Administrator
Administrator
profile
nice! thx wiggles this makes customizing a snap with JS RMMV ++++ !!! ^,^
Administrator
Show Signature
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 https://www.youtube.com/user/MrGameface101?feature=watch

Sponsored content

profile

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

 

Chatbox system disabled
Personal messaging disabled