JavaScript questions that don't deserve their own thread

Firgof

Artist / Designer
Veteran
Joined
Jul 29, 2012
Messages
236
Reaction score
215
First Language
English
Primarily Uses
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.
 

masterlobo

Veteran
Veteran
Joined
Mar 14, 2012
Messages
235
Reaction score
263
First Language
English
Primarily Uses
RMMV
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)
 
Last edited by a moderator:

Lakaroth

Veteran
Veteran
Joined
Dec 9, 2014
Messages
274
Reaction score
133
First Language
English
Primarily Uses
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
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,699
Reaction score
940
First Language
English
Primarily Uses
N/A
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.
 

Lakaroth

Veteran
Veteran
Joined
Dec 9, 2014
Messages
274
Reaction score
133
First Language
English
Primarily Uses
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.
 

Firgof

Artist / Designer
Veteran
Joined
Jul 29, 2012
Messages
236
Reaction score
215
First Language
English
Primarily Uses
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?
 

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
858
Reaction score
365
First Language
Spanish
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...
 

Corona~!

Stardust Crusader
Member
Joined
Jul 18, 2015
Messages
8
Reaction score
22
First Language
English
Primarily Uses
RMMV
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.
 
Last edited by a moderator:

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
858
Reaction score
365
First Language
Spanish
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
 

babykgar

Villager
Member
Joined
Oct 19, 2015
Messages
14
Reaction score
1
First Language
English
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.
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,811
Reaction score
882
First Language
German
Primarily Uses
RMMZ
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.
 

Paulionassus

Warper
Member
Joined
Oct 30, 2015
Messages
3
Reaction score
0
First Language
English
 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);};
 

Torqus

Veteran
Veteran
Joined
Aug 2, 2015
Messages
169
Reaction score
27
First Language
English
Primarily Uses
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
 
Last edited by a moderator:

meep79a

Warper
Member
Joined
Oct 29, 2015
Messages
1
Reaction score
0
First Language
English
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?
 
Joined
Aug 16, 2014
Messages
2
Reaction score
0
First Language
English
Primarily Uses
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);
 

kiriseo

Veteran
Veteran
Joined
Oct 27, 2015
Messages
245
Reaction score
84
First Language
German
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;
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,811
Reaction score
882
First Language
German
Primarily Uses
RMMZ
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});
 
Last edited by a moderator:
Joined
Aug 16, 2014
Messages
2
Reaction score
0
First Language
English
Primarily Uses
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);
 

Cel

Veteran
Veteran
Joined
Oct 28, 2015
Messages
88
Reaction score
56
First Language
Swedish
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!
 
Last edited by a moderator:

Latest Threads

Latest Posts

Latest Profile Posts

Have spent too much time hammering out with a friend just how to make a reoccurring enemy that permanently learns skills you use against her.
I know what I want in a loose sense. Maybe I should just make a post asking for opinions and suggestions.
Shoot Enemy Off-Screen, Run RPG Maker Game as a Web Server, & Thai Keyboard | RPG Maker News #109

Some people have too strong of an opinion about what maker is the best, I've seen discussions like:
- I prefer VXAce because I like the style of the RTP better than the older releases
- You're worse than Hitler
My number one take away from this game jam is to make small games that are as polished and bug free as possible. Far less dev time, and if the game flops, it matters less because my time investment is much lower. Also, whatever ambitions I have... aim for about 10% of them. They are clearly too high, and will involve stuff that likely won't matter.

Forum statistics

Threads
113,732
Messages
1,077,019
Members
147,760
Latest member
anitalains
Top