JavaScript questions that don't deserve their own thread

Discussion in 'Javascript/Plugin Support' started by Shaz, Oct 23, 2015.

  1. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,641
    Likes Received:
    9,155
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
  2. Sword of Spirit

    Sword of Spirit Veteran Veteran

    Messages:
    114
    Likes Received:
    14
    First Language:
    English
    Primarily Uses:
    RMMV
    Drop them in ProjectFolder > js >plugins
     
  3. Bonkers

    Bonkers Bioware, do you need a nap? Restaff

    Messages:
    2,947
    Likes Received:
    2,883
    Location:
    New York
    First Language:
    English
    Primarily Uses:
    RMMV
    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?
     
  4. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,641
    Likes Received:
    9,155
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    @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 ===
     
    Bonkers likes this.
  5. Bonkers

    Bonkers Bioware, do you need a nap? Restaff

    Messages:
    2,947
    Likes Received:
    2,883
    Location:
    New York
    First Language:
    English
    Primarily Uses:
    RMMV
    @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.
     
  6. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,641
    Likes Received:
    9,155
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    @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.
     
    Bonkers likes this.
  7. Bonkers

    Bonkers Bioware, do you need a nap? Restaff

    Messages:
    2,947
    Likes Received:
    2,883
    Location:
    New York
    First Language:
    English
    Primarily Uses:
    RMMV
    @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>
     
  8. Sword of Spirit

    Sword of Spirit Veteran Veteran

    Messages:
    114
    Likes Received:
    14
    First Language:
    English
    Primarily Uses:
    RMMV
    <Deleted>

    Nevermind, I just found what I did wrong--I had a letter uncapitalized.
     
  9. Dama

    Dama Veteran Veteran

    Messages:
    42
    Likes Received:
    42
    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
     
  10. Sword of Spirit

    Sword of Spirit Veteran Veteran

    Messages:
    114
    Likes Received:
    14
    First Language:
    English
    Primarily Uses:
    RMMV
    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.)
     
  11. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,403
    Likes Received:
    2,817
    Location:
    Philippines
    First Language:
    Tagalog
    So you want to check if the weapon equipped is of a certain weapon type and if yes, unequip it?
     
    Sword of Spirit likes this.
  12. Sword of Spirit

    Sword of Spirit Veteran Veteran

    Messages:
    114
    Likes Received:
    14
    First Language:
    English
    Primarily Uses:
    RMMV
    Yes, exactly!
     
  13. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,403
    Likes Received:
    2,817
    Location:
    Philippines
    First Language:
    Tagalog
    Do you have dual wield in your game, or all actors can only have 1 weapon equipped at a time?
     
  14. Sword of Spirit

    Sword of Spirit Veteran Veteran

    Messages:
    114
    Likes Received:
    14
    First Language:
    English
    Primarily Uses:
    RMMV
    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.
     
  15. KockaAdmiralac

    KockaAdmiralac Cube-shaped garbage can Veteran

    Messages:
    570
    Likes Received:
    156
    Location:
    Belgrade
    First Language:
    Serbian
    Primarily Uses:
    N/A
    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).
     
    Sword of Spirit likes this.
  16. Sword of Spirit

    Sword of Spirit Veteran Veteran

    Messages:
    114
    Likes Received:
    14
    First Language:
    English
    Primarily Uses:
    RMMV
    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!
     
  17. Sword of Spirit

    Sword of Spirit Veteran Veteran

    Messages:
    114
    Likes Received:
    14
    First Language:
    English
    Primarily Uses:
    RMMV
    <Nevermind, just figured something out>
     
  18. Sword of Spirit

    Sword of Spirit Veteran Veteran

    Messages:
    114
    Likes Received:
    14
    First Language:
    English
    Primarily Uses:
    RMMV
    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.
     
  19. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,641
    Likes Received:
    9,155
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    There are two possibilities.
    Code:
    if ($gameParty.members()[0].actorId() == 1) {}
    
    if ($gameActors.actor(1) == $gameParty.members()[0]) {}
     
  20. KockaAdmiralac

    KockaAdmiralac Cube-shaped garbage can Veteran

    Messages:
    570
    Likes Received:
    156
    Location:
    Belgrade
    First Language:
    Serbian
    Primarily Uses:
    N/A
    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.
     

Share This Page