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:



Go to page : Previous  1, 2

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

Administrator
Administrator
#11 RMMV - Plugin Sample - Page 2 Empty Re: RMMV - Plugin Sample
Loading

G@MeF@Ce

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
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
#12 RMMV - Plugin Sample - Page 2 Empty Re: RMMV - Plugin Sample
Loading

mr_wiggles

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 RMMV - Plugin Sample - Page 2 Empty Re: RMMV - Plugin Sample
Loading

mr_wiggles

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 RMMV - Plugin Sample - Page 2 Empty Re: RMMV - Plugin Sample
Loading

mr_wiggles

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 RMMV - Plugin Sample - Page 2 Empty Re: RMMV - Plugin Sample
Loading

G@MeF@Ce

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
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
#16 RMMV - Plugin Sample - Page 2 Empty Re: RMMV - Plugin Sample
Loading

mr_wiggles

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

Sponsored content

profile

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

Go to page : Previous  1, 2

 

Chatbox system disabled
Personal messaging disabled