• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] I NEED SOME DAMN HELP!!!

  • 158
    Posts
    6
    Years
    I managed to get my ability Lucky Heal to work, but the way it functions is that it should only heal the user ONCE per battle if its HP is in red, but every time I test it out, it heals it multiple times! :(

    Here's the code:
    # Lucky Heal
    if i.hasWorkingAbility(:LUCKYHEAL) && i.hp<=(i.totalhp/3).floor
    if i.effects[PBEffects::LuckyHeal]==0 && i.effects[PBEffects::HealBlock]==0
    PBDebug.log("[Ability triggered] #{i.pbThis}'s Lucky Heal")
    hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
    pbDisplay(_INTL("{1}'s {2} healed itself!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
    elsif i.effects[PBEffects::LuckyHeal]==1
    end
    end

    Please, what am I doing wrong?!
     
    You don't set the LuckyHeal effect to 1 after gaining HP, so the code for "Lucky Heal has not triggered yet in this battle" runs every time.

    (Also once you've fixed this you might want to test if you can use the ability again after switching out and back in)
     
    Last edited:
    You don't set the LuckyHeal effect to 1 after gaining HP, so the code for "Lucky Heal has not triggered yet in this battle" runs every time.

    (Also once you've fixed this you might want to test if you can use the ability again after switching out and back in)

    Okay but Idk how to make it only usable once!

    I tried:
    # Lucky Heal
    if i.hasWorkingAbility(:LUCKYHEAL) && i.hp<=(i.totalhp/3).floor
    if i.effects[PBEffects::LuckyHeal]==0 && i.effects[PBEffects::HealBlock]==0
    PBDebug.log("[Ability triggered] #{i.pbThis}'s Lucky Heal")
    hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
    pbDisplay(_INTL("{1}'s {2} healed itself!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
    elsif i.effects[PBEffects::LuckyHeal]>0
    end
    end
    But it still kept doing it multiple times a battle and not once! :(
     
    Okay but Idk how to make it only usable once!

    I basically told you what do to:
    mgriffin said:
    You don't set the LuckyHeal effect to 1 after gaining HP
    You need to set the "i.effects[PBEffects::LuckyHeal]" to 1 after healing the first time so that the second time the code runs your if doesn't match, and the elsif does.
     
    Question: What's a Ruby tutorial?

    Ruby is the programming language that you script in. Marin wrote a tutorial on PC but of course there are others out there.

    At any rate I would recommend you take some responsibility for learning how to script (and Google in general, if you had searched "ruby tutorial" you would have known what I was talking about) and not coming onto the forums asking people to write all the code for you. But that's just my opinion, do what suits you.
     
    Last edited:
    I don't understand how you'd have created this ability without know how to increment the variable.

    Code:
    if i.hasWorkingAbility(:LUCKYHEAL) && i.hp<=(i.totalhp/3).floor
      if i.effects[PBEffects::LuckyHeal]==0 && i.effects[PBEffects::HealBlock]==0
        PBDebug.log("[Ability triggered] #{i.pbThis}'s Lucky Heal")
        hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
        pbDisplay(_INTL("{1}'s {2} healed itself!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
        [B]i.effects[PBEffects::LuckyHeal] += 1[/B]
      elsif i.effects[PBEffects::LuckyHeal]>0
      end
    end
     
    Ruby is the programming language that you script in. Marin wrote a tutorial on PC but of course there are others out there.

    At any rate I would recommend you take some responsibility for learning how to script (and Google in general, if you had searched "ruby tutorial" you would have known what I was talking about) and not coming onto the forums asking people to write all the code for you. But that's just my opinion, do what suits you.

    Okay!
     
    I don't understand how you'd have created this ability without know how to increment the variable.

    Code:
    if i.hasWorkingAbility(:LUCKYHEAL) && i.hp<=(i.totalhp/3).floor
      if i.effects[PBEffects::LuckyHeal]==0 && i.effects[PBEffects::HealBlock]==0
        PBDebug.log("[Ability triggered] #{i.pbThis}'s Lucky Heal")
        hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
        pbDisplay(_INTL("{1}'s {2} healed itself!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
        [B]i.effects[PBEffects::LuckyHeal] += 1[/B]
      elsif i.effects[PBEffects::LuckyHeal]>0
      end
    end

    Might try that!
     
    I don't understand how you'd have created this ability without know how to increment the variable.

    Code:
    if i.hasWorkingAbility(:LUCKYHEAL) && i.hp<=(i.totalhp/3).floor
      if i.effects[PBEffects::LuckyHeal]==0 && i.effects[PBEffects::HealBlock]==0
        PBDebug.log("[Ability triggered] #{i.pbThis}'s Lucky Heal")
        hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
        pbDisplay(_INTL("{1}'s {2} healed itself!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
        [B]i.effects[PBEffects::LuckyHeal] += 1[/B]
      elsif i.effects[PBEffects::LuckyHeal]>0
      end
    end

    It doesn't work!
     
    I decided to give up on Lucky Heal since it seems impossible to make it only work once.

    It is now the ability Synthesise, which is like the Leftovers that restore HP a little every time a round ends. Just letting you all know that.
     
    I decided to give up on Lucky Heal since it seems impossible to make it only work once.
    It is definitely not impossible. In fact, you're very close to accomplishing it.

    Now, Bonzeet showed you how to increment the lucky heal effect. But here's the other side if it - did you ever add LuckyHeal to the list of in battle effects? And did you initialize it (seeing it to 0) in the battle script?

    As has been suggested, you need to look closer at essentials and learn more about ruby to understand how they work. We've all gone through that process. You're clearly driven and ambitious, so learning a bit more will definitely help you achieve your ambitions.
     
    It is definitely not impossible. In fact, you're very close to accomplishing it.

    Now, Bonzeet showed you how to increment the lucky heal effect. But here's the other side if it - did you ever add LuckyHeal to the list of in battle effects? And did you initialize it (seeing it to 0) in the battle script?

    As has been suggested, you need to look closer at essentials and learn more about ruby to understand how they work. We've all gone through that process. You're clearly driven and ambitious, so learning a bit more will definitely help you achieve your ambitions.

    Thanks dude!
     
    Back
    Top