PDA

View Full Version : [Essentials tutorial] How to add more features to the PokeGear


FL
May 8th, 2013, 04:06 PM
Map, Phone and Jukebox aren't enough features for you? Let's add more!

In Pokégear script section, after line '@cmdJukebox=-1' add '@cmdSomething=-1', after line 'commands[@cmdJukebox=commands.length]=_INTL("Jukebox")' add 'commands[@cmdSomething=commands.length]=_INTL("Something")'. Before the last line 'return', add the scene call in a 'if' statement with the command index, something like:

if @cmdSomething>=0 && @sprites["command_window"].index==@cmdSomething
pbPlayDecisionSE()
pbFadeOutIn(99999) {
scene=SomethingScene.new
screen=Something.new(scene)
screen.pbStartScreen
}
end

Change all the "Something" for something (lol) like DayCareChecker (works with this script (http://www.pokecommunity.com/showthread.php?t=278209) if you use 'screen.startScreen' instead of 'screen.pbStartScreen' in the scene call). You can put a icon if you match the name, like the pokégear icons in Graphics/Pictures folder.

Tayuya of the Sound Four
May 8th, 2013, 06:41 PM
Thanks n_n Say if I wanted to make a sort of, mail/email system, how would that work? I know how to make scenes, just not how to populate them

FL
May 11th, 2013, 02:54 PM
Thanks n_n Say if I wanted to make a sort of, mail/email system, how would that work? I know how to make scenes, just not how to populate themUse a selection for choosing the values in a list, I suggest something like Kernel.pbMessage("Choose something",["choice 1","choice 2","choice 3","Cancel",3)

For showing a text (you need to define the background IMAGEPATH):

def pbStartScene
@sprites={}
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@sprites["background"]=IconSprite.new(0,0,@viewport)
@sprites["background"].setBitmap(IMAGEPATH)
@sprites["background"].x=(Graphics.width-@sprites["background"].bitmap.width)/2
@sprites["background"].y=(Graphics.height-@sprites["background"].bitmap.height)/2
@sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
pbSetSystemFont(@sprites["overlay"].bitmap)
overlay=@sprites["overlay"].bitmap
overlay.clear
marginLeft=32
marginRight=32
baseColor=Color.new(72,72,72)
shadowColor=Color.new(160,160,160)
textPositions=["Title goes here",Graphics.width/2,0,2,baseColor,shadowColor]]
pbDrawTextPositions(overlay,textPositions)
text = "text text text text text text text text text text text text text text text"
drawTextEx(overlay,marginLeft,64,Graphics.width-marginLeft-marginRight,8,
text,baseColor,shadowColor)
pbFadeInAndShow(@sprites) { update }
end

Look at my diploma tutorial (http://www.pokecommunity.com/showthread.php?t=286554) for a better example.

bartyboy6
August 16th, 2013, 02:42 AM
small question: I want the pokedex to be on the pokegear instead of in the menu screen along with a pokemon storage check (you can't move your pokemon from there but merely check their summary)

FL
August 18th, 2013, 08:07 AM
small question: I want the pokedex to be on the pokegear instead of in the menu screen along with a pokemon storage check (you can't move your pokemon from there but merely check their summary)Simply do the tutorial and for the last part (of each one) do something like:

if @cmdPokedex>=0 && @sprites["command_window"].index==@cmdPokedex # I copied for menu script
pbPlayDecisionSE()
if DEXDEPENDSONLOCATION
pbFadeOutIn(99999) {
scene=PokemonPokedexScene.new
screen=PokemonPokedex.new(scene)
screen.pbStartScreen
@scene.pbRefresh
}
else
if $PokemonGlobal.pokedexViable.length==1
$PokemonGlobal.pokedexDex=$PokemonGlobal.pokedexViable[0]
$PokemonGlobal.pokedexDex=-1 if $PokemonGlobal.pokedexDex==$PokemonGlobal.pokedexUnlocked.length-1
pbFadeOutIn(99999) {
scene=PokemonPokedexScene.new
screen=PokemonPokedex.new(scene)
screen.pbStartScreen
@scene.pbRefresh
}
else
$scene = Scene_PokedexMenu.new # Changed
end
end
end
if @cmdStorage>=0 && @sprites["command_window"].index==@cmdStorage
pbFadeOutIn(99999){
scene=PokemonStorageScene.new
screen=PokemonStorageScreen.new(scene,$PokemonStorage,false) # 3 parameters
screen.pbStartScreen(2)
}
end

In PokemonStorage, change the line 'def initialize(scene,storage)' to:

def initialize(scene,storage,actionsEnabled=true)
@actionsEnabled = actionsEnabled


Change the second 'command=pbShowCommands(helptext,commands)' to:

actionsDisabled=[
_INTL("Move"),
_INTL("Store"),
_INTL("Withdraw"),
_INTL("Item"),
_INTL("Release")
]
actionsDisabledPositions=[]
if !@actionsEnabled
count = commands.size
while(count>0) # Goes backward to memorize the positions
count-=1
if actionsDisabled.include?(commands[count])
actionsDisabledPositions.push(count)
commands.delete_at(count)
end
end
actionsDisabledPositions.sort!
end
command=pbShowCommands(helptext,commands)
for position in actionsDisabledPositions
command+=1 if command>=position
end

To make the back button in pokédex returns to PokéGear: In PokemonPokedex change every 'Scene_Map.new' to 'Scene_Pokegear.new'

linkthehero
August 23rd, 2013, 06:42 AM
thank you very much =) the day cary stuff works fine , but ice tried toput the voltorb flip in this event ,but i got this error ,when i end the voltorb flip scene

---------------------------
Pokemon 1
---------------------------
Exception: NoMethodError

Message: undefined method `new' for nil:NilClass

PokemonPokegear:178:in `update_command'

PokemonPokegear:177:in `pbFadeOutIn'

PokemonPokegear:177:in `update_command'

PokemonPokegear:135:in `update'

PokemonPokegear:116:in `main'

PokemonPokegear:113:in `loop'

PokemonPokegear:120:in `main'

PokemonUtilities:991:in `pbLoadRpgxpScene'

PokemonPauseMenu:147:in `pbStartPokemonMenu'

PokemonPauseMenu:142:in `loop'



This exception was logged in

C:\Users\Salem\Saved Games/Pokemon 1/errorlog.txt.

Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK
---------------------------

FL
August 27th, 2013, 09:04 AM
thank you very much =) the day cary stuff works fine , but ice tried toput the voltorb flip in this event ,but i got this error ,when i end the voltorb flip sceneI followed the instructions and manage it (I only used 'pbVoltorbFlip' after 'pbPlayDecisionSE()' in the last part). You probably done something wrong, try again.

linkthehero
August 30th, 2013, 11:14 PM
sorry but i god some problems to fix it.please help me
class PokegearButton < SpriteWrapper
attr_reader :index
attr_reader :name
attr_accessor :selected

def initialize(x,y,name="",index=0,viewport=nil)
super(viewport)
@index=index
@name=name
@selected=false
fembutton=pbResolveBitmap(sprintf("Graphics/Pictures/pokegearButtonf"))
if $Trainer.gender==1 && fembutton
@button=AnimatedBitmap.new("Graphics/Pictures/pokegearButtonf")
else
@button=AnimatedBitmap.new("Graphics/Pictures/pokegearButton")
end
@contents=BitmapWrapper.new(@button.width,@button.height)
self.bitmap=@contents
self.x=x
self.y=y
update
end

def dispose
@button.dispose
@contents.dispose
super
end

def refresh
self.bitmap.clear
self.bitmap.blt(0,0,@button.bitmap,Rect.new(0,0,@button.width,@button.height))
pbSetSystemFont(self.bitmap)
textpos=[ # Name is written on both unselected and selected buttons
[@name,self.bitmap.width/2,10,2,Color.new(248,248,248),Color.new(40,40,40)],
[@name,self.bitmap.width/2,62,2,Color.new(248,248,248),Color.new(40,40,40)]
]
pbDrawTextPositions(self.bitmap,textpos)
icon=sprintf("Graphics/Pictures/pokegear"+@name)
imagepos=[ # Icon is put on both unselected and selected buttons
[icon,18,10,0,0,-1,-1],
[icon,18,62,0,0,-1,-1]
]
pbDrawImagePositions(self.bitmap,imagepos)
end

def update
if self.selected
self.src_rect.set(0,self.bitmap.height/2,self.bitmap.width,self.bitmap.height/2)
else
self.src_rect.set(0,0,self.bitmap.width,self.bitmap.height/2)
end
refresh
super
end
end



#===============================================================================
# - Scene_Pokegear
#-------------------------------------------------------------------------------
# Modified By Harshboy
# Modified by Peter O.
# Also Modified By OblivionMew
# Overhauled by Maruno
#===============================================================================
class Scene_Pokegear
#-----------------------------------------------------------------------------
# initialize
#-----------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#-----------------------------------------------------------------------------
# main
#-----------------------------------------------------------------------------
def main
commands=[]
# OPTIONS - If you change these, you should also change update_command below.
@cmdMap=-1
@cmdPhone=-1
@cmdJukebox=-1
@cmdVoltorbFlip=-1
commands[@cmdMap=commands.length]=_INTL("Map")
commands[@cmdPhone=commands.length]=_INTL("Phone") if $PokemonGlobal.phoneNumbers &&
$PokemonGlobal.phoneNumbers.length>0
commands[@cmdJukebox=commands.length]=_INTL("Jukebox")
commands[@cmdPension=commands.length]=_INTL("Pensionschecker") if pbGet(102)
commands[@cmdVoltorbFlip=commands.length]=_INTL("VoltorbFlip")
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@button=AnimatedBitmap.new("Graphics/Pictures/pokegearButton")
@sprites={}
@sprites["background"] = IconSprite.new(0,0)
femback=pbResolveBitmap(sprintf("Graphics/Pictures/pokegearbgf"))
if $Trainer.gender==1 && femback
@sprites["background"].setBitmap("Graphics/Pictures/pokegearbgf")
else
@sprites["background"].setBitmap("Graphics/Pictures/pokegearbg")
end
@sprites["command_window"] = Window_CommandPokemon.new(commands,160)
@sprites["command_window"].index = @menu_index
@sprites["command_window"].x = Graphics.width
@sprites["command_window"].y = 0
for i in 0...commands.length
x=118
y=196 - (commands.length*24) + (i*48)
@sprites["button#{i}"]=PokegearButton.new(x,y,commands[i],i,@viewport)
@sprites["button#{i}"].selected=(i==@sprites["command_window"].index)
@sprites["button#{i}"].update
end
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
pbDisposeSpriteHash(@sprites)
end
#-----------------------------------------------------------------------------
# update the scene
#-----------------------------------------------------------------------------
def update
pbUpdateSpriteHash(@sprites)
for i in 0...@sprites["command_window"].commands.length
sprite=@sprites["button#{i}"]
sprite.selected=(i==@sprites["command_window"].index) ? true : false
end
#update command window and the info if it's active
if @sprites["command_window"].active
update_command
return
end
end
#-----------------------------------------------------------------------------
# update the command window
#-----------------------------------------------------------------------------
def update_command
if Input.trigger?(Input::B)
pbPlayCancelSE()
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
if @cmdMap>=0 && @sprites["command_window"].index==@cmdMap
pbPlayDecisionSE()
pbFadeOutIn(99999) {
scene=PokemonRegionMapScene.new
screen=PokemonRegionMap.new(scene)
screen.pbStartScreen
}
end
if @cmdPhone>=0 && @sprites["command_window"].index==@cmdPhone
pbPlayDecisionSE()
pbFadeOutIn(99999) {
PokemonPhoneScene.new.start
}
end
if @cmdJukebox>=0 && @sprites["command_window"].index==@cmdJukebox
pbPlayDecisionSE()
$scene = Scene_Jukebox.new
end
if @cmdPension>=0 && @sprites["command_window"].index==@cmdPension
pbPlayDecisionSE()
pbFadeOutIn(99999) {
scene=DayCareCheckerScene.new
screen=DayCareChecker.new(scene)
screen.startScreen
}
end
if @cmdPension>=0 && @sprites["command_window"].index==@cmdVoltorbFlip
pbPlayDecisionSE()
pbFadeOutIn(99999) {
scene=pbVoltorbFlip.new
screen=pbVoltorbFlip.new(scene)
screen.pbStartScreen
}
end
return
end
end
end

FL
September 1st, 2013, 09:51 AM
sorry but i god some problems to fix it.please help meLike I said: You done something wrong. 'if @cmdPension>=0 && @sprites["command_window"].index==@cmdVoltorbFlip' line should be 'if @cmdVoltorbFlip>=0 && @sprites["command_window"].index==@cmdVoltorbFlip'. Change
pbFadeOutIn(99999) {
scene=pbVoltorbFlip.new
screen=pbVoltorbFlip.new(scene)
screen.pbStartScreen
}
to 'pbVoltorbFlip'

Maruno
September 1st, 2013, 11:37 AM
You'll also need the line @cmdPension=-1 in there somewhere. You could also try saying what your problems actually are.

linkthehero
September 2nd, 2013, 06:51 AM
thank you so much for the help
it works perfect =)

linkthehero
December 28th, 2013, 08:36 AM
how is it posibal to put the bike in
could someone help me please

FL
January 1st, 2014, 12:15 PM
how is it posibal to put the bike in
could someone help me pleaseThe last part is:

if @cmdBicycle>=0 && @sprites["command_window"].index==@cmdBicycle #gearmod
if pbBikeCheck
if $PokemonGlobal.bicycle
Kernel.pbDismountBike
else
Kernel.pbMountBike
end
$scene = Scene_Map.new
end
end

To close the menu, I suggest you to create a new flag at PokemonTemp. At pause menu script, when this variable is true, just closes the menu (break the loop). At this script, set this variable to true after line '$scene = Scene_Map.new'.

linkthehero
January 1st, 2014, 03:00 PM
ok thank you but the stuff with the pause menu is not needed i use another menu =)
thank you =)

TheMarkCrafter
January 27th, 2014, 06:50 AM
Drawing app?

How do I add a drawing app?

Maruno
January 27th, 2014, 08:44 AM
The first post explains how to call your drawing app scripts from the Pokégear.

Describing how to make a whole new screen is not a part of this tutorial.