• Hi, Guest!
    Some images might be missing as we move away from using embedded images, sorry for the mess!
    From now on, you'll be required to use a third party to host images. You can learn how to add images here, and if your thread is missing images you can request them here.
    Do not use Discord to host any images you post, these links expire quickly!
Fluid Badges

Resource Fluid Badges 2022-12-07

TechSkylander1518 submitted a new resource:

Fluid Badges - Allows Badges to be collected and displayed in any order

View attachment 14228
Script to let players earn badges in any order they like. Badges will be displayed in the order received.

This is currently only written for default Essentials UI. It's totally possible to adapt it for another layout, you'll just need to work to integrate it into the other script.​

Code​

If you prefer plug-and-play scripts, you can paste this in a new script section above Main.
...

Read more about this resource...
 

taynathon

professional lackey
Member
Joined
Nov 4, 2022
Posts
14
is it backwards compatible with v18.1?
 
is it backwards compatible with v18.1?
Not the plug-and-play version - there's been way too many changes between v18 and v20 for most scripts to be compatible between the two, unless they're mostly with non-Pokemon mechanics like event movement. But you can try to adapt the Instructions section for v18. The names for certain methods/objects are different between the two (badge_count was numbadges in v18, $player was $Trainer, etc.), so you'll have to try to translate it back.
 

taynathon

professional lackey
Member
Joined
Nov 4, 2022
Posts
14
Not the plug-and-play version - there's been way too many changes between v18 and v20 for most scripts to be compatible between the two, unless they're mostly with non-Pokemon mechanics like event movement. But you can try to adapt the Instructions section for v18. The names for certain methods/objects are different between the two (badge_count was numbadges in v18, $player was $Trainer, etc.), so you'll have to try to translate it back.
Aight ill give it a try, thanks
 

Smithereens

Novice
Member
Joined
Dec 4, 2022
Posts
37
Hey! So this works great, but there were two errors in the scripts as given that I had to track down.

First, in UI_TrainerCard, you don't define the imagePositions array, which causes the game to crash upon displaying the Trainer Card. That script should be:

Ruby:
    x = 72
    imagePositions = []
    for i in 0...$player.badges.length
      badge = $player.badges[i].to_s
      @sprites["badge#{i}"] = IconSprite.new(x, 310, @viewport)
      @sprites["badge#{i}"].setBitmap("Graphics/Pictures/Trainer Card/#{badge}")
      x += 48
    end

Second, the pbGiveBadge function defines the badge image as {badge} and then calls it as {badgename}. That section should read:

Ruby:
def pbGiveBadge(badge)
  raise "#{badge} Badge has no graphic" if !pbResolveBitmap("Graphics/Pictures/Trainer Card/#{badge}")
  $player.badges.push(badge)
end

With those two fixes, this appears to work like a charm!
 
Hey! So this works great, but there were two errors in the scripts as given that I had to track down.

First, in UI_TrainerCard, you don't define the imagePositions array, which causes the game to crash upon displaying the Trainer Card. That script should be:

Ruby:
    x = 72
    imagePositions = []
    for i in 0...$player.badges.length
      badge = $player.badges[i].to_s
      @sprites["badge#{i}"] = IconSprite.new(x, 310, @viewport)
      @sprites["badge#{i}"].setBitmap("Graphics/Pictures/Trainer Card/#{badge}")
      x += 48
    end

Second, the pbGiveBadge function defines the badge image as {badge} and then calls it as {badgename}. That section should read:

Ruby:
def pbGiveBadge(badge)
  raise "#{badge} Badge has no graphic" if !pbResolveBitmap("Graphics/Pictures/Trainer Card/#{badge}")
  $player.badges.push(badge)
end

With those two fixes, this appears to work like a charm!
Thanks so much for catching those! I had actually meant to delete the other line referring to imagePositions as well, since it's not used anymore, seems like I missed it copying over. The badgename thing is actually supposed to make the error a little more readable with capitalization (it gets defined on the line above), but it's definitely way easier to just capitalize in the message than put in two variables with almost the same name. (Especially seeing as I did mix them up and had it check for the wrong file name) Should be fixed in the post, thanks again!
 

Mike0siris

Rookie
Member
Joined
Feb 24, 2023
Posts
3
Hello. Whenever I try to run the game, it stops from running, saying that the "Trainer" on line 10 of the code is an ininitialized constant. Do you know anything I can do to fix this? Should I just replace the other lines of code instead of just using the plug-and-play script?
 

Terra

Novice
Member
Joined
Apr 15, 2023
Posts
15
1.PNG

attempting to use in v21.1... this error is... not helpful (~_~;)
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
614
Well, you can't expect an outdated script to still work in recent versions, that's the basics of the basics
The error is telling them that there is some error in how some code ends. That doesn't have to do with the Essentials version being used but instead that the code was likely edited and an "end" or "}" that should be in the code was deleted.
 

Willøw

Mew and Slither Wing Fan
Member
Joined
Nov 1, 2023
Posts
95
The error is telling them that there is some error in how some code ends. That doesn't have to do with the Essentials version being used but instead that the code was likely edited and an "end" or "}" that should be in the code was deleted.
I don't think he's messed with the script, since he has no idea what errors might pop up. But it could be a possibility
 

Terra

Novice
Member
Joined
Apr 15, 2023
Posts
15
Well, you can't expect an outdated script to still work in recent versions, that's the basics of the basics
actually it's working fine now. the trainercard ui was just missing an extra "end". i probably accidentally deleted it.
 
Back
Top