@BurningOrca That is up to you, really. Perhaps the plugins go about the same end result in different ways. Perhaps one is more compatible with the plugins another user has in a project. You can never tell how useful a plugin will be to someone.
JavaScript questions that don't deserve their own thread
● ARCHIVED · READ-ONLY
-
-
As someone who used to make scripts on Ace even if Yanfly has a similar script, I made my scripts have a bit of different application method. Like for most of Yanfly's event execution scripts, it gives the capability to run a common event during some trigger, while mine would let the user define an actual RGSS3 code instead...
Also as Ossra said, there can exist different ways of implementing the same behavior, so that also gives justification to the other plugin. If yours would work have the same output and same method of work, then yeah there's not much point except for the sake of you having your own (which is also fine).
This also gives people options in case the plugin of one coder has problems in their project or when the creator of that plugin stops supporting and/or in extreme cases, makes their plugins unavailable for use.
It might be a bit small in amount but I see threads or posts every now and then which asks for alternatives to the more known plugins due to incompatibilities and personal reasons.
iirc the purpose of this thread is for questions about JS codes that doesnt directly relate to a plugin, or the creation of such. -
There's also the concept of "feature bloat". Perhaps the existing plugin has that feature plus 49 other features. If yours only has the one feature it is more likely to be performant, easy to read, and compatible with other plugins.
-
@BurningOrca That is up to you, really. Perhaps the plugins go about the same end result in different ways. Perhaps one is more compatible with the plugins another user has in a project. You can never tell how useful a plugin will be to someone.
As someone who used to make scripts on Ace even if Yanfly has a similar script, I made my scripts have a bit of different application method. Like for most of Yanfly's event execution scripts, it gives the capability to run a common event during some trigger, while mine would let the user define an actual RGSS3 code instead...
Also as Ossra said, there can exist different ways of implementing the same behavior, so that also gives justification to the other plugin. If yours would work have the same output and same method of work, then yeah there's not much point except for the sake of you having your own (which is also fine).
This also gives people options in case the plugin of one coder has problems in their project or when the creator of that plugin stops supporting and/or in extreme cases, makes their plugins unavailable for use.
It might be a bit small in amount but I see threads or posts every now and then which asks for alternatives to the more known plugins due to incompatibilities and personal reasons.
iirc the purpose of this thread is for questions about JS codes that doesnt directly relate to a plugin, or the creation of such.
There's also the concept of "feature bloat". Perhaps the existing plugin has that feature plus 49 other features. If yours only has the one feature it is more likely to be performant, easy to read, and compatible with other plugins.
@Ossra @Engr. Adiktuzmiko @Aloe Guvner: Thank you all for your answers. -
There's also the concept of "feature bloat". Perhaps the existing plugin has that feature plus 49 other features. If yours only has the one feature it is more likely to be performant, easy to read, and compatible with other plugins.
That's one of the reasons I have read from people not wanting to use a YEP for some features that they need. -
Hey Guys,
in Spriteset_Base.prototype.createBaseSprite it creates a new ScreenSprite called _blackScreen which is subsequently as a child to each _baseSprite in every Spriteset. Does _blackScreen serve no other purpose than being a black base for the _baseSprite and its save to assume it doesnt have anything to do with Screen fade ins and outs? -
Hi, I'm using most of Yanfly's plugins but the relevant ones to my question involve these 2 notetags. Basically I'm trying to create a spell that will cost however much mana the caster has left, whether they're at full mana, 1mp or somewhere in between. Then, damage dealt would correspond directly w/ how much mana was used to cast the spell. Right now, I got the 1st part working (MP Cost) but the damage dealt is always 0. I'm guessing it's cuz the game is looking at the unit's MP after it's been spent on the spell, not before. Any help is appreciated, thx.
<Custom MP Cost>
var mana = user.mp
cost = user.mp
</Custom MP Cost>
<damage formula>
value = a.mp
</damage formula> -
As you suspected, yes, damage is calculated aftee paying the cost... You will need to set a variable equal to the MP before the cost is taken, and use that variable as the damage value.
Like in the cost part do something like this first
$gameVariables.set(ID,user.mp)
then on your damage part, do
value = $gameVariables.value(ID)
Take note though that if that is your only damage formula, you can skip using the notetag and just type
$gameVariables.value(ID)
directly in the damage formula box of the skill. The damage formula box is already a JS evaluation box, no need to use a plugin for codes that fit and write nicely into the box. -
Thx, this seems like exactly what I needed! But when I try it, I'm still getting 0...This is what I have now in the skill's note box:As you suspected, yes, damage is calculated aftee paying the cost... You will need to set a variable equal to the MP before the cost is taken, and use that variable as the damage value.
Like in the cost part do something like this first
$gameVariables.set(ID,user.mp)
then on your damage part, do
value = $gameVariables.value(ID)
Take note though that if that is your only damage formula, you can skip using the notetag and just type
$gameVariables.value(ID)
directly in the damage formula box of the skill. The damage formula box is already a JS evaluation box, no need to use a plugin for codes that fit and write nicely into the box.
<Custom Execution>
$gameVariables.set(1,user.mp);
</Custom Execution>
<Custom MP Cost>
cost = user.mp;
</Custom MP Cost>
Also, as per your suggestion, I put $gameVariables.value(ID) in the damage formula box. Actually i put $gameVariables.value(1)
What am I doing wrong here? I've tried a couple of variations in the note box, such as putting $gameVariables.value(ID) in the <Custom MP Cost> tag and even making sure I had the semicolons (which I totally forgot to put the 1st time lol). Perhaps the value of the variable is changing in real-time as my unit's MP changes? Thus exhibiting the same problem I've been having from the beginning? -
Variables set to things like HP and such usually dont change IRT because they get the value, not the pointer to the data. A lot of people actually put requests on the past to be able to do that with variables so they only need to "set" it once.
But just in case, you can try to manually give it the value to ensure that it saves the value, not the pointer. I kinda forgot how to do that in JS though.
Or first try actually using user.mp() on the variable setting instead of just user.mp. Because from my experience, when you set a variable to a JS function but only use the name without the () [which denotes a call to the function], it actually saves the whole function as text instead of evaluating it and saving the result.
TBH though, using variable 1 is pretty risky, because its the first ever variable you might have been using it too on other stuff. It might not matter on the skill since the cost calculation happens right before execution too anyway, but it might cause problems with other stuff. Or it could also be affecting the skill.
PS: Make sure to check it inside the cost part again instead of on the execute code.
You can also add this, after the variable set and before the cost = code
console.log($gameVariables.value(ID))
And test your game while the console is ON, that way we can see what value is saved during the saving part. -
I'm having an issue with some script calls. I'm used to programming in Unity in C#, but decided to give some simple things a try in RPGMMV to start learning some basic java skills, but something in my script calls isn't functioning correctly.
I keep getting errors revolving around undefined. Basically, what I'm trying to do is feed variables set in the database into the script call for adding/subtracting items.
Code:◆Script:var r = $gameVariables._data[8]; : :var q = $gameVariables._data[9]; : :$gameParty.gainItem($dataItems._data[r], -q); ◆Script:var r = $gameVariables._data[1]; : :var q = $gameVariables._data[2]; : :$gameParty.gainItem($dataItems[r], q); ◆Play SE:Bell2 (90, 100, 0)
Any help would be appreciated, as I'm sure it's something simple I'm missing. Thank you! -
Still no luck in my attempts to create a spell that deals damage based on the amount of mana used to cast the spell (the spell uses all of the user's remaining mana, however much it might be). I looked through Yanfly's tips & tricks videos for guidance, especially when it comes to syntax and so forth. Here are a few I think might be useful, but try as I might...I just can't get the spell to work! If anyone can chime in and gimme a hand, I would forever be in your debt. (The stuff in bold might be useful for the spell I'm trying to create)
SACRIFICIAL BOLT
<Custom Execution>
// Get the group that the user belongs to.
var group = user.friendsUnit();
// Get the alive members of the group.
var allies = group.aliveMembers();
// Remove the user from the group.
allies.splice(allies.indexOf(user), 1);
// Pick a random ally.
var ally = allies[Math.floor(Math.random() * allies.length)];
// Store the ally's current HP value with the user.
user._allyHp = ally.hp;
// Store the ally's current MAT value with the user.
user._allyMat = ally.mat;
// Play animation 65 on the ally.
ally.startAnimation(65);
// Time to kill off the ally.
ally.gainHp(-1 * ally.hp);
// Perform the collapse effect on the ally.
ally.performCollapse();
</Custom Execution>
<Damage Formula>
// Damage Formula used for the skill.
value = user._allyHp + user._allyMat * 14;
// Remove stored ally HP value.
user._allyHp = undefined;
// Remove stored ally MAT value.
user._allyMat = undefined;
</Damage Formula>
ANNIE'S DISINTEGRATE
<Post-Damage Eval>
if (target.hp <= 0) {
user.gainMp(item.mpCost);
}
</Post-Damage Eval>
MOLTEN GIANT
<Custom MP Cost>
cost -= user.mhp - user.hp
</Custom MP Cost> -
@DarkSpectre please post the error message that you are getting so that we can have a better idea of what is happening.
Also if that script code is how it looks exactly on your editor, Im pretty sure you have extra : lying in front of your lines... Delete those. I guess you copy pasted it from a screenshot of the event editor, and as such you also copied the : that was actually part of the event editor's UI instead of the code. -
@DarkSpectre please post the error message that you are getting so that we can have a better idea of what is happening.
Also if that script code is how it looks exactly on your editor, Im pretty sure you have extra : lying in front of your lines... Delete those. I guess you copy pasted it from a screenshot of the event editor, and as such you also copied the : that was actually part of the event editor's UI instead of the code.
You are correct about me copying and pasting from the editor, my apologies, the extra : are from the interface as you suggested, and not part of the actual code.
The exact error I’m receiving is:
Cannot read property undefined of undefined.
Thanks again for any help! -
@DarkSpectre
I mean your actual code still has :, which it shouldnt have. Your script call shouldnt have any : in it.
If you copy pasted from the editor to your post, your post should only have one : per line (from the UI, the leftmost : ), but your post have two : per line on the 2nd,3rd,5th,6th lines... Which means your actual code has : in it.
So you should delete those extra : (the second ones) from the script call in your editor because they would indeed cause errors. A day ago, somebody made that same mistake and we ended up with 2 pages of post before we even realized that it was all because of that simple thing...
As for the error, please test the game with console on, and see which code/line the error points to. Do this after you remove the extra : though.
Also, calling ._data[id] isnt a good idea because if you do that, the auto-initialization being done by the .value(id) function wont kick in, so you might end up using variables that arent initialized with a value yet.
I suggest using $gameVariables.value(id) instead of handling the ._data array directly.
Your $dataItems call might also have a problem but Im not sure of the correct call for that right now. -
@Engr. Adiktuzmiko
Actually I just fixed this a moment ago, but your reply was partially correct. The issue wasn't anything to do with : in the code, it was just the way that the editor was displaying the script call in the common event I had it in. I believe they were being added by the editor because I was doing more than a single line of text in the script box. The actual syntax for the code I was using was like this:
Code:var r = $gameVariables._data[8]; var q = $gameVariables._data[9]; $gameParty.gainItem($dataItems._data[r], -q);
Because I copied the editor lines as text it copied the :
See what I mean here...
Anyways, what the actual problem was, was the way I was trying to access the variable as you mentioned above. I changed the previous codes to the below syntax, and now everything is A-OK. :LZScheeze:
Code:$gameParty.gainItem($dataItems[$gameVariables.value(4)], -($gameVariables.value(5)));
I just didn't know enough about Java Syntax yet to figure out what was going on. When I did some research on just regular JS, not specifically RPG Maker, I figured out what was going on, then found the correct way to access the variable data in the RPG Maker core codes.
Thank you so much for all your help! -
Glad it all works now.. BTW, dont mix Java with JavaScript, they are different :)
-
Glad it all works now.. BTW, dont mix Java with JavaScript, they are different :)
Sorry, yea, I meant JS. I always used Unity or Unreal for my college stuff, so I'm just finally getting back into the RPG Maker stuff, and realized they went and changed languages on me while I was gone. Lol. I'll pick it up eventually, I just never had much use for JS before now.
I managed to create a simple crafting system using events in the editor, and just couldn't seem to find a way to add an item by using a variable containing an ID and a variable containing a quantity without actually using the couple lines of script. (Not without running a conditional check for each and every item in the database anyways.)
Now it works fully!
It uses type Hidden Item A items set up as recipes, items setup as resources, and items you want to create. Then the user just adjusts variables for where the recipes start and end, and creates the recipe contents in the common event itself by copy-pasting the example and editing the values. I know it would have been much neater as a plugin, but I wanted to see if it was possible using mostly event commands for people like me who don't fully understand all of JS yet. Once I get a grasp on recursively accessing the arrays inside of structs utilizing JSON.parse, then maybe I'll give it a go at creating a plugin. I have found it surprisingly hard to find any video tutorials demonstrating how.
Thanks again for all your help! -
For Alistair's Mana Barrier, is there a way to make a skill bypass the barrier?
-
Lol i doubt that people even know what "Alistair's Mana Barrier" is, when you just asked like that