JavaScript questions that don't deserve their own thread

zelanius

Everyman
Veteran
Joined
Apr 29, 2020
Messages
50
Reaction score
4
First Language
English
Primarily Uses
RMMV
Ok, the plugin seems to be working. So for some reason, when it checks the actor sprites, the actor with the id you are looking for is not in that list. Make sure, that the script call takes place, when the actor is already on the battlefield and then move the actor. That's all I can tell looking at it from here. Maybe test it with other actor ids just to make sure it works if there is an actor on the battle field.
Hi Lanzy, thank you so much. For some reason, the script cannot work in the same Common Event as the summon, so I suspect that until the Common Event resolves, the summoned actor is not properly added to the party/battlefield (I wonder if that is the reason why SRD Summon Core creates an instance of the actor rather than the actor itself). I tested it by adding a code to move one of the non-summonable actors already on the battlefield, and they moved to the new x, y location when I used the skill to summon. I also tried to create a separate skill that runs a Common Event to reposition the summons after the summon already happens, and it works.

Now I just have to figure out how to get the script to run in the same instance as the summon, maybe using states to run the script or tie a new Common Event to a switch that gets activated after the skill resolves.

Again, thank you so much!!
 
Last edited:

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
571
Reaction score
196
First Language
English
Primarily Uses
RMMV
I wasn't sure if you wanted to have the 20% chance every time MP is used or just outright 20% chance
regardless of MP use. So I did both.
Thank you very much, everything works great!

Just as an extra question, what would be the line of code I could add to play a SE?
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
128
Reaction score
54
First Language
English
Primarily Uses
RMMV
Thank you very much, everything works great!

Just as an extra question, what would be the line of code I could add to play a SE?
First off: Just realized u wanted a probability of 10% not 20%. Simply change the line where it says

if (Math.random() <= 0.2)

To

if (Math.random() <= 0.1)

Secondly:
I attached an excel sheet with script calls you can use in MV. There are a lot of useful methods in there.
Amongst them you will find sound effects too.

Cheers
 

Attachments

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
571
Reaction score
196
First Language
English
Primarily Uses
RMMV
Bit of an odd question here. I've been using a script call to check whether certain party members have a certain accessory equipped. This is the script that I'm using in the conditional branch. (Note: I'm checking equip slot 4 and 5 due to using Yanfly's Equip Core to allow for two accessory slots)

Code:
$gameParty.members()[2].equips()[4].id === 67 || $gameParty.members()[2].equips()[5].id === 67
The thing is, this works perfectly in game. The only oddity is, if this check returns false, I get the following error in the console. (Also, just to note, even though EventCopier shows up in the error, disabling it gives the same error)

Capture.PNG

Could someone help me tweak my script to fix the errors showing up in the console?
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
128
Reaction score
54
First Language
English
Primarily Uses
RMMV
Bit of an odd question here. I've been using a script call to check whether certain party members have a certain accessory equipped. This is the script that I'm using in the conditional branch. (Note: I'm checking equip slot 4 and 5 due to using Yanfly's Equip Core to allow for two accessory slots)

Code:
$gameParty.members()[2].equips()[4].id === 67 || $gameParty.members()[2].equips()[5].id === 67
The thing is, this works perfectly in game. The only oddity is, if this check returns false, I get the following error in the console. (Also, just to note, even though EventCopier shows up in the error, disabling it gives the same error)

View attachment 164900

Could someone help me tweak my script to fix the errors showing up in the console?
When an equip slot is empty and the conditional branch is checking for an equip id, it will return that error. Because it can't check the id of a non-existing equip.

You have to include a check to see if an equip exists before checking it's id.
Code:
$gameParty.members()[2].equips()[4] && 
$gameParty.members()[2].equips()[4].id === 67 || 
$gameParty.members()[2].equips()[5] && 
$gameParty.members()[2].equips()[5].id === 67
It gets a bit messy. But that's the way to do it in this case.
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
571
Reaction score
196
First Language
English
Primarily Uses
RMMV
When an equip slot is empty and the conditional branch is checking for an equip id, it will return that error. Because it can't check the id of a non-existing equip.
Thank you for your help.

Hmm... that seemed to fix one error, but now I'm getting a different error. Still works fine in game, but getting this error in the colsole, when using this script call.

Code:
$gameParty.members()[2].equips()[4] && $gameParty.members()[2].equips()[4].id === 67 || $gameParty.members()[2].equips()[5] && $gameParty.members()[2].equips()[5].id === 67
Capture.PNG
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
128
Reaction score
54
First Language
English
Primarily Uses
RMMV
Thank you for your help.

Hmm... that seemed to fix one error, but now I'm getting a different error. Still works fine in game, but getting this error in the colsole, when using this script call.

Code:
$gameParty.members()[2].equips()[4] && $gameParty.members()[2].equips()[4].id === 67 || $gameParty.members()[2].equips()[5] && $gameParty.members()[2].equips()[5].id === 67
View attachment 165070
Yea, that means that the member of the party doesn't exist. So u wanna make another condition before checking equips, to check if party member exists.

Note that members()[2] is actor no. 3 in the party list.
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
571
Reaction score
196
First Language
English
Primarily Uses
RMMV
Yea, that means that the member of the party doesn't exist. So u wanna make another condition before checking equips, to check if party member exists.

Note that members()[2] is actor no. 3 in the party list.
Ah, that makes sense, thank you very much!

In case anyone else is curious how to set it up, this is the script that I ended up using:

Code:
$gameParty.members().length >= 1 && $gameParty.members()[0].equips()[4] && $gameParty.members()[0].equips()[4].id === 67 || $gameParty.members().length >= 1 && $gameParty.members()[0].equips()[5] && $gameParty.members()[0].equips()[5].id === 67
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
129
Reaction score
70
First Language
French
Primarily Uses
RMMV
Hi, y'all. I was working on a skill that reduces the max HP of the target by 25% of the damage taken, and this is what I came up with:
JavaScript:
<Custom Deselect Effect>
erosion = Math.round(value/4);
target._paramPlus[0] -= erosion;
target.removeState(59);
</Custom Deselect Effect>
This is in the note of a state that's applied in the damage formula.

Unfortunately, it returns an error about not being able to draw the health bar because the value is non-finite, even though I'm making sure the erosion variable is rounded.
YEP_CoreEngine.js:1098 TypeError: Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': The provided double value is non-finite.
at Bitmap.gradientFillRect (rpg_core.js:1289)
at Bitmap.gradientFillRect (YEP_CoreEngine.js:1014)
at Window_VisualHPGauge.drawGauge (YEP_X_VisualHpGauge.js:717)
at Window_VisualHPGauge.drawActorHp (WAY_X_VisualGaugesAddon.js:1146)
at Window_VisualHPGauge.refresh (YEP_X_VisualHpGauge.js:641)
at Window_VisualHPGauge.updateRefresh (YEP_X_VisualHpGauge.js:632)
at Window_VisualHPGauge.updateWindowAspects (YEP_X_VisualHpGauge.js:544)
at Window_VisualHPGauge.update (YEP_X_VisualHpGauge.js:536)
at rpg_core.js:4068
at Array.forEach (<anonymous>)
If I replace -= erosion in the 3rd line by -= 100, it works perfectly. So the issue has to come from the erosion variable.
So I have no idea what's causing the erosion value, a very much finite number because it gets rounded, to return this error.
Can somebody tell me what's wrong, and how to fix it?
 

kiriseo

Veteran
Veteran
Joined
Oct 27, 2015
Messages
245
Reaction score
82
First Language
German
I'm just gonna guess, 'cause it's rather late here.
The issue might be the "value" variable.
When the deselectStateEffect function calls the customEffectEval function, the "value" variable isn't provided, so it defaults to "undefined".
Now you're trying to divide "undefined" by 4 what gets you NaN (Not a Number).
You could try it with the <Custom Respond Effect> tag instead. The "value" variable there will have the damage value in it for that.
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
129
Reaction score
70
First Language
French
Primarily Uses
RMMV
I'm just gonna guess, 'cause it's rather late here.
The issue might be the "value" variable.
When the deselectStateEffect function calls the customEffectEval function, the "value" variable isn't provided, so it defaults to "undefined".
Now you're trying to divide "undefined" by 4 what gets you NaN (Not a Number).
You could try it with the <Custom Respond Effect> tag instead. The "value" variable there will have the damage value in it for that.
Well I didn't know I could both suck and be mildly proficient at JS. Thank you!
 

Laya

Warper
Member
Joined
Oct 19, 2017
Messages
4
Reaction score
1
First Language
English
Primarily Uses
RMMV
Can anyone who knows javascript pick up mv and write plug ins for it or are there other things that person has to learn first? For example, if I tried to hire a JS programmer off another site, could they just jump right into MV? Or do they need to learn other things as well?
 

Dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
498
Reaction score
226
First Language
German
Primarily Uses
RMMV
Can anyone who knows javascript pick up mv and write plug ins for it or are there other things that person has to learn first? For example, if I tried to hire a JS programmer off another site, could they just jump right into MV? Or do they need to learn other things as well?
RPG has basic Plugins:
Screenshot_3.png
So if you hire someone who is used to JS, that person will still have to learn everything about what happens in those basic plugins.. and it would be better to know how the RPG systems works
(I mean beein familiar with eventing and the engine itself in that case MV)
 

Lady_JJ

Veteran
Veteran
Joined
May 6, 2019
Messages
69
Reaction score
48
First Language
English
Primarily Uses
RMMV
I can concatenate a string and use $gameVariables.value(n)+" blind mice", I can force a line feed with "blind \n mice", but I don't know how to insert an icon in the js string to show in the message box. It just shows up as "3 \i[48] blind mice." Is it possible to do this?
 

Dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
498
Reaction score
226
First Language
German
Primarily Uses
RMMV
I can concatenate a string and use $gameVariables.value(n)+" blind mice", I can force a line feed with "blind \n mice", but I don't know how to insert an icon in the js string to show in the message box. It just shows up as "3 \i[48] blind mice." Is it possible to do this?
Im not sure if that solves your question but i found this topic.
(RPG Maker MV Message Boxes: Special Characters)
And this posting #4.. ( in the topic)
 

Lady_JJ

Veteran
Veteran
Joined
May 6, 2019
Messages
69
Reaction score
48
First Language
English
Primarily Uses
RMMV
Im not sure if that solves your question but i found this topic.
(RPG Maker MV Message Boxes: Special Characters)
And this posting #4.. ( in the topic)
Thanks for helping me search, but this only relates to the special characters within the message box itself. What I really want to do is insert the icon into a javascript constructed string variable. I'm still searching, but it seems that because it's an image, it's not a simple thing.
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
128
Reaction score
54
First Language
English
Primarily Uses
RMMV
Thanks for helping me search, but this only relates to the special characters within the message box itself. What I really want to do is insert the icon into a javascript constructed string variable. I'm still searching, but it seems that because it's an image, it's not a simple thing.
The text in message boxes gets checked for special characters and then replaces them accordingly. You will need to run your string through the same interpreter. I'm too tired now to check, but if u give me time I'll check it out and let u know, since that would also be interesting for me to know.
 

Lady_JJ

Veteran
Veteran
Joined
May 6, 2019
Messages
69
Reaction score
48
First Language
English
Primarily Uses
RMMV
Thank you. I have decided to go a simpler route. I'm going to use multiple variables for the conventional text and just line them up accordingly. I had wanted to omit the icon if the quantity of that item were zero, but I'll just include the icon and note the quantity as zero. Still, if you decide to ever work this out, that would be amazing!
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
129
Reaction score
70
First Language
French
Primarily Uses
RMMV
I'm using Yanfly's Quest Journal System. Is there a function I can call that will return the title of a quest, with the quest ID being the argument to return the right one?

I'm trying to automate creating Gab windows that indicate quest changes, using the Quest Journal's Lunatic Mode in the plugin settings. If I could just get a string that returns the title like I typed it in the plugin settings, I've got the rest covered.
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
128
Reaction score
54
First Language
English
Primarily Uses
RMMV
I'm using Yanfly's Quest Journal System. Is there a function I can call that will return the title of a quest, with the quest ID being the argument to return the right one?

I'm trying to automate creating Gab windows that indicate quest changes, using the Quest Journal's Lunatic Mode in the plugin settings. If I could just get a string that returns the title like I typed it in the plugin settings, I've got the rest covered.
Try using

JavaScript:
$dataQuests[questID];
This might just return the entire quest, rather than the name.
I don't know how it's structured. If you can use that code above in the console and post a screenshot, then I can give u more details.
 

Users Who Are Viewing This Thread (Users: 5, Guests: 2)

Latest Threads

Latest Profile Posts

People3_1 and People3_2 added!

Part 2 of my Audio Engine tutorial for MZ is out!
Come join our stream starting at 2pm and win cool stuff! :D
Star citizen just announced they will develop a roadmap for their planned roadmap...
And i thought i needed order on my project... :kaoswt2:
Big City Greens had it right:
"Always back up your brain game, that's what I like to say!"

Forum statistics

Threads
105,708
Messages
1,015,785
Members
137,387
Latest member
Reeman326
Top