v20.1 Help with Custom Credits

This thread pertains to v20.1 of Pokémon Essentials.

Gardenette

Trainer
Member
Joined
May 30, 2022
Posts
50
Age
27
I need some help with my custom credits script.
What I'm trying to accomplish: I want a custom icon to appear next to specific people's names. If there exists a file in Graphics/Pictures/Credits/person's name, I want to put that icon next to their name.

Here is my problem:
When I run the credits, the first file aligns perfectly. The second file is not at the same height as the name Gardenette, and it only gets worse as it goes on. Here is a picture.
1662139161031.png

The image of 4 red arrows should appear next to Saltilton, which it does.
The image of the player head should appear next to Gardenette, and it appears 32 pixels lower than it should.

Both images are 32x32.
1662139258438.png

1662139280509.png

1662139306776.png


Here is the code:
=====================================================================================================
#==============================================================================
# * Scene_Credits
#------------------------------------------------------------------------------
# Scrolls the credits you make below. Original Author unknown.
#
## Edited by MiDas Mike so it doesn't play over the Title, but runs by calling
# the following:
# $scene = Scene_Credits.new
#
## New Edit 3/6/2007 11:14 PM by AvatarMonkeyKirby.
# Ok, what I've done is changed the part of the script that was supposed to make
# the credits automatically end so that way they actually end! Yes, they will
# actually end when the credits are finished! So, that will make the people you
# should give credit to now is: Unknown, MiDas Mike, and AvatarMonkeyKirby.
# -sincerly yours,
# Your Beloved
# Oh yea, and I also added a line of code that fades out the BGM so it fades
# sooner and smoother.
#
## New Edit 24/1/2012 by Maruno.
# Added the ability to split a line into two halves with <s>, with each half
# aligned towards the centre. Please also credit me if used.
#
## New Edit 22/2/2012 by Maruno.
# Credits now scroll properly when played with a zoom factor of 0.5. Music can
# now be defined. Credits can't be skipped during their first play.
#
## New Edit 25/3/2020 by Maruno.
# Scroll speed is now independent of frame rate. Now supports non-integer values
# for SCROLL_SPEED.
#
## New Edit 21/8/2020 by Marin.
# Now automatically inserts the credits from the plugins that have been
# registered through the PluginManager module.
#==============================================================================
class Scene_Credits
# Backgrounds to show in credits. Found in Graphics/Titles/ folder
BACKGROUNDS_LIST = ["credits1", "credits2", "credits3", "credits4", "credits5"]
BGM = "Credits"
SCROLL_SPEED = 190 # Pixels per second, was 40
SECONDS_PER_BACKGROUND = 11
TEXT_OUTLINE_COLOR = Color.new(0, 0, 128, 255)
TEXT_BASE_COLOR = Color.new(255, 255, 255, 255)
TEXT_SHADOW_COLOR = Color.new(0, 0, 0, 100)

# This next piece of code is the credits.
# Start Editing
CREDIT = <<END
Saltilton
Gardenette
Scripts & Coding
----------------
Advanced Map Transfers:
Luka S.J.

Always in Bushes:
Kotaro
KleinStudio

Ambient Pokémon Cries:
Vendily
SpaceWestern

Astralneko's Scripting Utilities:
Astralneko

Bag Screen with Interactable Party:
DiegoWT
Rose
Vendily

Better Region Map:
Marin
Boonzeet

New DexNav:
Phantombass
suzerain
NuriYuri
raZ
Vendily
Savordez
Marin
Zaffre
ThatWelshOne_

DiegoWT's Starter Selection:
DiegoWT

DPPT Gender Selector Scene:
A.Somersault

Easy Text Skip:
Amethyst
Kurotsune
ENLS

Easy Mouse System:
Luka S.J.

Evolve from Party:
IndianAnimator
eriedaberrie#1569

EVs and IVs in Summary:
Deoxysprime

Following Pokémon EX:
Golisopod User
Help-14
zingzags
Rayd12smitty
Venom12
mej71
PurpleZaffre
Akizakura16
Thundaga
Armin
Maruno

Item Find:
Boonzeet

Location Signposts:
LostSoulsDev
carmaniac
PurpleZaffre
Golisopod User

Luka's Scripting Utilities:
Luka S.J.

Marin's Scripting Utilities:
Marin

Modern Quest System + UI:
ThatWelshOne_
mej71
derFischae
Marin

Overworld Shadows EX:
Golisopod User
Wolf PP
Marin

Monitor Icons:
Ulithium_Dragon
bo4p5687
ThatWelshOne_
raZ
Marin
Maruno
Nuri Yuri
PurpleZaffre
Savordez
Vendily
SpaceWestern
Gardenette

Pokémon Amie:
PizzaSun
rigbycwts
BhagyaJyoti
Luka S.J
bo4p5687

Quicksave:
Low

Speed Up 2.0:
Marin
Phantombass

Video with Using Gif:
bo4p5687

Voltseon's A-Star Pathfinding:
Voltseon
Golisopod User
ENLS

Voltseon's Pause Menu:
Voltseon
Golisopod User
ENLS










Graphics
--------
Tilesets:
Tyler Jones - Environmental Designer
GreenJellybean
ventesthefloof
Griffin L
Kaloja
Saltilton
Aveon Trainer
Derlo
King Tapia
Magiscarf
Princess Phoenix
Donlawride
aball
Cristata
Groogey
ShadySheep
the.sizzlepanda
Rider Dragon

Pokémon & Pokédex:
Jack
Claire
Evelyn315
Akikaze
Firedude
LuckyBenjamin the Appletun
Loretze
Applesaucior
farbol234
SoundJack426
8xviktor
ventesthefloof
RockTomb
Ian (The Picky Pixel Artist)
Saltilton
theWaterleaf
Soda
Lorka_Grey
KameOtaku
Dan Bacon
MillerMiller
Cristata
I’m Para
Jeremy K
Hub-Bub
Master_Machi
Pelican
Bean Soup
A Happi Rapter
aball
Bee
Chespin (Ethan)
Chromatech01
Eshan
Fikolyte
Floriak
gribbin
Grimrose
Igor!
MarsTemple
Regal-Turtwig
ShadySheep
SietseML
Solvaa
SomeAllay
WillTheWall

Trainers/NPCs:
Jack
Claire
Loretze
ventesthefloof
RockTomb
Saltilton
HingisDingus
Chespin (Ethan)
Akikaze
KameOtaku
Gardenette
Zacharie
MillerMiller
Bee
TheRoyalDex
MILKMAN

UI & Misc.:
Random Talking Bush
aball
Adam
Dan Bacon
Basalte
HwiteHwale
MillerMiller
Gardenette
MANGO
MarsTemple
Riot
Master_Machi
Chespin (Ethan)
Jackster
Saltilton










Music
-----
Soundtrack:
Rhythm Break
ReMX Bossa Nova

Pokémon Cries:
Gardenette
Text 206










Mapping
-------
stygma
ImaDeadMan
Gardenette
Kaloja
GreenJellybean
MANGO
RISH
Shadows










Eventing
--------
Low
SpaceWestern
stygma
Gardenette










Story & Quests
--------------
Angel
BlueLightning
Firedude
Kyl-E
Gardenette
ThisGrainCharacter (Gluten Free)
DeinoNuggies
HwiteHwale
Krabby Enthusiast
Luc_
Shilo
sneakysnek










Game Data & Balancing
---------------------
Malarkey3072
Kyl-E
Low
SpaceWestern
stygma
Gardenette
MacheteMcGoo
noahthenumbat
DomTom
<3 w <3
Adam
caesar
Empyrean
Garreon
Hare64
HwiteHwale
MarsTemple
Midbus
mSilk
Robochef9000
Señor Gallo de Caballo
Shadows
Waffler
Zyuran










Translating
-----------
Blind guy,i guess
Fitch
Basalte
Floriak
Hey
Truegear
Wowo










Playtesting
-----------
Chespin (Ethan)
ventesthefloof
BlueLightning
Saltilton
Blind guy,i guess
Jamadxx










Team Organization
-----------------
stygma
Katie
HingisDingus
Gardenette
Master_Machi
Bee
Luc_
MarsTemple
Firedude










Mazah Region Created by
-----------------------
Subjectively
Jack
Claire










Special Thanks
--------------
"Pokémon Essentials" was created by:
Flameguru
Poccil (Peter O.)
Maruno

With contributions from:
AvatarMonkeyKirby
Marin
Boushy
MiDas Mike
Brother1440
Near Fantastica
FL.
PinkMan
Genzai Kawakami
Popper
Golisopod User
Rataime
help-14
Savordez
IceGod64
SoundSpawn
Jacob O. Wobbrock
the__end
KitsuneKouta
Venom12
Lisa Anthony
Wachunga
Luka S.J.
Derxwna Kapsyla
and everyone else who helped out

"mkxp-z" by:
Roza
Based on MKXP by Ancurio et al.

"RPG Maker XP" by:
Enterbrain

Pokémon is owned by:
The Pokémon Company
Nintendo
Affiliated with Game Freak



This is a non-profit fan-made game.
No copyright infringements intended.
Please support the official games!
{INSERTS_PLUGIN_CREDITS_DO_NOT_REMOVE}
END
# Stop Editing

def main
@creditsEnd = 0
#-------------------------------
# Animated Background Setup
#-------------------------------
@counter = 0.0 # Counts time elapsed since the background image changed
@bg_index = 0
@bitmap_height = Graphics.height # For a single credits text bitmap
@trim = Graphics.height / 10
# Number of game frames per background frame
@realOY = -(Graphics.height - @trim)
#-------------------------------
# Credits text Setup
#-------------------------------
plugin_credits = ""
PluginManager.plugins.each do |plugin|
pcred = PluginManager.credits(plugin)
CREDIT.gsub!(/\{INSERTS_PLUGIN_CREDITS_DO_NOT_REMOVE\}/, plugin_credits)
@credit_lines = CREDIT.split(/\n/)
plugin_credits << "\"#{plugin}\" v.#{PluginManager.version(plugin)} by:\n"
if pcred.size >= 5
plugin_credits << pcred[0] + "\n"
i = 1
until i >= pcred.size
plugin_credits << pcred + "<s>" + (pcred[i + 1] || "") + "\n"
i += 2
end
else
pcred.each { |name| plugin_credits << name + "\n" }
end
plugin_credits << "\n"
end


#-------------------------------
# Make background and text sprites
#-------------------------------
@text_viewport = Viewport.new(0, @trim, Graphics.width, Graphics.height - (@trim * 2))
@text_viewport.z = 99999

@background_sprite = IconSprite.new(0, 0)
@background_sprite.setBitmap("Graphics/Titles/" + BACKGROUNDS_LIST[0])
@background_sprite.opacity = 0
@credit_sprites = []
@contributor_sprites = {}
@total_height = @credit_lines.size * 32
lines_per_bitmap = @bitmap_height / 32
num_bitmaps = (@credit_lines.size.to_f / lines_per_bitmap).ceil

#there are 42 bitmaps right now, so for i in 0...42 (iterate 42 times)
for i in 0...num_bitmaps
#the width and height match the size of the screen
credit_bitmap = Bitmap.new(Graphics.width, @bitmap_height)
#Sets a bitmap's font to the system font.
pbSetSystemFont(credit_bitmap)
#j is the iteration letter
#lines_per_bitmap is 12
#so for j in 0...12 (12 times), but it goes more than 12 times
for j in 0...lines_per_bitmap
#line = blank. The first line in the credits
#@credit_lines = the entire credits all in one array
#i = 0, since this is the first iteration
#lines_per_bitmap = 12
#j = 0, the first iteration, then 1, 2, all the way to 11
#(12 iterations)
#so it's
#line = @credit_lines array, position [0 * 12 + 0] = @credit_lines[0]
line = @credit_lines[i * lines_per_bitmap + j]
next if !line
#if the line is not empty as in has no value and we've reached the end?
#split the line when you find a <s>
line = line.split("<s>")
xpos = 0
align = 1 # Centre align
linewidth = Graphics.width
#k is the iteration letter
#line.length is 0 if the line is empty and 1 if there is anything on the
#line
for k in 0...line.length
#so for k in 0...line.length (2 times?)
#k is just 0 over and over
if line.length > 1
#I have no idea what's going on here. Something about alignment
xpos = (k == 0) ? 0 : 20 + Graphics.width / 2
align = (k == 0) ? 2 : 0 # Right align : left align
linewidth = Graphics.width / 2 - 20
end
#change the font color of text put on the bitmap
credit_bitmap.font.color = TEXT_SHADOW_COLOR
#draw the shadow of the text on the bitmap
#xpos = 0 over and over
#y is j*32+8, which comes out to 40, 72, 104, 136, etc and eventually
#loops back to 0 if it passes the screen height. The +8 is just for
#the shadow.
#so draw_text(x = 0, y = 0, width = linewidth, height = 32, what to
#draw is the contents of line[k] so "Scripts & Coding" which is the
#first line in the credits, alignment)
credit_bitmap.draw_text(xpos, j * 32 + 8, linewidth, 32, line[k], align)
credit_bitmap.font.color = TEXT_OUTLINE_COLOR
credit_bitmap.draw_text(xpos + 2, j * 32 - 2, linewidth, 32, line[k], align)
credit_bitmap.draw_text(xpos, j * 32 - 2, linewidth, 32, line[k], align)
credit_bitmap.draw_text(xpos - 2, j * 32 - 2, linewidth, 32, line[k], align)
credit_bitmap.draw_text(xpos + 2, j * 32, linewidth, 32, line[k], align)
credit_bitmap.draw_text(xpos - 2, j * 32, linewidth, 32, line[k], align)
credit_bitmap.draw_text(xpos + 2, j * 32 + 2, linewidth, 32, line[k], align)
credit_bitmap.draw_text(xpos, j * 32 + 2, linewidth, 32, line[k], align)
credit_bitmap.draw_text(xpos - 2, j * 32 + 2, linewidth, 32, line[k], align)
credit_bitmap.font.color = TEXT_BASE_COLOR
#draw the contents of line[k] to the bitmap
#j is 0...12 and goes (12 times). It's the number of lines per the
#bitmap
#j*32 is 32,64,96,128,192,224,256,320,0,64,96,160,192,224,256,320,352,
#0,etc.
#it seems the bitmap's height is 352. Once the y reaches 352, the next
#bit of text's y starts at 0 or whatever is leftover when going over
#352
credit_bitmap.draw_text(xpos, j * 32, linewidth, 32, line[k], align)
#I need to check if the contents of line[k] exist as a file in
#pictures/credits, and it if does, put it at height j*32 in this loop
#that should put the graphic in the correct spot next to the name
#but for now I will check if line[k] equals a specific string and if
#it does, I will place a sprite at j*32 on this bitmap



name = line[k].to_s
if FileTest.image_exist?("Graphics/Pictures/Credits/" + name)
#create a new sprite for line[k]
@contributor_sprites[name+"-#{i}-#{j}"] = Sprite.new(@text_viewport)
#make the sprite a bitmap
@contributor_sprites[name+"-#{i}-#{j}"].bitmap = Bitmap.new("Graphics/Pictures/Credits/" + name)
#set the x of that bitmap sprite (the person's graphic)
@contributor_sprites[name+"-#{i}-#{j}"].x = 0
#set the y of that bitmap sprite (the person's graphic)
#j * 32 is the height the name appears at on this bitmap, whether it's
#0,32,64, etc.
name_height = j * 32
@contributor_sprites[name+"-#{i}-#{j}"].y = name_height + @bitmap_height * i
#print name+"-#{i}-#{j}"
#print name + ".y is " + @contributor_sprites[name].y.to_s
end

end
end
#all this below is in the for i loop
#put all the bitmaps together
credit_sprite = Sprite.new(@text_viewport)
credit_sprite.bitmap = credit_bitmap
credit_sprite.z = 9998

#create the long bitmap for the contributor sprites
=begin
contributor_sprite = Sprite.new(@cont_viewport)
contributor_sprite.bitmap = credit_bitmap
contributor_sprite.z = 9997
=end

#@realOY = -(Graphics.height - @trim), which I don't understand
#@bitmap_height = 384, -346, 384, -730, 384, -1114, 384, -1498, 384, -1882
#which I don't understand
#i = 0, then 1, 2, etc. up to 42 (iterates 42 times
#credit_sprite.oy = -346, -730, -1114, etc., and this happens 42 times,
#once per bitmap created
credit_sprite.oy = @realOY - @bitmap_height * i
#print "Credit sprite oy is " + credit_sprite.oy.to_s
#contributor_sprite.oy = @realOY - @bitmap_height * i
#@credit_sprites is blank. Is this an image?
#i is the bitmap, the block of text
#@credit_sprites bitmap 0 (first bitmap) is credit_sprite, which is put on
#the @text_viewport
@credit_sprites = credit_sprite
#@contributor_sprites = contributor_sprite
#credit_sprite is an image, a sprite
end






#-------------------------------
# Setup
#-------------------------------
# Stops all audio but background music
previousBGM = $game_system.getPlayingBGM
pbMEStop
pbBGSStop
pbSEStop
pbBGMFade(2.0)
pbBGMPlay(BGM)
Graphics.transition(20)
while @creditsEnd != 1
Graphics.update
Input.update
update
pbUpdateSceneMap
break if $scene != self
end
pbBGMFade(2.0)
Graphics.freeze
Graphics.transition(20, "fadetoblack")
@background_sprite.dispose
@credit_sprites.each { |s| s.dispose if s }
@contributor_sprites.each { |s| s[1].dispose if s[1] }
@text_viewport.dispose
$PokemonGlobal.creditsPlayed = true
pbBGMPlay(previousBGM)
end




# Check if the credits should be cancelled
def cancel?
if Input.trigger?(Input::USE) && $PokemonGlobal.creditsPlayed
$scene = Scene_Map.new
pbBGMFade(1.0)
return true
end
return false
end

# Checks if credits bitmap has reached its ending point
def last?
if @realOY > @total_height + @trim
$scene = ($game_map) ? Scene_Map.new : nil
@creditsEnd = 1
pbBGMFade(2.0)
return true
end
return false
end

def update
delta = Graphics.delta_s
@counter += delta
# Go to next slide
if @counter >= SECONDS_PER_BACKGROUND
@counter -= SECONDS_PER_BACKGROUND
@bg_index += 1
@bg_index = 0 if @bg_index >= BACKGROUNDS_LIST.length
@background_sprite.setBitmap("Graphics/Titles/" + BACKGROUNDS_LIST[@bg_index])
end
return if cancel?
return if last?
@realOY += SCROLL_SPEED * delta
# s is the sprite, i is the index
@credit_sprites.each_with_index { |s, i| s.oy = @realOY - @bitmap_height * i }

# a is an array with the name of the contributor and the sprite
# a[1] is the first sprite, then it's the second sprite, and so on in a loop
#until the credits end
#realOY starts just off-screen, so it starts around -300 something
#as graphics update, the realOY becomes more positive, so the sprites scroll
#upwards
@contributor_sprites.each_with_index { |a, i|
a[1].oy = @realOY - a[1].y
#print a[1].oy.to_s
}
end


#end of class
end

=====================================================================================================
I tried printing the .oy of each picture, and the first picture's .oy is at @realOY minus 0, which is correct. The second picture's .oy is at @realOY minus 32, which is also correct! So why is there a 32 pixel gap between the icons?

Can anybody assist?
 
Solution
I figured this out. Rather than me pasting the entirety of the code here and explaining the many hoops I had to jump through to get this to work, I'm actually gonna release this as a resource in case anybody wants to use it.

This one is solved.

Gardenette

Trainer
Member
Joined
May 30, 2022
Posts
50
Age
27
I figured this out. Rather than me pasting the entirety of the code here and explaining the many hoops I had to jump through to get this to work, I'm actually gonna release this as a resource in case anybody wants to use it.

This one is solved.
 
Solution
Top