The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Scripts & Tutorials
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.

Reply
 
Thread Tools
  #1    
Old April 8th, 2014 (08:46 AM).
FL's Avatar
FL
Pokémon Island Creator
 
Join Date: Sep 2010
Gender: Male
This script add a watch at Pokégear screen. I suggest you to change the pokégear pokegearbg.png and pokegearbgf.png (at Graphics\Pictures) to the ones that I edited for this purpose. At PokemonPokegear script section, before line 'Graphics.transition' add:

Code:
@sprites["overlay"]=BitmapSprite.new(
    Graphics.width,Graphics.height,@viewport)
pbSetSystemFont(@sprites["overlay"].bitmap)
@dateString=""
updateDateIfNecessary
Change

Code:
  #-----------------------------------------------------------------------------
  # update the scene
  #-----------------------------------------------------------------------------
  def update
to

Code:
  #-----------------------------------------------------------------------------
  # update the date display if necessary
  #-----------------------------------------------------------------------------
  def updateDateIfNecessary
    showSeconds = true # Make it false to won't show the seconds
    newDate = pbGetTimeNow.strftime(showSeconds ? "%I:%M:%S %p" : "%I:%M %p")
    return false if @dateString==newDate
    @dateString=newDate  
    overlay=@sprites["overlay"].bitmap
    overlay.clear 
    baseColor=Color.new(72,72,72)
    shadowColor=Color.new(160,160,160)
    textPositions=[
       [@dateString,Graphics.width/2,-2,2,baseColor,shadowColor]]
    pbDrawTextPositions(overlay,textPositions)
    return true
  end
  #-----------------------------------------------------------------------------
  # update the scene
  #-----------------------------------------------------------------------------
  def update
    updateDateIfNecessary
This script works well with Unreal time system
Attached Thumbnails
pokegearwatchscreen.png‎   pokegearbg.png‎   pokegearbgf.png‎  
__________________
Reply With Quote
  #2    
Old August 4th, 2014 (12:58 PM).
Lexxilion's Avatar
Lexxilion
 
Join Date: Jul 2014
Gender: Male
Nature: Careful
How easily could this be adapted for a wall clock? I can't seem to find any info on setting up a wall clock that upon interaction would show the time.
Reply With Quote
  #3    
Old August 4th, 2014 (05:45 PM).
Super Dedenne's Avatar
Super Dedenne
 
Join Date: Apr 2014
Gender:
Quote:
Originally Posted by Lexxilion View Post
How easily could this be adapted for a wall clock? I can't seem to find any info on setting up a wall clock that upon interaction would show the time.
Hello!

It can be done very easily actually. Say you just want a message to show up after interacting with the clock. Simply create an event and use this script call:

Code:
pbSet(112,pbGetTimeNow.strftime("%I:%M %p"))
This just stored the current time in Variable 112 (or which ever temporary variable you'd like). Now, let's display this in a text message. With the same event, use Show Text and allow it to say the following:

"The time is \v[112]."

And there you have it! It will display the time in HOUR:MIN AM/PM format. You could replace with pbGetTimeNow.strftime("%I:%M %p") with pbGetTimeNow.strftime("%A") to display the current day of the week instead. Or any combination of either, really.
__________________
Public Additions/Snippets:

Trainer Outfit Acro/MachBike Fix
Pokemon Summary Fix: Improved Ribbons + Scroll!
Reply With Quote
  #4    
Old August 4th, 2014 (11:19 PM).
Lexxilion's Avatar
Lexxilion
 
Join Date: Jul 2014
Gender: Male
Nature: Careful
Thanks very much! I love the clock bit from RSE and I'm not wanting to attempt clocksetting, but I'd like interactions with objects to be real and of value =]
Reply With Quote
  #5    
Old August 5th, 2014 (06:26 AM).
Richard PT's Avatar
Richard PT
 
Join Date: Aug 2014
Gender: Male
So we can have a clock in the wall with interation? Like in ruby, sapphire and emerald?
Reply With Quote
  #6    
Old August 9th, 2014 (03:53 PM).
FL's Avatar
FL
Pokémon Island Creator
 
Join Date: Sep 2010
Gender: Male
I made a Wall Clock script at http://www.pokecommunity.com/showthread.php?t=333511
__________________
Reply With Quote
  #7    
Old August 15th, 2014 (02:40 AM).
Richard PT's Avatar
Richard PT
 
Join Date: Aug 2014
Gender: Male
Thanks for your help FL, you deserve credits.
Reply With Quote
  #8    
Old October 18th, 2014 (02:01 AM). Edited October 18th, 2014 by Epic Flex.
Epic Flex's Avatar
Epic Flex
Game Dev
 
Join Date: Jun 2013
Location: Kalos Region
Gender: Male
While Testing I get This error message
Click image for larger version

Name:	error.PNG
Views:	7
Size:	5.4 KB
ID:	73650

Here My Code
Code:
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
    refresh
    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
    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
    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")

    @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
    @sprites["overlay"]=BitmapSprite.new(
    Graphics.width,Graphics.height,@viewport)
    pbSetSystemFont(@sprites["overlay"].bitmap)
    @dateString=""
    updateDateIfNecessary
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    pbDisposeSpriteHash(@sprites)
  end
  #-----------------------------------------------------------------------------
  # update the date display if necessary
  #-----------------------------------------------------------------------------
  def updateDateIfNecessary
    showSeconds = true # Make it false to won't show the seconds
    newDate = pbGetTimeNow.strftime(showSeconds ? "%I:%M:%S %p" : "%I:%M %p")
    return false if @dateString==newDate
    @dateString=newDate  
    overlay=@sprites["overlay"].bitmap
    overlay.clear 
    baseColor=Color.new(72,72,72)
    shadowColor=Color.new(160,160,160)
    textPositions=[
       [@dateString,Graphics.width/2,-2,2,baseColor,shadowColor]]
    pbDrawTextPositions(overlay,textPositions)
    return true
  end
  #-----------------------------------------------------------------------------
  # update the scene
  #-----------------------------------------------------------------------------
  def update
    updateDateIfNecessary
  def update
    for i in 0...@sprites["command_window"].commands.length
      sprite=@sprites["button#{i}"]
      sprite.selected=(i==@sprites["command_window"].index) ? true : false
    end
    pbUpdateSpriteHash(@sprites)
    #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()
        pbShowMap(-1,false)
      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
    return
    end
  end
end
Reply With Quote
  #9    
Old October 18th, 2014 (06:19 AM).
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
Quote:
Originally Posted by Epic Flex View Post
While Testing I get This error message
Attachment 73650

Here My Code
Spoiler:

Code:
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
    refresh
    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
    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
    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")

    @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
    @sprites["overlay"]=BitmapSprite.new(
    Graphics.width,Graphics.height,@viewport)
    pbSetSystemFont(@sprites["overlay"].bitmap)
    @dateString=""
    updateDateIfNecessary
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    pbDisposeSpriteHash(@sprites)
  end
  #-----------------------------------------------------------------------------
  # update the date display if necessary
  #-----------------------------------------------------------------------------
  def updateDateIfNecessary
    showSeconds = true # Make it false to won't show the seconds
    newDate = pbGetTimeNow.strftime(showSeconds ? "%I:%M:%S %p" : "%I:%M %p")
    return false if @dateString==newDate
    @dateString=newDate  
    overlay=@sprites["overlay"].bitmap
    overlay.clear 
    baseColor=Color.new(72,72,72)
    shadowColor=Color.new(160,160,160)
    textPositions=[
       [@dateString,Graphics.width/2,-2,2,baseColor,shadowColor]]
    pbDrawTextPositions(overlay,textPositions)
    return true
  end
  #-----------------------------------------------------------------------------
  # update the scene
  #-----------------------------------------------------------------------------
  def update
    updateDateIfNecessary
  def update
    for i in 0...@sprites["command_window"].commands.length
      sprite=@sprites["button#{i}"]
      sprite.selected=(i==@sprites["command_window"].index) ? true : false
    end
    pbUpdateSpriteHash(@sprites)
    #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()
        pbShowMap(-1,false)
      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
    return
    end
  end
end
That's not the right section... You have 186 lines in that code... Your error is looking at line 189... It's not possible!

Check your code again, but in the right section this time.
Reply With Quote
  #10    
Old October 18th, 2014 (09:31 AM).
Epic Flex's Avatar
Epic Flex
Game Dev
 
Join Date: Jun 2013
Location: Kalos Region
Gender: Male
Rechecked the whole code Works Fine now! Thx
The whole code was 188 lines.
Reply With Quote
  #11    
Old 1 Week Ago (03:25 PM). Edited 1 Week Ago by p.claydon.
p.claydon
 
Join Date: Jan 2011
Gender:
is there a way to get it to update while on the screen as it only seams to update when i open and close the pokégear

EDIT

ok ignore me i didnt read the instructions correctly
Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 09:41 PM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.