JavaScript questions that don't deserve their own thread

TheGamedawg

Veteran
Veteran
Joined
Aug 29, 2014
Messages
350
Reaction score
133
First Language
English
Primarily Uses
I'm looking to add a bar to my status menu that are similar in appearance to the HP and MP bars, however I can't quite get it to work. I was wondering if anyone could help.


It's a bar that starts out low, but grows overtime as you gain exp. The end of the bar represents the number of max exp a character can potentially have.


So far I've been able to draw in the bars.  Not much past that however.
 

CobraA1

Villager
Member
Joined
Dec 13, 2015
Messages
24
Reaction score
17
First Language
English
The plugin I'm working on has a custom graphic. It's basically a system graphic, not related to tilesets or characters of anything like that.


Where is the best place to put it, and what's the best way to package it with the script?
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
857
First Language
German
Primarily Uses
If the graphic isn't absolutely essential (and in like 99% it's not), just leave it out. Otherwise, you can either:


- Put it with the plugin in a zip file and introduce a plugin parameter to tell where it is (clean), or


- Convert it to Base64 and put it into the plugin (ugly)
 

CobraA1

Villager
Member
Joined
Dec 13, 2015
Messages
24
Reaction score
17
First Language
English
If the graphic isn't absolutely essential (and in like 99% it's not), just leave it out. Otherwise, you can either:


- Put it with the plugin in a zip file and introduce a plugin parameter to tell where it is (clean), or


- Convert it to Base64 and put it into the plugin (ugly)


I don't think there's a standard graphic in RPG Maker MV that would be a good substitution, so I think it's essential.


I am wondering if I should put it in the same folder as the script, or put it into a different folder, though.
 

ragnorak6608

Veteran
Veteran
Joined
May 25, 2014
Messages
54
Reaction score
1
First Language
English
Is there a way to bypass the start screen? Like if I wanted to have the game start on a map.
 

BloodletterQ

Chaotic Neutral Assassin
Veteran
Joined
Aug 15, 2012
Messages
1,464
Reaction score
1,066
First Language
English
Primarily Uses
N/A
I want to skip MP when stats are being displayed since I'm not using it.


Window_StatCompare.prototype.refresh = function() {
this.contents.clear();
if (!this._actor) return;
for (var i = 0; i < 7; ++i) {
this.drawItem(0, this.lineHeight() * i - 32, i);
}
};


Hw do I skip i = 1? 
 

Liquidize

Caffeine Overload
Developer
Joined
Nov 1, 2015
Messages
466
Reaction score
456
First Language
English
Primarily Uses
RMMV
I want to skip MP when stats are being displayed since I'm not using it.


Hw do I skip i = 1? 
Window_StatCompare.prototype.refresh = function() {
this.contents.clear();
if (!this._actor) return;
for (var i = 0; i < 7; ++i) {
if (i === 1) continue;
this.drawItem(0, this.lineHeight() * i - 32, i);
}
};


The above snippet will skip "1" for you.
 

BloodletterQ

Chaotic Neutral Assassin
Veteran
Joined
Aug 15, 2012
Messages
1,464
Reaction score
1,066
First Language
English
Primarily Uses
N/A
Window_StatCompare.prototype.refresh = function() {
this.contents.clear();
if (!this._actor) return;
for (var i = 0; i < 7; ++i) {
if (i === 1) continue;
this.drawItem(0, this.lineHeight() * i - 32, i);
}
};


The above snippet will skip "1" for you.
Thanks but the HP is skipped as well. I'm just trying to get rid of MP.
 

Liquidize

Caffeine Overload
Developer
Joined
Nov 1, 2015
Messages
466
Reaction score
456
First Language
English
Primarily Uses
RMMV
I answered your question :)  you asked how to skip "i=1" it seems you need to find what "i=1" actually is (what object) and prevent the MP from drawing in there instead. 
 

BloodletterQ

Chaotic Neutral Assassin
Veteran
Joined
Aug 15, 2012
Messages
1,464
Reaction score
1,066
First Language
English
Primarily Uses
N/A
Silly me. My adjustment (-32) hid it. I hate to bother you again, but how do I remove that space where MP was?
 

TheGamedawg

Veteran
Veteran
Joined
Aug 29, 2014
Messages
350
Reaction score
133
First Language
English
Primarily Uses
I'm looking to add a bar to my status menu that are similar in appearance to the HP and MP bars, however I can't quite get it to work. I was wondering if anyone could help.


It's a bar that starts out low, but grows overtime as you gain exp. The end of the bar represents the number of max exp a character can potentially have.


So far I've been able to draw in the bars.  Not much past that however.
I'm going to bump this since its been a few days now.  I still haven't gotten a response.
 

Liquidize

Caffeine Overload
Developer
Joined
Nov 1, 2015
Messages
466
Reaction score
456
First Language
English
Primarily Uses
RMMV
I don't know, I can speculate but without seeing the full script and what the "drawItem" method is actually doing all I can say is the following:


I am assuming the drawItem method is taking "i" as a parameter to determine what stat to draw, if this is the case  you could do:


Window_StatCompare.prototype.refresh = function() {
this.contents.clear();
if (!this._actor) return;
for (var i = 0; i < 7; ++i) {
if (i === 1) continue;
if (i === 0) {
this.drawItem(0, this.lineHeight() * i, i);
}
else {
this.drawItem(0, this.lineHeight() * i - 32, i);
}
}
};




Keep in mind this is just speculation, and without knowing what the drawItem function is actually doing, I can not give a concise answer.

I'm looking to add a bar to my status menu that are similar in appearance to the HP and MP bars, however I can't quite get it to work. I was wondering if anyone could help.


It's a bar that starts out low, but grows overtime as you gain exp. The end of the bar represents the number of max exp a character can potentially have.


So far I've been able to draw in the bars.  Not much past that however.


Assuming you are using the "drawGauge" function of the Window_Base (and all windows that inherit this), it takes a "rate" parameter, this is the parameter that determines how much of the gauge is filled. You would want to pass a variable containing the current exp they have, divided by the maximum total experience they could potentially have. E.G: If their current exp is "1000" and the max total exp is "10000" you'd do "1000/10000" or 0.1, or 10% filled. You could use the "currentExp" function of the actor object (assuming one is being passed to the function drawing the gauge,other wise you need to get the actor object yourself) to get the current amount of exp they have, however no function exists to get the "max exp possible" directly. You'd need to call the "expForLevel" function of the actor object, and pass the max level to it as an argument.
 
Last edited by a moderator:

BloodletterQ

Chaotic Neutral Assassin
Veteran
Joined
Aug 15, 2012
Messages
1,464
Reaction score
1,066
First Language
English
Primarily Uses
N/A
I don't know, I can speculate but without seeing the full script and what the "drawItem" method is actually doing all I can say is the following:


I am assuming the drawItem method is taking "i" as a parameter to determine what stat to draw, if this is the case  you could do:



Window_StatCompare.prototype.refresh = function() {
this.contents.clear();
if (!this._actor) return;
for (var i = 0; i < 7; ++i) {
if (i === 1) continue;
if (i === 0) {
this.drawItem(0, this.lineHeight() * i, i);
}
else {
this.drawItem(0, this.lineHeight() * i - 32, i);
}
}
};




Keep in mind this is just speculation, and without knowing what the drawItem function is actually doing, I can not give a concise answer.


Assuming you are using the "drawGauge" function of the Window_Base (and all windows that inherit this), it takes a "rate" parameter, this is the parameter that determines how much of the gauge is filled. You would want to pass a variable containing the current exp they have, divided by the maximum total experience they could potentially have. E.G: If their current exp is "1000" and the max total exp is "10000" you'd do "1000/10000" or 0.1, or 10% filled. You could use the "currentExp" function of the actor object (assuming one is being passed to the function drawing the gauge,other wise you need to get the actor object yourself) to get the current amount of exp they have, however no function exists to get the "max exp possible" directly. You'd need to call the "expForLevel" function of the actor object, and pass the max level to it as an argument.
Thanks and so sorry for the bother. I had it that way before I updated my plugins and overwrote my mod. Now I couldn't find the original topic I got that mod from.

I have a suggestion for Shaz if it's not too much trouble:
So that we don't worry about asking the same questions, would it be a problem if you added links to different answers in your original post? It might help clear up redundant questions.
 

TheGamedawg

Veteran
Veteran
Joined
Aug 29, 2014
Messages
350
Reaction score
133
First Language
English
Primarily Uses
Is there a way to set a conditional branch that goes off specifically if I have a certain character in the second slot of my party?
 

Shinma

Lurker
Veteran
Joined
Dec 29, 2012
Messages
756
Reaction score
336
First Language
English
Primarily Uses
RMMV
@TheGamedawg


Yes, set up a conditional branch and select script on the 4th tab. The syntax for it is: $gameParty.members()[partymemberID] == $gameActors.actor(actorID)


Bear in mind that that actor ID starts at 1 and party member ID starts at 0.


As an example, let's say you have the following four actors:


Actor ID:

  1. Shinma
  2. Xycin
  3. Kenji
  4. Evans

If they were in the party in the same order then their party ID would be:


Party ID:


   0. Shinma


   1. Xycin


   2. Kenji


   3. Evans


And you wanted to test out if Xycin was in the 2nd position of the party.


$gameParty.members()[1] == $gameActors.actor(2)
 
Last edited by a moderator:

TheGamedawg

Veteran
Veteran
Joined
Aug 29, 2014
Messages
350
Reaction score
133
First Language
English
Primarily Uses
So I'm working on a puzzle involving pushing orbs onto buttons, but I'm having a little trouble making it so the button will press when the orb rolls on top of it.  Shaz gave me a great hint by saying to try using regions on top of the buttons and using a conditional branch of if this._regionId() !== 2 for the orbs.  However this just makes it I get a syntax error when the orb stops rolling.  Can anyone help?
 

SwiftIllusion

Veteran
Veteran
Joined
Jan 8, 2016
Messages
107
Reaction score
180
First Language
English
Primarily Uses
I'd really appreciate if someone could let me know how to set the element rate in Javascript.
I've seen various functions in the damage formula that get the value, etc, but I need it within the Javascript context and haven't been able to find it anywhere.


I'm trying to use "target.elementRate(8) = 10;" but it tells me I have an invalid left-hand side in assignment, which I imagine is a poor guess on my part in my attempts to work out what to write to set it with?
It's within the context of a state (using a plugin that will run the change each time the actor affected by the state is targeted, but the code needed has nothing to do with the plugin-just javascript, hence posting within this thread).
Any help with this would be greatly appreciated.
 

yuyu!

The Hero of Rhyme
Member
Joined
Feb 19, 2014
Messages
25
Reaction score
11
Hi, there! :)


Unless I'm mistaken, I've heard that "BattleManager.actor" can be used during battle to return the current selected actor's ID. I'm trying to run script calls to detect the current actor's weapon id. This is what I have so far:


if ($gameActors.actor($BattleManager.actor).equips()[0] != null) {
$gameVariables.setValue(17, $gameActors.actor($BattleManager.actor).equips()[0].id);}




However, I seem to be doing something wrong; I keep getting an error that "$BattleManager is not defined". :( If someone can help out, I'd be eternally grateful!


Thanks for your time! :D
 

kiriseo

Veteran
Veteran
Joined
Oct 27, 2015
Messages
229
Reaction score
74
First Language
German
However, I seem to be doing something wrong; I keep getting an error that "$BattleManager is not defined". :( If someone can help out, I'd be eternally grateful!


Thanks for your time! :D


You have to use BattleManager, not $BattleManager.


And BattleManager.actor() should give you the actor, not the actors ID.
 

yuyu!

The Hero of Rhyme
Member
Joined
Feb 19, 2014
Messages
25
Reaction score
11
You have to use BattleManager, not $BattleManager.


And BattleManager.actor() should give you the actor, not the actors ID.


Thank you so much for the reply! :)


I tried using BattleManager.actor.id and BattleManager.actor().id to grab the actor's ID number. Both seemed to get me a little farther but keep failing to read the ID and has only been returning "null". I'm not sure what I'm doing wrong... Sorry about being so lost, JS is new to me. ^^;



Thank you again! :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Hey guys how come my new plugin that I programmed so perfectly doesn't work? Oh wait.... I forgot to add it to my game's plugins. :kaoswt:
While I take a break from developing RPGs, I'm thinking of doing something I've never done before: actually playing an RPG released by someone else. Any suggestions?
Good lord this is taking forever, I'm not even out of the opening really and I've still got hours worth of work to do before I get to the main gameplay loop. Orphan of Time will probably be done some time next year, If I'm lucky.
Finally the new pc is working!! But it seems a lost my license to Windows 10 because of the hardware changing :(
Tune in next time for our newest Episode: "PC issues return! Palm uses every swear in the lexicon!"

Forum statistics

Threads
93,565
Messages
913,506
Members
123,096
Latest member
RosyNoodle
Top