JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 57 of 171 View original ↗
  1. Drop them in ProjectFolder > js >plugins
  2. Quick question as I am using Yanfly's skill core. I'd like to add this note tag to healing spells, so when the 8th actor casts healing spells on someone to full or over heals they restore 10% mana.

    <After Eval>
    if (target.hp === mhp){
    $gameActors.actorid(8).gainMp(Math.round(.1*(m.mmp)))}
    </After Eval>

    Unfortunately it didn't work, have I miswritten the command?
  3. @Bonkers
    1. You have target.mp, but only mhp. Whose mhp?
    2. Not actorid, but actor
    3. What is m.mmp? I know what is mmp, but what is m?
    4. It's better to write 0.1 instead of .1, it's more readable.
    5. If you want to cover both full heals and overheals, it might be better to use >= instead of ===
  4. @Poryg
    1. Max hp of the target the healing spell effects.
    does this mean that 'target' is only for enemy battlers? I can use actor.hp as well then.
    2. Thank you, the master script call list was what I was using to flesh out the statement. I have changed this.
    3. Max mp? I'll change that as well.
    4. Much appreciated.
    5. A very good point. That's much better, thank you.

    <After Eval>
    if (target.hp >= mhp){
    $gameActors.actor(8).gainMp(Math.round(0.1*(mmp)))}
    </After Eval>

    I've also tried actor.hp, but the effect doesn't occur.
  5. @Bonkers None of these were questions to answer, but pointers to your errors.
    Alright, more explicitly.
    1. You wrote target.hp, but only mhp. target.hp is ok, but just mhp is not, because you need to specify to whom it belongs to.
    3. Same here. The point was not mmp being wrong. It was that you wrote m.mmp, which I suppose neither the computer nor me can recognize what the first m was.
  6. @Poryg Understood, and thank you. Those points help immensely and I got it working. =D
    I knew the targets but the computer did not, and I just haven't learned that the computer doesn't know what it knows till I tell it so.

    <Post-Damage Eval>
    if (target.hp >= target.mhp){
    $gameActors.actor(8).gainMp(Math.round(0.1*($gameActors.actor(8).mmp)))}
    </Post-Damage Eval>
  7. <Deleted>

    Nevermind, I just found what I did wrong--I had a letter uncapitalized.
  8. Is there any way to be able to use "Comment : tool_position : move_to_target" of chrono engine in its abs mode? or script command? using script command to move to target gives "cannot read property '_x' of undefined" error
  9. What's the command to unequip an actor's weapon/weapons based on weapon type ID?
    (I can't do it with events, because I need to run it with a plugin at an odd time in processing.)
  10. So you want to check if the weapon equipped is of a certain weapon type and if yes, unequip it?
  11. Engr. Adiktuzmiko said:
    So you want to check if the weapon equipped is of a certain weapon type and if yes, unequip it?

    Yes, exactly!
  12. Do you have dual wield in your game, or all actors can only have 1 weapon equipped at a time?
  13. Yes, there are a couple of States that allow Dual Wield, and they are some of the ones relevant to this. If it's a problem though, I think I can just worry about the first weapon slot, although it may be more forward compatible to handle both.
  14. JavaScript code that lets you unequip all weapons of a certain weapon type ID seems to be:
    Code:
    var actor = $gameActors.actor(1);
    actor.equips().forEach(function(equip) {
        if (equip && equip.wtypeId && equip.wtypeId === 2) {
            actor.discardEquip(equip);
        }
    });
    Where 1 is the actor ID and 2 is the weapon type ID.
    I don't know with what plugin are you trying to do it and at what time, so I can't assist further than that (also, I've been away for quite long from RPG Maker MV).
  15. That's it! I'm using Yanfly Skill Core to use it with a skill before the rest of the skill's effects start. The skill puts the character into a state that I made that (through Yanfly Equip Requirements) doesn't allow certain weapon types to be equipped when in that state. Unfortunately, if the character had one of those weapon types equipped when they activated the skill before, it would unequip all of their equipment (armor, etc)--not just the offending weapon. So I needed this to remove the weapons first so that adding the state wouldn't cause the character to disrobe. Works great, thanks!
  16. <Nevermind, just figured something out>
  17. Could anyone tell me how to determine if a particular actor is in a particular slot in the battle party, for purposes of an if statement? For some reason I can find a lot of different things that look like they would work, but none of them actually seem to.
  18. There are two possibilities.
    Code:
    if ($gameParty.members()[0].actorId() == 1) {}
    
    if ($gameActors.actor(1) == $gameParty.members()[0]) {}
  19. In addition to what Poryg said, $gameParty.members() returns all members if outside the battle, if you want specifically battle members you can use $gameParty.battleMembers() instead.
  20. I can't seem to get either of those to work. I'm checking to see if Actor 1 is in position 0:

    Code:
    if ($gameParty.battleMembers()[0].actorId() == 1) {99}; else {5};
    
    if ($gameActors.actor(1) == $gameParty.battleMembers()[0]) {99}; else {5};

    That's what I'm trying to use, but to no effect. This is putting a number into a variable via a troop event, and I haven't had any problems using expressions like "$gameParty.battleMembers()[0].def-10" in those events once I figured them out. But this one has me stumped.

    Alternatively, I could work with finding out whether a battle member has a state. That might even be a better method, but I'm having a hard time getting that to work either. Darn battleMembers.