PC Pokegear app

Kioshi Hoshitsuya

Trainer
Member
Joined
Mar 4, 2018
Posts
52
I've recently been working on a feature that let's you access the PC via the menu. A user (credit to MGriffin) and I also have made it so that this feature doesn't let you heal your Pokemon when storing them in the PC so that players can't exploit the feature to heal the team without using Potions. But, instead of making it a menu feature, I want it to be a Pokegear App. I'm a noob at scripting so if someone could explain step by step how to do it I'd really appreciate it. Thanks in advance!
I'll leave you the Scripts.rxdata so that you can check out the modified PC script (make sure to look in PScreen_PauseMenu, PScreen_PC and Follow Pokemon):
https://www.dropbox.com/s/brgg0ejh08syidl/1523433213520_Scripts.rxdata?dl=0
 

olihewi

British "Person"
Member
Joined
Apr 1, 2018
Posts
1
Age
19
So first error message that I got when I ran the script was:
"Undefined local variable or method 'pbPlayDEcisionSE".

This shows that there was an error in the typing of pbPlayDecisionSE where you mucked up the capitalisation (line 162), so the first step is to sort that out.

Once that's sorted, the next error message you get when attempting to open the PC is:
"undefined local variable or method 'is_pc'". (line 165)

All of this is mostly unnecessary and just makes it more complicated if you wanted it to work this way:
Code:
pbFadeOutIn(99999) {
	scene = PokemonStorageScene.new
	screen =PokemonStorageScreen.new(scene,$PokemonStorage,is_pc)
	screen.pbStartScreen()
}
The reason why is that you can just run the pbPokeCenterPC method immediately after selecting the command, so you can replace all of that with:
Code:
pbPokeCenterPC(false)
because you just want to run the script immediately.
However, this will just show the text over the Pokégear menu, so if you wanted to show something else, probably use the FadeOutIn bit, in which case I'll let you work out how to do it.

So in summary, fix the capitalisation on line 162 and either comment out or delete lines 163-167 and put in pbPokeCenterPC(false) instead.

Code:
class PokegearButton < SpriteWrapper
attr_reader :index
attr_reader :name
attr_reader :selected
def initialize(command,x,y,viewport=nil)
super(viewport)
@image = command[0]
@name = command[1]
@selected = false
if $Trainer.isFemale? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/icon_button_f"))
@button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button_f")
else
@button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button")
end
@contents = BitmapWrapper.new(@button.width,@button.height)
self.bitmap = @contents
self.x = x
self.y = y
pbSetSystemFont(self.bitmap)
refresh
end
def dispose
@button.dispose
@contents.dispose
super
end
def selected=(val)
oldsel = @selected
@selected = val
refresh if oldsel!=val
end
def refresh
self.bitmap.clear
rect = Rect.new(0,0,@button.width,@button.height/2)
rect.y = @button.height/2 if @selected
self.bitmap.blt(0,0,@button.bitmap,rect)
textpos = [
[@name,self.bitmap.width/2,10,2,Color.new(248,248,248),Color.new(40,40,40)],
]
pbDrawTextPositions(self.bitmap,textpos)
imagepos = [
[sprintf("Graphics/Pictures/Pokegear/icon_"+@image),18,10,0,0,-1,-1],
]
pbDrawImagePositions(self.bitmap,imagepos)
end
end
 
class PokemonPokegear_Scene
def pbUpdate
for i in 0...@commands.length
@sprites["button#{i}"].selected = (i==@index)
end
pbUpdateSpriteHash(@sprites)
end
def pbStartScene(commands)
@commands = commands
@index = 0
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z = 99999
@sprites = {}
@sprites["background"] = IconSprite.new(0,0,@viewport)
if $Trainer.isFemale? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/bg_f"))
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg_f")
else
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg")
end
for i in 0...@commands.length
y = 196 - (@commands.length*24) + (i*48)
@sprites["button#{i}"] = PokegearButton.new(@commands[i],118,y,@viewport)
end
pbFadeInAndShow(@sprites) { pbUpdate }
end
def pbScene
ret = -1
loop do
Graphics.update
Input.update
pbUpdate
if Input.trigger?(Input::B)
break
elsif Input.trigger?(Input::C)
ret = @index
break
elsif Input.trigger?(Input::UP)
@index -= 1
@index = @commands.length-1 if @index<0
pbPlayCursorSE if @commands.length>1
elsif Input.trigger?(Input::DOWN)
@index += 1
@index = 0 if @index>=@commands.length
pbPlayCursorSE if @commands.length>1
end
end
return ret
end
def pbEndScene
pbFadeOutAndHide(@sprites) { pbUpdate }
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
end
 
class PokemonPokegearScreen
def initialize(scene)
@scene = scene
end
def pbStartScreen
commands = []
cmdMap = -1
cmdPhone = -1
cmdJukebox = -1
cmdPC = -1
commands[cmdMap = commands.length] = ["map",_INTL("Map")]
if $PokemonGlobal.phoneNumbers && $PokemonGlobal.phoneNumbers.length>0
commands[cmdPhone = commands.length] = ["phone",_INTL("Phone")]
end
commands[cmdPC = commands.length] = ["pc",_INTL("PC")]
def pbPokeCenterPC(is_pc=true)
Kernel.pbMessage(_INTL("\\se[PC open]{1} booted up the PC.",$Trainer.name))
loop do
commands=PokemonPCList.getCommandList
command=Kernel.pbMessage(_INTL("Which PC should be accessed?"),commands,commands.length)
break if !PokemonPCList.callCommand(command, is_pc)
end
pbSEPlay("PC close")
end
commands[cmdJukebox = commands.length] = ["jukebox",_INTL("Jukebox")]
@scene.pbStartScene(commands)
loop do
cmd = @scene.pbScene
if cmd<0
pbPlayCancelSE
break
elsif cmdMap>=0 && cmd==cmdMap
pbPlayDecisionSE
pbShowMap(-1,false)
elsif cmdPhone>=0 && cmd==cmdPhone
pbPlayDecisionSE
pbFadeOutIn(99999){
PokemonPhoneScene.new.start
}
elsif cmdJukebox>=0 && cmd==cmdJukebox
pbPlayDecisionSE
pbFadeOutIn(99999){
scene = PokemonJukebox_Scene.new
screen = PokemonJukeboxScreen.new(scene)
screen.pbStartScreen
}
elsif cmdPC>=0 && cmd==cmdPC
pbPlayDecisionSE
#pbFadeOutIn(99999){
#scene = PokemonStorageScene.new
#screen = PokemonStorageScreen.new(scene,$PokemonStorage,false)
#screen.pbStartScreen()
#}
pbPokeCenterPC(false)
end
end
@scene.pbEndScene
end
end
 

Kioshi Hoshitsuya

Trainer
Member
Joined
Mar 4, 2018
Posts
52
T
So first error message that I got when I ran the script was:
"Undefined local variable or method 'pbPlayDEcisionSE".

This shows that there was an error in the typing of pbPlayDecisionSE where you mucked up the capitalisation (line 162), so the first step is to sort that out.

Once that's sorted, the next error message you get when attempting to open the PC is:
"undefined local variable or method 'is_pc'". (line 165)

All of this is mostly unnecessary and just makes it more complicated if you wanted it to work this way:
Code:
pbFadeOutIn(99999) {
	scene = PokemonStorageScene.new
	screen =PokemonStorageScreen.new(scene,$PokemonStorage,is_pc)
	screen.pbStartScreen()
}
The reason why is that you can just run the pbPokeCenterPC method immediately after selecting the command, so you can replace all of that with:
Code:
pbPokeCenterPC(false)
because you just want to run the script immediately.
However, this will just show the text over the Pokégear menu, so if you wanted to show something else, probably use the FadeOutIn bit, in which case I'll let you work out how to do it.

So in summary, fix the capitalisation on line 162 and either comment out or delete lines 163-167 and put in pbPokeCenterPC(false) instead.

Code:
class PokegearButton < SpriteWrapper
attr_reader :index
attr_reader :name
attr_reader :selected
def initialize(command,x,y,viewport=nil)
super(viewport)
@image = command[0]
@name = command[1]
@selected = false
if $Trainer.isFemale? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/icon_button_f"))
@button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button_f")
else
@button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button")
end
@contents = BitmapWrapper.new(@button.width,@button.height)
self.bitmap = @contents
self.x = x
self.y = y
pbSetSystemFont(self.bitmap)
refresh
end
def dispose
@button.dispose
@contents.dispose
super
end
def selected=(val)
oldsel = @selected
@selected = val
refresh if oldsel!=val
end
def refresh
self.bitmap.clear
rect = Rect.new(0,0,@button.width,@button.height/2)
rect.y = @button.height/2 if @selected
self.bitmap.blt(0,0,@button.bitmap,rect)
textpos = [
[@name,self.bitmap.width/2,10,2,Color.new(248,248,248),Color.new(40,40,40)],
]
pbDrawTextPositions(self.bitmap,textpos)
imagepos = [
[sprintf("Graphics/Pictures/Pokegear/icon_"+@image),18,10,0,0,-1,-1],
]
pbDrawImagePositions(self.bitmap,imagepos)
end
end
 
class PokemonPokegear_Scene
def pbUpdate
for i in 0...@commands.length
@sprites["button#{i}"].selected = (i==@index)
end
pbUpdateSpriteHash(@sprites)
end
def pbStartScene(commands)
@commands = commands
@index = 0
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z = 99999
@sprites = {}
@sprites["background"] = IconSprite.new(0,0,@viewport)
if $Trainer.isFemale? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/bg_f"))
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg_f")
else
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg")
end
for i in 0...@commands.length
y = 196 - (@commands.length*24) + (i*48)
@sprites["button#{i}"] = PokegearButton.new(@commands[i],118,y,@viewport)
end
pbFadeInAndShow(@sprites) { pbUpdate }
end
def pbScene
ret = -1
loop do
Graphics.update
Input.update
pbUpdate
if Input.trigger?(Input::B)
break
elsif Input.trigger?(Input::C)
ret = @index
break
elsif Input.trigger?(Input::UP)
@index -= 1
@index = @commands.length-1 if @index<0
pbPlayCursorSE if @commands.length>1
elsif Input.trigger?(Input::DOWN)
@index += 1
@index = 0 if @index>=@commands.length
pbPlayCursorSE if @commands.length>1
end
end
return ret
end
def pbEndScene
pbFadeOutAndHide(@sprites) { pbUpdate }
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
end
 
class PokemonPokegearScreen
def initialize(scene)
@scene = scene
end
def pbStartScreen
commands = []
cmdMap = -1
cmdPhone = -1
cmdJukebox = -1
cmdPC = -1
commands[cmdMap = commands.length] = ["map",_INTL("Map")]
if $PokemonGlobal.phoneNumbers && $PokemonGlobal.phoneNumbers.length>0
commands[cmdPhone = commands.length] = ["phone",_INTL("Phone")]
end
commands[cmdPC = commands.length] = ["pc",_INTL("PC")]
def pbPokeCenterPC(is_pc=true)
Kernel.pbMessage(_INTL("\\se[PC open]{1} booted up the PC.",$Trainer.name))
loop do
commands=PokemonPCList.getCommandList
command=Kernel.pbMessage(_INTL("Which PC should be accessed?"),commands,commands.length)
break if !PokemonPCList.callCommand(command, is_pc)
end
pbSEPlay("PC close")
end
commands[cmdJukebox = commands.length] = ["jukebox",_INTL("Jukebox")]
@scene.pbStartScene(commands)
loop do
cmd = @scene.pbScene
if cmd<0
pbPlayCancelSE
break
elsif cmdMap>=0 && cmd==cmdMap
pbPlayDecisionSE
pbShowMap(-1,false)
elsif cmdPhone>=0 && cmd==cmdPhone
pbPlayDecisionSE
pbFadeOutIn(99999){
PokemonPhoneScene.new.start
}
elsif cmdJukebox>=0 && cmd==cmdJukebox
pbPlayDecisionSE
pbFadeOutIn(99999){
scene = PokemonJukebox_Scene.new
screen = PokemonJukeboxScreen.new(scene)
screen.pbStartScreen
}
elsif cmdPC>=0 && cmd==cmdPC
pbPlayDecisionSE
#pbFadeOutIn(99999){
#scene = PokemonStorageScene.new
#screen = PokemonStorageScreen.new(scene,$PokemonStorage,false)
#screen.pbStartScreen()
#}
pbPokeCenterPC(false)
end
end
@scene.pbEndScene
end
end
Thanks! I'll surely credit you for your help!
 
Top