• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Forum moderator applications are now open! Click here for details.
  • 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!!!

163
Posts
5
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?!
 
1,405
Posts
9
Years
  • Seen today
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:
163
Posts
5
Years
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! :(
 
1,405
Posts
9
Years
  • Seen today
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.
 
1,405
Posts
9
Years
  • Seen today
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:

Boonzeet

Pokémon Secrets of the Ages Developer
188
Posts
14
Years
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
 
163
Posts
5
Years
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!
 
163
Posts
5
Years
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!
 
163
Posts
5
Years
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!
 
163
Posts
5
Years
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.
 

Poq

144
Posts
6
Years
  • Age 34
  • Seen Aug 28, 2021
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.
 
163
Posts
5
Years
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