Is there a script I can add to a plugin to increase the spacing between commands on the main menu?
I have made the menu commands as icons but they are too close together and I'm just wondering how I can spread them further apart.
JavaScript questions that don't deserve their own thread
● ARCHIVED · READ-ONLY
-
-
The easiest way to achieve this is to just define a new itemHeight method for Window_MenuCommand.
Code:Window_MenuCommand.prototype.itemHeight = function() { return this.lineHeight() + x } //replace x with a value for the extra space you want (eg. 10) -
I'm making a skill that is like this: A warlock puts a curse on an enemy. If the enemy is attacked, then the curse is lift, but the enemy loses life and the attacker gains that amount of life. I know that I should use yanfly's buff and states core, and in the state (of the curse) I should put a code between this:
<Custom Remove Effect>
</Custom Remove Effect>
but I have problems checking who the attacker is. Please help. Thanks -
I'm making a skill that is like this: A warlock puts a curse on an enemy. If the enemy is attacked, then the curse is lift, but the enemy loses life and the attacker gains that amount of life. I know that I should use yanfly's buff and states core, and in the state (of the curse) I should put a code between this:
<Custom Remove Effect>
</Custom Remove Effect>
but I have problems checking who the attacker is. Please help. Thanks
Hello, I would use this notetag instead:
Code:<Custom Respond Effect> if (this.isPhysical() && target.result().hpDamage > 0) { dam = target.result().hpDamage; user.gainHp(dam) target.removeState(state ID); } </Custom Respond Effect> -
I have a character who is an Alchemist. I have it set up with Victor Engine's Mix Action so that he can combine two items in combat for a predetermined effect.
What I would like to happen is that when he combines the items, it gets added to a list in the menu that the player can view (but not use; it's a battle skill only). I'm also using YEP_SkillCore, and I thought I could have him "learn" his Alchemy Skills by putting something like this in the notes of each skill:
<Post-Damage Eval>
if (!user.isLearnedSkill(skill.id)) {
user.learnSkill(skill.id);
var text = user.name() + ‘ discovered the formula for ‘
text = text + skill.name + ‘!’;
$gameMessage.add(text);
}
</Post-Damage Eval>
Basically, whenever he mixes an item in battle to get an effect, I want the game to check to see if he already knows the skill, and if not, to add it to the menu for viewing. The above code returns a syntax error, though, and I'm not sure what I'm missing. -
You've got ‘opening/closing’ quote marks there, rather than 'neutral' ones. Try this instead:<Post-Damage Eval>
if (!user.isLearnedSkill(skill.id)) {
user.learnSkill(skill.id);
var text = user.name() + ‘ discovered the formula for ‘
text = text + skill.name + ‘!’;
$gameMessage.add(text);
}
</Post-Damage Eval>
JavaScript:if (!user.isLearnedSkill(skill.id)) { user.learnSkill(skill.id); var text = user.name() + ' discovered the formula for '; text += skill.name + '!'; $gameMessage.add(text); } -
Need a bit of help understanding something. I have this code here I'm trying to insert into an old method, but I get an error of "cannot read property call is undefined".
Code:const gameActionElementReactionMessageDisplay = Game_Action.prototype.makeDamageVaule; Game_Action.prototype.makeDamageValue = function(target,critical) { gameActionElementReactionMessageDisplay.call(this,target,critical); if (this.calcElementRate(target) > 0) { SceneManager._scene._logWindow.addText("Poop!") }; };
I don't know if it has something to do with the args. I've mainly been using this method on methods without them. But I'm not sure why this call isn't working? -
It's
makeDamageValuenotmakeDamageVaule;) -
It's
makeDamageValuenotmakeDamageVaule;)
@TheoAllen - Oh my god. That was it. :eswt:
Though now nobody's doing any damage. But at least for now, it is saying "Poop".
So that's progress. Thanks! -
You've got ‘opening/closing’ quote marks there, rather than 'neutral' ones. Try this instead:
JavaScript:if (!user.isLearnedSkill(skill.id)) { user.learnSkill(skill.id); var text = user.name() + ' discovered the formula for '; text += skill.name + '!'; $gameMessage.add(text); }
Got it. I tried that and then it gave me a reference error, saying "skill is not defined."
So then I thought maybe I needed to specify THIS skill ("THIS" meaning whatever skill effect the user is trying to create), so I tried the following code...
JavaScript:if (!user.isLearnedSkill(this.skill.id)) { user.learnSkill(this.skill.id); var text = user.name() + ' discovered the formula for '; text += this.skill.name + '!'; $gameMessage.add(text); }
... which gave me this:
... and I don't know what that means. -
Oh, just checked the code of Yanfly's Skill Core; looks like you should replaceGot it. I tried that and then it gave me a reference error, saying "skill is not defined."
skillwithitem, i.e.
JavaScript:if (!user.isLearnedSkill(item.id)) { user.learnSkill(item.id); var text = user.name() + ' discovered the formula for '; text += item.name + '!'; $gameMessage.add(text); } -
I did some more experimentation with my code from yesterday. And I made sure value was spelled right this time! It seems that the damage value gets lost somewhere. Using "return 10" will result in 10 damage. But using "return value" results in an error message that value is undefined.
Does anybody know why value is undefined if I'm still referencing the old method that has it?
Code:const gameActionElementReactionMessageDisplay = Game_Action.prototype.makeDamageValue; Game_Action.prototype.makeDamageValue = function(target,critical) { gameActionElementReactionMessageDisplay.call(this,target,critical); if (this.calcElementRate(target) > 1) { SceneManager._scene._logWindow.addText("They didn't enjoy that all!") }; if (this.calcElementRate(target) < 1) { SceneManager._scene._logWindow.addText("They shrugged it off.") }; return value; }; -
Hi, value is undefined because it is not defined anywhere above... You have to declare it inside the function or send it to the function as argument. The function you show above use target and critical as its arguments by default.Does anybody know why value is undefined if I'm still referencing the old method that has it?
-
Does that mean you can't reference variables from the original methods when you do things like this?
-
Well, if by original method you mean the Game_Action.prototype.makeDamageValue from object.js,Does that mean you can't reference variables from the original methods when you do things like this?
value is declare inside the function like this:
var value = baseValue * this.calcElementRate(target);
One way or the other, if value is not defined either inside the function, in the scope above it or send as an argument, you can't reference it.
*where do you put that code and how do you call the method? -
I'm trying to use it like how you'd use an alias in Ruby. So it is just exactly like how it's posted at the end of my scripts. So it should be getting called when the original makeDamageValue is called.
-
Code:Here is what you need to do
const gameActionElementReactionMessageDisplay = Game_Action.prototype.makeDamageValue; Game_Action.prototype.makeDamageValue = function(target,critical) { var value = gameActionElementReactionMessageDisplay.call(this,target,critical); if (this.calcElementRate(target) > 1) { SceneManager._scene._logWindow.addText("They didn't enjoy that all!") }; if (this.calcElementRate(target) < 1) { SceneManager._scene._logWindow.addText("They shrugged it off.") }; return value; };
EDIT:
Even if it was a Ruby code, you will still get undefined method error. The same logic applies here and there.I'm trying to use it like how you'd use an alias in Ruby. -
That seems to have worked. Thanks! I guess as just one more question if I wanted to get multiple variables out of a function or method, I'd just have to make similar lines, except for each variable I'm trying to reference?
-
Well, no. Their scope is local, so you can not get them in any way. Usually, they're only there as a temporary variable to store the value necessary to compute whatever they're computing within the function. What you can get is the return value, not the entire local variable defined in that function. This is true for any programming language as far as I know.if I wanted to get multiple variables out of a function or method
You can, but this entirely depends on the scenario. You can make a similar line and it's going to work fine, but some cases may not.I'd just have to make similar lines
I don't understand this sentence.except for each variable I'm trying to reference? -
Sorry if I'm butchering the language. I meant that on top of the value, I could get other things like the targets/items name and stuff like that. But it's really fine if it doesn't work out like that - since I can just think up a generic message for what I'm trying to do.
Thanks for the help/explanation though.