- Pokémon Essentials Version
- v19.1 ➖
Love lore dumps but hate scrolling through little textboxes? Boy do I have a script for you!
Code
Paste in a new script section above Main!
Ruby:
#books
BookZero = [
"TITLE","This is the text of your book.\nThis is on a new line.<i>This text is italicized</i>, but this is not.",
"PAGE 1","<fs=28>This is the next page. See how the left arrow appears now?\nThe text is also bigger!</fs>",
"PAGE 2","<fs=22>Here's the last page! The right arrow has disappeared. The text is smaller, so I could write a lot more! But I won't.</fs>"
]
BookOne = [
"TITLE","Here's another book! This one only has one page!"
]
Books = [
BookZero,
BookOne
]
def textbook(book)
scene = Textbook_Scene.new
screen = TextbookScreen.new(scene)
screen.pbStartTextbookScreen(book)
yield if block_given?
pbFadeInAndShow(@sprites)
end
class TextbookScreen
def initialize(scene)
@scene = scene
end
def pbStartTextbookScreen(book)
@scene.pbStartTextbookScene(book)
ret = @scene.pbTextbookScene
@scene.pbEndScene
return ret
end
end
class Textbook_Scene
def pbUpdate
pbUpdateSpriteHash(@sprites)
end
def pbStartTextbookScene(book)
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z = 99999
@page = 0
@book = book
@bookarray= Books[book]
@max=Books[book].length#)+4)/2
#@max+=4
#@max/=2
@sprites = {}
@sprites["background"] = IconSprite.new(0,0,@viewport)
@sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
pbSetSystemFont(@sprites["overlay"].bitmap)
@sprites["leftarrow"] = AnimatedSprite.new("Graphics/Pictures/leftarrow",8,40,28,2,@viewport)
@sprites["leftarrow"].x = -4
@sprites["leftarrow"].y = 10
@sprites["leftarrow"].play
@sprites["rightarrow"] = AnimatedSprite.new("Graphics/Pictures/rightarrow",8,40,28,2,@viewport)
@sprites["rightarrow"].x = (Graphics.width)-36
@sprites["rightarrow"].y = 10
@sprites["rightarrow"].visible = (!@choosing || numfilledpockets>1)
@sprites["rightarrow"].play
drawTextbookPage(@page)
pbFadeInAndShow(@sprites) { pbUpdate }
end
def pbEndScene
pbFadeOutAndHide(@sprites) { pbUpdate }
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
def drawTextbookPage(page)
book = @book
@sprites["leftarrow"].visible = (@page>0)
@sprites["rightarrow"].visible = (@page+3<@max)
overlay = @sprites["overlay"].bitmap
overlay.clear
base = Color.new(0,0,0)
# Set background image
@sprites["background"].setBitmap("Graphics/Pictures/textbookbg")
imagepos=[]
# Write various bits of text
pagename = @bookarray[page]
textpos = [
[pagename,Graphics.width/2,10,2,base]
]
#For title size
@sprites["overlay"].bitmap.font.size=32
pbDrawTextPositions(overlay,textpos)
@sprites["overlay"].bitmap.font.size=26
text=@bookarray[page+1]
drawFormattedTextEx(overlay,25,35,Graphics.width-40,text,base)
end
def pbTextbookScene
loop do
Graphics.update
Input.update
pbUpdate
dorefresh = false
if Input.trigger?(Input::BACK)
pbPlayCloseMenuSE
break
elsif Input.trigger?(Input::LEFT)
oldpage = @page
@page -= 2
@page = 0 if @page<0
if @page!=oldpage # Move to next page
pbSEPlay("GUI summary change page")
dorefresh = true
end
elsif Input.trigger?(Input::RIGHT)
oldpage = @page
@page += 2
@page = @max-2 if @page+3>@max
if @page!=oldpage # Move to next page
pbSEPlay("GUI summary change page")
dorefresh = true
end
end
if dorefresh
drawTextbookPage(@page)
end
end
end
end
If you're using a version prior to v19, change
(Input::BACK)
to (Input::B)
If you're using a version prior to v18, change
pbPlayCloseMenuSE
to pbSEPlay("GUI menu close")
Using the script
Most of what we need to do is at the top of this script! I've included some example books to give a feel for how this works!
Ruby:
BookZero = [
"TITLE","This is the text of your book.\nThis is on a new line.<i>This text is italicized</i>, but this is not.",
"PAGE 1","This is the next page. See how the left arrow appears now?\nThe text is also bigger!",
"PAGE 2","Here's the last page! The right arrow has disappeared. The text is smaller, so I could write a lot more! But I won't."
]
- Things that affect stuff like the speed of text or the positioning of the menu box, since neither exist here.
- Things that require another menu box to be displayed- showing money/coins, \f to display a picture, choices, etc.
Remember that the array name has to be capitalized!
After that, just put your array's name in the array Books!
Ruby:
Books = [
BookZero,
BookOne
]
And to call it, just use textbook(book), with book being the number in the Books array! (Remember that it starts at 0!)
You'll need a file titled textbookbg in Graphics/Pictures! If you want to create your own, I do recommend downloading the one linked here all the same, so you can be sure your text will align!
Future Goals
- Get a page turn sound effect, get a way to easily set custom sound effects
- Make a way to set custom backgrounds but still be able to default to one
- Implement a table of contents feature, to jump to pages
- Credits
- TechSkylander1518 for the code
AnonAlpaca for the graphic, if used