JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 3 of 171 View original ↗
  1. Appreciate it, shaz.  Worth noting the proper call is "Bitmap.snap(this);"  where 'this' points to the Scene object you want to be copied into a Bitmap.
  2. Hello,

    How can I get the value of a switch from a script?

    I'm trying:

    $gameSwitches[0]...but it always returns undefined.

    EDIT: Solved myself a few mins after posting this lol.

    Code:
    $gameSwitches.value(0)
  3. How can i have a partial mouse support?
    For example i want disable character movement with the mouse click, but keep the curosor or touch screen function avaiable.
    Thanks
  4. Lakaroth said:
    How can i have a partial mouse support?

    For example i want disable character movement with the mouse click, but keep the curosor or touch screen function avaiable.

    Thanks
    As a stab in the dark, try this:

    Game_Temp.prototype.setDestination = function() {}Keep in mind this should permanently disable touch input, which would stop touchscreens and mobile phones from playing the game.
  5. Zalerinian said:
    As a stab in the dark, try this:

    Game_Temp.prototype.setDestination = function() {}Keep in mind this should permanently disable touch input, which would stop touchscreens and mobile phones from playing the game.
     I see, so it works only with mouse, but i need to keep touchscreen and mobile functions active, but stop player movement, i'm planning to create a trasparent gamepad on the screen to let player move.
  6. I'm attempting to create a 'glitchy' sort of effect and am doing random blts and clear_rects - however I can't seem to find a way to recover the image once I've cleared it.

    I even tried to set the bitmap to null and get the image manager to load it again to no effect.

    How can we reload an image from its source?
  7. Firgof said:
    How can we reload an image from its source?
    var myNewBitmap = Bitmap.load('img/char.png');But for those effects you may want to learn how to create shaders...
  8. Does anyone know if it's possible to reinitialize a Graphics class once the game has fully loaded? I'm trying to resize via Script Calling with...

    Graphics.boxWidth = 960;Graphics.width = 960;But in spite of the fact actual display area shrinks (Graphics.width), the overall window/fullscreen (Probably Graphics.boxWidth, but I'm not 100% sure) won't resize to fit, meaning the displayed game area shrinks as I intended but it leaves a black border behind.
  9. Corona~! said:
    Does anyone know if it's possible to reinitialize a Graphics class once the game has fully loaded? I'm trying to resize via Script Calling with...

    Graphics.boxWidth = 960;Graphics.width = 960;But in spite of the fact actual display area shrinks (Graphics.width), the overall window/fullscreen (Probably Graphics.boxWidth, but I'm not 100% sure) won't resize to fit, meaning the displayed game area shrinks as I intended but it leaves a black border behind.
    Edit the index.html file if you plan to do that, some css will solve that, rember canvas size is different than window size
  10. Gekko-Ni said:
    I need the item_ID of the last used item.

    Celianna already asked that for the ACE, but how can i do this in MV? (Without a common event for each item.)

    http://forums.rpgmakerweb.com/index.php?/topic/16250-set-used-item-to-a-variable/

    Some ideas? :)
    It looks like you can capture this information in rpg_objects.js > Game_Action.prototype.apply.

    I'm still getting used to the game code, so I apologize if this is not the most performant or most elegant example:

    (function() { var Game_Action_Apply = Game_Action.prototype.apply; Game_Action.prototype.apply = function (target) { if (this._item.isItem()) { // Example: Storing last used item in Game_Variable slot 1: $gameVariables.setValue(1, this._item._itemId); } Game_Action_Apply.call(this, target); }})();I could make a plugin for this if you're interested.
  11. I wanted to ask here before looking through the base scripts:


    Has someone succeeded in working with PIXI.RenderTexture in combination with MV's Sprite classes? What i'm trying to achieve is to create a texture from (part of) a scene and render it as a minimap.
  12.  Hi,

    I am sorry if this has been answered somewhere else already, I have looked through the threads but couldn't find anything. I am new to scripting (although I have a basic understanding of Java) and want to learn and the best for me to learn is to do. I have started my first script (see below) to add a "Quit" function to the GameEnd screen. As you can see I have made a valiant start in the fact that I have the item display and selectable. I copied the "To Title" function in here to make sure the call was working but this is where I am stuck. What command do I use to not only close the Game End scene but also the main game window?

    Thanks in advance

    (also if you think there is a better way to do this or an easy way to code this, I'd be grateful to hear it)

    Code:
    /*: * @plugindesc 1.0 Displays an option in End Game to shut down * @author Pauli'O'nassus * * @help * * All this does is adds a Shut Down function to the Game End Menu */var oriGameEndMenu = Window_GameEnd.prototype.makeCommandList;Window_GameEnd.prototype.makeCommandList = function () {      oriGameEndMenu.call(this);      this.addCommand('Quit', 'quitToWindows');    }Scene_GameEnd.prototype.createCommandWindow = function() {    this._commandWindow = new Window_GameEnd();    this._commandWindow.setHandler('quitToWindows',  this.commandquitToWindows.bind(this));    this.addWindow(this._commandWindow);};Scene_GameEnd.prototype.commandquitToWindows = function() {    this.fadeOutAll();    SceneManager.goto(Scene_Title);};
  13. I have a problem with "onAfterLoad", in VX Ace it worked to replay BGM and BGS, in my case, after the game was loaded.

    But now I'm trying to make a script and the line is not working, the BGM doesn't play after loading the game

    I'm trying to change the gotoTitle so it loads the last saved game instead.

    Scene_Gameover.prototype.gotoTitle = function() { this.fadeOutAll(); DataManager.loadGame(DataManager.latestSavefileId()); SceneManager.goto(Scene_Map); $gameSystem.onAfterLoad();};PD: onAfterLoad is in rpg_objects.js
  14. actor.addParam(this._params[2], value); I found this in the scripts under rpg_objects //change parameter.

    what I would like to do is something like

    this.actor.addParam(0, 1);0 would be the param with ID of 0.

    Even more simply, I want to add 1 point of attack to a actor already selected from the menu through script. Dose anybody know how to do this?
  15. Does anyone know how to get an Actors current level?

    I want to use $gameActors.actor(actorId).changeLevel(n, true/false);

    But I want n to equal the actors current level plus a variable. So something like the following:

    Code:
    var l = Actor 1 Current Level???var m = $gameVariables.value(2);$gameActors.actor(1).changeLevel(l+m, true);
  16. Goofygooberbro said:
    Does anyone know how to get an Actors current level?

    I want to use $gameActors.actor(actorId).changeLevel(n, true/false);

    But I want n to equal the actors current level plus a variable. So something like the following:

    var l = Actor 1 Current Level???var m = $gameVariables.value(2);$gameActors.actor(1).changeLevel(l+m, true);
    In the Game_Actor class is a property called "_level" for the current level. So something like that should work, but I didn't test it.

    Code:
    var l = $gameActors.actor(1)._level;
  17. You should use ".level", instead. Variables prefixed with "_" are meant for internal usage only.

    In case you're wondering, it's defined here:

    Code:
    Object.defineProperty(Game_Actor.prototype, 'level', {    get: function() {        return this._level;    },    configurable: true});
  18. Iavra said:
    You should use ".level", instead. Variables prefixed with "_" are meant for internal usage only.

    In case you're wondering, it's defined here:

    Object.defineProperty(Game_Actor.prototype, 'level', { get: function() { return this._level; }, configurable: true});
    Perfect! That did the trick. Thanks lavra and kiriseo.

    For anyone wanting to do something similar a working example is below:

    Code:
    var l = $gameActors.actor(1).level;var m = $gameVariables.value(2);$gameActors.actor(1).changeLevel(l+m, true);
  19. I've been trying to get rid of some numbers in my main menu as the game uses 0-100 for all resources (HP/MP/TP) and showing their numbers outside of a bar out of combat is fairly pointless. I can get rid of HP and MP numbers easily enough, but TP lingers on matter what I do. Anyone got an idea as to why? What I've done so far is go into rpg_windows.js and edit this section:

    Window_Base.prototype.drawActorHp = function(actor, x, y, width) { width = width || 186; var color1 = this.hpGaugeColor1(); var color2 = this.hpGaugeColor2(); this.drawGauge(x, y, width, actor.hpRate(), color1, color2); this.changeTextColor(this.systemColor()); this.drawText(TextManager.hpA, x, y, 44); this.drawCurrentAndMax(actor.hp, actor.mhp, x, y, width, this.hpColor(actor), this.normalColor());};Window_Base.prototype.drawActorMp = function(actor, x, y, width) { width = width || 186; var color1 = this.mpGaugeColor1(); var color2 = this.mpGaugeColor2(); this.drawGauge(x, y, width, actor.mpRate(), color1, color2); this.changeTextColor(this.systemColor()); this.drawText(TextManager.mpA, x, y, 44); this.drawCurrentAndMax(actor.mp, actor.mmp, x, y, width, this.mpColor(actor), this.normalColor());};Window_Base.prototype.drawActorTp = function(actor, x, y, width) { width = width || 96; var color1 = this.tpGaugeColor1(); var color2 = this.tpGaugeColor2(); this.drawGauge(x, y, width, actor.tpRate(), color1, color2); this.changeTextColor(this.systemColor()); this.drawText(TextManager.tpA, x, y, 44); this.changeTextColor(this.tpColor(actor)); this.drawText(actor.tp, x + width - 64, y, 64, 'right');};so it looks like this instead:

    Window_Base.prototype.drawActorHp = function(actor, x, y, width) { width = width || 186; var color1 = this.hpGaugeColor1(); var color2 = this.hpGaugeColor2(); this.drawGauge(x, y, width, actor.hpRate(), color1, color2); this.changeTextColor(this.systemColor()); this.drawText(TextManager.hpA, x, y, 44); this.drawText();};Window_Base.prototype.drawActorMp = function(actor, x, y, width) { width = width || 186; var color1 = this.mpGaugeColor1(); var color2 = this.mpGaugeColor2(); this.drawGauge(x, y, width, actor.mpRate(), color1, color2); this.changeTextColor(this.systemColor()); this.drawText(TextManager.mpA, x, y, 44); this.drawText();};Window_Base.prototype.drawActorTp = function(actor, x, y, width) { width = width || 96; var color1 = this.tpGaugeColor1(); var color2 = this.tpGaugeColor2(); this.drawGauge(x, y, width, actor.tpRate(), color1, color2); this.changeTextColor(this.systemColor()); this.drawText(TextManager.tpA, x, y, 44); this.changeTextColor(this.tpColor(actor)); this.drawText();};For some reason the result is this:

    658294b491.jpg

    Anyone got an idea as to why? I'm sure something else is drawing that 0, but I can't seem to find what.

    EDIT: Nevermind, solved it. Turns out Yanfly's plugins override the default TP draw from the base stuff. My bad!