• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
SomerPoketch Script

SomerPoketch Script 4.1.1

Pokémon Essentials Version
v17.2 ➖
This new version of my own pokétch script for rpg maker XP is more user-friendly than ever!!! Once again, I have to give huge thanks to DarkBX, who did helped me with some of the apps. IMPORTANT: IT NEEDS SUSc v3.0 at least in order to work (download links in "installation"). This version includes the following features:

poketch.gif
NEW FEATURES!:
-Now you can set the scale of the poketch (reccomended for single screen mode)
-In a search for making the addition of new apps more and more easier, the whole script has been completely refactorized.

BUGFIX IN v4.1:
-Dot Artist App bugs solved!!!!

APPS:
-Clock app
-Pedometer app
-Marking map app
-Dot artist app
-Debug app
-KleinStudio 's Xtransceiver script compatibility!






USAGE:
-Giving the player the poketch: pbGetPoketch
-Removing the poketch (just because): pbRemovePoketch
-Adding a new app: pbAddApp(appNum)
-Deleting an app: pbDeleteApp(appNum)
-Changing automatically to a certain app (meant and reccomended for cutscenes): pbChangeToApp(appNum)

And that's it! We will include more apps in a future!
(Also, shout out to spriters-resource.com for the graphic resources)

  1. Download this pack and Uncompress the folder Poketch (I underline the word FOLDER) into the Pictures subdirectory.
  2. Install Marin's Better Bitmaps Script (the suitable version is included in the pack you have just downloaded)
  3. Install SUSc over Marin's Better Bitmaps script
  4. Copy and paste this in a new script section over main and over SUSc; call it SomerPoketch
    Ruby:
    Expand Collapse Copy
    #==============================================================================#
    #==============================================================================#
    #                        SOMERSAULT'S POKÉTCH SCRIPT v4.1.1                    #
    #==============================================================================#
    # CREDITS:                                                                     #
    # Somersault                                                                   #
    # DarkBX                                                                       #
    # Marin (for "Better Bitmaps" script)                                          #
    #==============================================================================#
    # INSTALLATION INSTRUCTIONS:                                                   #
    #==============================================================================#
    # 0. Uncompress the folder Poketch (I underline the word FOLDER) into the      #
    #    Pictures subdirectory.                                                    #
    # 1. Uncompress the audio files into respectively the SE and ME folders        #
    #    (in case you don't use your own ones)                                     #
    # 2. Install Marin's Better Bitmaps Script (AND GIVE CREDIT TO HIM!)           #
    # 3. Install SUSc (requires v3.0 at least) and place it over B.bitmaps script. #
    # 4. Create a new scrpit section over SUSc and paste in this script.           #
    # 5. Create a new script section over this script and paste in the contents of #
    #    SomerPoketch_Apps script.                                                 #
    # DONE!                                                                        #
    #==============================================================================#
    # USAGE INSTRUCTIONS:                                                          #
    #==============================================================================#
    # -Giving the player the poketch: pbGetPoketch(x,y,animatedBoolean)
    # -Removing the poketch:          pbRemovePoketch(x,y,animatedBoolean)
    # -Adding a new app:              pbAddApp(appNum,playMEBool,showTextBool)
    # -Deleting an app:               pbDeleteApp(appNum)
    # -Changing automatically to a certain app (meant and reccomended for cutscenes):
    #                                 pbChangeToApp(appNum)
    #==============================================================================#
    #==============================================================================#
    #                                   (STEP 0)                                   #
    #                     Array of all apps (activated or not)                     #
    #    NOTE: if you needed more apps, then just add it before DebugApp.new()     #
    #==============================================================================#
    $appArray = [
      ClockApp.new(0),
      XtransceiverApp.new(XTRANSAPPNUM),
      MarkingMapApp.new(2),
      PedometerApp.new(3),
      DotArtistApp.new(4),
      DebugApp.new(ACTAPPS_C.length)
    ]
    #==============================================================================#
    #                    PUBLIC FUNCTIONS FOR HANDLING THE POKETCH                 #
    #==============================================================================#
    #==============================================================================#
    #                   Functions to obtain and remove the poketch                 #
    #==============================================================================#
    def pbGetPoketch(xPos = POKETCHXPOS, yPos = POKETCHYPOS, animated = true)
      $poketch=Poketch.new(xPos,yPos,animated)
      $PokemonGlobal.poketch = true
    end
    #------------------------------------------------------------------------------#
    def pbRemovePoketch(animated = true)
      $poketch.dispose(animated) if $poketch != false
    end
    #==============================================================================#
    #                       Function to enable an App in-game                      #
    #==============================================================================#
    def pbAddApp(appnum, playFanfare=true, showMessage = true)
      pbMEPlay(ADD_APP_FANFARE,100,100) if playFanfare
      Kernel.pbMessageBlack(0,false,_INTL("{1} obtained <c3=52b5ff,29638c>{2} app\\c[0]!\1",$Trainer.name,APPS_INGAME_NAMES[appnum])) if showMessage
      $PokemonGlobal.actApps[appnum] = 1
    end
    #==============================================================================#
    #                       Function to disable an App in-game                     #
    #==============================================================================#
    def pbDeleteApp(appnum)
      $PokemonGlobal.actApps[appnum] = 0
    end
    #==============================================================================#
    #              Function for changing automatically an app in field             #
    #                          (designed for cutscenes)                            #
    #==============================================================================#
    def pbChangetoApp(appNum)
      if $PokemonGlobal.actApps[appNum]==1
        $PokemonGlobal.appVar = appNum
        $PokemonGlobal.appVar = $PokemonGlobal.appVar % ACTAPPS_C.size
        $poketch.changeToNewApp(true)
      end
    end
    #==============================================================================#
    #                      Function to update the poketch state                    #
    # Note: You don't need to use this one since the system automatically uses it. #
    #==============================================================================#
    def pbUpdatePoketch; $poketch.update if $poketch != false; end
    #==============================================================================#
    #                                DO-NOT-TOUCH STUFF                            #
    #                    (Unless you want the script to stop working)              #
    #==============================================================================#
    $poketch = false
    $poketchDisabled = true
    POKETCHINSTALLED = true
    #==============================================================================#
    #==============================================================================#
    class Poketch
      @PoketchViewport1 = Viewport.new(POKETCHXPOS,POKETCHYPOS,Graphics.width,Graphics.height)
      def initialize(xPos,yPos,animated)
        #hash and Class variables declaration
        $PokemonGlobal.appVar = 0 if $PokemonGlobal.appVar == nil
    
        #start poketch
        startScene(animated)
      end
    
      def changeToNewApp(chAppInEffect = false)
        changeAppInEffect if chAppInEffect
        $changingApp = true
        @currentApp.dispose if @currentApp
        executeApp(true)
        $changingApp = false
        changeAppOutEffect
      end
    
      def clickedOnMainUpBtn?
        clicked = clicked?(@poketch["btnUp"],true,MAIN_BUTTONS_SE)
        if clicked #&& !poketchDisabled?
    
          unless pbMapInterpreterRunning? or $game_system.menu_disabled or $game_player.moving?
            changeAppInEffect
            $PokemonGlobal.appVar += 1
            $PokemonGlobal.appVar = $PokemonGlobal.appVar % $PokemonGlobal.actApps.length
      
            until $PokemonGlobal.actApps[$PokemonGlobal.appVar]==1
              $PokemonGlobal.appVar +=1
              $PokemonGlobal.appVar += 1 if !XTRANSCEIVERADDED and $PokemonGlobal.appVar == XTRANSAPPNUM
              $PokemonGlobal.appVar = $PokemonGlobal.appVar % $PokemonGlobal.actApps.length
            end
            changeToNewApp
          end
        end
    
        return clicked
      end
    #------------------------------------------------------------------------------#
      def clickedOnMainDownBtn?
        clicked = clicked?(@poketch["btnDown"],true,MAIN_BUTTONS_SE)
        if clicked #&& !poketchDisabled?
          unless pbMapInterpreterRunning? or $game_system.menu_disabled or $game_player.moving?
            changeAppInEffect
            $PokemonGlobal.appVar -= 1
            $PokemonGlobal.appVar = $PokemonGlobal.actApps.length - 1 if $PokemonGlobal.appVar < 0
      
            until $PokemonGlobal.actApps[$PokemonGlobal.appVar]==1
              $PokemonGlobal.appVar -=1
              $PokemonGlobal.appVar -= 1 if !XTRANSCEIVERADDED and $PokemonGlobal.appVar == XTRANSAPPNUM
              $PokemonGlobal.appVar = $PokemonGlobal.actApps.length - 1 if $PokemonGlobal.appVar < 0
            end
            changeToNewApp
          end
        end
    
        return clicked
      end
    #==============================================================================#
    #==============================================================================#
    #                         GIVING THE PLAYER THE POKETCH                        #
    #==============================================================================#
      def startScene(animated = true)
        loadBaseGraphics
        curtainInEffect if animated
    
        for key in @poketch.keys
          @poketch[key].opacity = 255
          pbApplyRescaleRel(@poketch[key],POKETCHXPOS,POKETCHYPOS,POKETCH_SCALE)
        end
    
        # installing debug
        if $PokemonGlobal.actApps.length == ACTAPPS_C.length
          $PokemonGlobal.actApps[ACTAPPS_C.length] = 0
        end
    
        $changingApp = true
        executeApp
        $changingApp = false
    
        curtainOutEffect if animated
      end
    #==============================================================================#
    #                  UPDATING THE CURRENT STATE OF THE POKETCH                   #
    #==============================================================================#
      def executeApp(reset = false)
        if !@currentApp || reset
          @currentApp = AppExecutor.parse($PokemonGlobal.appVar)
          @currentApp.createGraphics if @currentApp
        end
    
        @currentApp.execute if @currentApp
      end
    #------------------------------------------------------------------------------#
      def update
        if !$game_system.map_interpreter.running? or !$game_temp.message_window_showing or $Poketch_On_Forced
          pbEnablePoketch
        else
          pbDisablePoketch
        end
    
        if $DEBUG && $PokemonGlobal.actApps[ACTAPPS_C.length] == 0
          pbAddApp(ACTAPPS_C.length,false,false)
        elsif !$DEBUG && $PokemonGlobal.actApps[ACTAPPS_C.length] == 1
          pbDeleteApp(ACTAPPS_C.length)
        end
    
        if XTRANSCEIVERADDED && $PokemonGlobal.actApps[XTRANSAPPNUM] == 0
          pbAddApp(XTRANSAPPNUM,false,false)
        elsif !XTRANSCEIVERADDED && $PokemonGlobal.actApps[XTRANSAPPNUM] == 1
          pbDeleteApp(XTRANSAPPNUM)
        end
    
        clickedOnMainDownBtn? if !clickedOnMainUpBtn?
        executeApp
      end
    #==============================================================================#
    #                            DISPOSING THE POKETCH                             #
    #==============================================================================#
      def dispose(animated = true)
        curtainInEffect if animated
        @currentApp.dispose if @currentApp
        pbDisposeGraphicsOf(@poketch,"bg","blScreen")
        curtainOutEffect if animated
        $poketch = false
        $PokemonGlobal.poketch = false
      end
    end
    #==============================================================================#
    #==============================================================================#
    #                             POKÉTCH BASE SCRIPT
    #==============================================================================#
    class PokemonGlobalMetadata
      attr_accessor :poketch
      attr_accessor :appVar
      attr_accessor :actApps
      attr_accessor :dotMatrix
    
      def poketch
        @poketch = nil if !@poketch
        return @poketch
      end
    
      def appVar
        @appVar = nil if !@appVar
        return @appVar
      end
    
      def actApps
        if !@actApps
          @actApps = []
          for i in 0...ACTAPPS_C.length
            @actApps[i] = ACTAPPS_C[i]
          end
        end
        return @actApps
      end
    
      def dotMatrix
        @dotMatrix = DOTMATRIX if !@dotMatrix
        return @dotMatrix
      end
    end
    
    class PokeBattle_Trainer
      attr_accessor :steps
    end
    
    Events.onStepTaken += proc do
      $Trainer.steps = 0 if !$Trainer.steps
      $Trainer.steps += 1
      Graphics.update if @appsHash == @pedometer
    end
    
    class Scene_Map
      alias _SomSceneMiniUpdate miniupdate
      def miniupdate
        _SomSceneMiniUpdate
        pbUpdatePoketch if $poketch != false
      end
    
      alias _SomCreateSpritesets createSpritesets
      def createSpritesets
        showPoketchBg if DOUBLESCREEN and $Trainer
        pbGetPoketch(POKETCHXPOS,POKETCHYPOS, false) if $PokemonGlobal.poketch #&& $poketch == false
        pbEnablePoketch #if !$poketchDisabled
        _SomCreateSpritesets
      end
    
      alias _SomDisposeSpritesets disposeSpritesets
      def disposeSpritesets
        return if !@spritesets
        #pbDisablePoketch if $poketch != false
        for i in @spritesets.keys
          if @spritesets[i]
            @spritesets[i].dispose
            @spritesets[i]=nil
          end
        end
        @spritesets.clear
        @spritesets={}
      end
    
      def main
        createSpritesets
        Graphics.transition
    
        while $scene == self
          #pbEnablePoketch #if !$poketchDisabled
          Graphics.update
          Input.update
          update
          pbUpdatePoketch if $poketch != false
        end
        Graphics.freeze
        disposeSpritesets
        if $game_temp.to_title
          Graphics.transition
          Graphics.freeze
        end
      end
    
      def showPoketchBg
        if DOUBLESCREEN
          @poketch = {}
    
          @poketch["bg"]=Sprite.new(@viewport)
          @poketch["bg"].bitmap=Bitmap.new(GRAPHICSPATH + "background.png")
          @poketch["bg"].x=POKETCHXPOS
          @poketch["bg"].y=POKETCHYPOS
          @poketch["bg"].z = 0
        end
      end
    end
    #===============================================================================
    #                               CURTAINS HANDLER                               #
    #==============================================================================#
    # Functions to handle poketch curtains
    #===============================================================================
    class Poketch
      def changeAppInEffect
        8.times do
          @poketch["bar1"].zoom_y += 24 * POKETCH_SCALE
          @poketch["bar2"].zoom_y += 24 * POKETCH_SCALE
          Graphics.update
        end
      end
    
      def changeAppOutEffect
        8.times do
          @poketch["bar1"].zoom_y -= 24 * POKETCH_SCALE
          @poketch["bar2"].zoom_y -= 24 * POKETCH_SCALE
          Graphics.update
        end
      end
    #===============================================================================
      #curtain effect
      def curtainInEffect
        @poketch["blScreen"]=Sprite.new(@viewport)
        @poketch["blScreen"].bitmap=Bitmap.new(GRAPHICSPATH + "blackScreen.png")
        @poketch["blScreen"].x = POKETCHXPOS
        @poketch["blScreen"].y = POKETCHYPOS
        @poketch["blScreen"].z = 99999
        @poketch["blScreen"].opacity = 255
        @poketch["blScreen"].zoom_y = 0
    
        8.times do
          @poketch["blScreen"].zoom_y += 0.125 * POKETCH_SCALE
          Graphics.update
        end
      end
    
      def curtainOutEffect
        #Retract the curtain
        8.times do
          @poketch["blScreen"].zoom_y -= 0.125 * POKETCH_SCALE
          Graphics.update
        end
    
    
        #dispose the curtain
        @poketch["blScreen"].dispose
        @poketch.delete("blScreen")
      end
    #==============================================================================#
    #                           LOADING THE BASE GRAPHICS                          #
    #==============================================================================#
    # Function to load the main Pokétch graphics
    #===============================================================================
      def loadBaseGraphics
        @poketch= {}
    
        if $Trainer.isMale?
          $person="Male"
        elsif $Trainer.isFemale?
          $person="Female"
        end
    
        $POKETCHBLACK = Sprite.new(@PoketchViewport1)
        $POKETCHBLACK.bitmap=Bitmap.new(GRAPHICSPATH + "blackScreen.png")
        $POKETCHBLACK.opacity = 0
        $POKETCHBLACK.x = POKETCHXPOS
        $POKETCHBLACK.y = POKETCHYPOS
        $POKETCHBLACK.z = 10000001
    
    
        @poketch["poketchBg"]=Sprite.new(@PoketchViewport1)
        @poketch["poketchBg"].bitmap=Bitmap.new(GRAPHICSPATH + "blank.png")
        @poketch["poketchBg"].x = APPX
        @poketch["poketchBg"].y = APPY
    
        @poketch["poketch"]=Sprite.new(@PoketchViewport1)
        @poketch["poketch"].bitmap=Bitmap.new(GRAPHICSPATH + "poketch" + $person + ".png")
        @poketch["poketch"].x = POKETCHXPOS
        @poketch["poketch"].y = POKETCHYPOS
    
        @poketch["btnUp"]=Sprite.new(@PoketchViewport1)
        @poketch["btnUp"].bitmap=Bitmap.new(GRAPHICSPATH + "btnUp.png")
        @poketch["btnUp"].x = POKETCHXPOS + 448
        @poketch["btnUp"].y = POKETCHYPOS + 60
        @poketch["btnUp"].src_rect.set(0,0,@poketch["btnUp"].bitmap.width / 2, @poketch["btnUp"].bitmap.height)
    
        @poketch["btnDown"]=Sprite.new(@PoketchViewport1)
        @poketch["btnDown"].bitmap=Bitmap.new(GRAPHICSPATH + "btnDown.png")
        @poketch["btnDown"].x = POKETCHXPOS + 448
        @poketch["btnDown"].y = POKETCHYPOS + 185
        @poketch["btnDown"].src_rect.set(0,0,@poketch["btnDown"].bitmap.width / 2, @poketch["btnDown"].bitmap.height)
    
        @poketch["bar1"]=Sprite.new(@PoketchViewport1)
        @poketch["bar1"].bitmap=Bitmap.new(GRAPHICSPATH + "transition.png")
        @poketch["bar1"].x = APPX
        @poketch["bar1"].y = APPY
        @poketch["bar1"].z = 2001
        @poketch["bar1"].zoom_y = 0
    
        @poketch["bar2"]=Sprite.new(@PoketchViewport1)
        @poketch["bar2"].bitmap=Bitmap.new(GRAPHICSPATH + "transition.png")
        @poketch["bar2"].x = APPX
        @poketch["bar2"].y = APPY + 318
        @poketch["bar2"].z = 2001
        @poketch["bar2"].zoom_y = 0
        @poketch["bar2"].ox = 384
        @poketch["bar2"].angle = 180
    
        for key in @poketch.keys
          @poketch[key].ox = 0 unless key == "bar2"
          @poketch[key].oy = 0
    
          @poketch[key].z = 2000 unless key == "bar1" || key == "bar2"
          @poketch[key].opacity = 0
        end
      end
    end
    #==============================================================================#
    #                         Function to handle clicks                            #
    #==============================================================================#
      #General click handler for any button in the poketch:
    def clicked?(sprite, animated = true, se="",volume=100,pitch=0,isBtn=true)
      clicked = false
      _isBtn = (isBtn ? true : false)
    
      if $mouse.leftClick?(sprite) && (_isBtn ? (($mouse.x - sprite.x) < sprite.bitmap.width/2) : true)
        pbSEPlay(se,volume,pitch)
        clicked = true
    
        if animated
          sprite.src_rect.set(sprite.bitmap.width/2, 0, sprite.bitmap.width/2, sprite.bitmap.height)
          pbWait(5)
          sprite.src_rect.set(0, 0, sprite.bitmap.width/2, sprite.bitmap.height)
        end
      end
      return clicked
    end
    #==============================================================================#
    #==============================================================================#
    #                          POKETCH AUXILIAR FUNCTIONS                          #
    #==============================================================================#
    # Auxiliar functions to handle pokétch app.                                    #
    #==============================================================================#
    def pbEnablePoketch
      if $POKETCHBLACK && !$POKETCHBLACK.disposed?
        $POKETCHBLACK.zoom_y = 0
        $POKETCHBLACK.opacity = 0
        $poketchDisabled = false
      end
    end
    
    def pbDisablePoketch
      if $POKETCHBLACK && !$POKETCHBLACK.disposed?
        $POKETCHBLACK.zoom_y  = 100
        $POKETCHBLACK.opacity = 80 unless $UndergroundOn
        $poketchDisabled = true
      end
    end
    #==============================================================================#
  5. Copy and paste this in a new script section over main and over SomerPoketch; call it SomerPoketch_Apps
    Ruby:
    Expand Collapse Copy
    #==============================================================================#
    #                    SOMERSAULT'S POKÉTCH APPS AND GRAPHICS                    #
    #                                      v4.1.1                                  #
    #==============================================================================#
    #==============================================================================#
    #                         POKETCH SCREEN LOCATION:                             #
    #         (you can use either numeric values or relative positions)            #
    #==============================================================================#
    POKETCHXPOS   = 0  #x coord of the poketch (specifically of its top left corner)
    POKETCHYPOS   = 0  #y coord of the poketch (specifically of its top left corner)
    
    POKETCH_SCALE = 1  #scale of the poketch (1 for 100%) This is mainly meant for
                       #single-screen mode, when you don't want the poketch to
                       #occupy the whole screen but just a small part (note: you can
                       #use decimals. Reccomended in single screen: 0.5)
    
    GRAPHICSPATH = "Graphics/Pictures/Poketch/"
    POKETCH_DEBUG_APP_IDX = 8
    #==============================================================================#
    #                                POKETCH SOUNDS:                               #
    #==============================================================================#
    MAIN_BUTTONS_SE = "poketchBtn"    #sound for when clicking on the side buttons
    ADD_APP_FANFARE = "Poketch.mid"   #fanfare for when obtaining a new app
    IN_APP_SOUND    = "poketchAppBtn" #sound for buttons inside the poketch screen
    #==============================================================================#
    #                               APPS PARAMETERS:                               #
    #==============================================================================#
    # Apps location relative to the poketch (be careful)
    APP_REL_X = 32
    APP_REL_Y = 32
    
    # Xtransceiver: (require KleinStudio's BW_Xtransceiver script to work. set it to
    # FALSE if you don't have that script in your game. Give credit to him if you do have it):
    XTRANSAPPNUM = 1          # (Index number of the xtransceiver. Starts in 0)
    
    # dot Artist:
    NUMCOLS = 24
    NUMROWS = 20
    
    DOTSIZE = 16
    NUMTONE = 4
    
    #tile tones:
    def pbSelectDotColor(id)
      case id
          when 0; return Color.new(24,40,24)      #(24,40,24)
          when 1; return Color.new(50,82,50)      #(80,128,80)
          when 2; return Color.new(80,128,80)     #(112,176,112)
          when 3; return Color.new(115,180,115)
         #...
         #when n; return Color.new(red,green,blue)
      end
    end
    
    #initial drawing for the dot artist app:
    # 0 = black
    # 1 = grey
    # 2 = light grey
    # 2 = white
    DOTMATRIX = [
          [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],
          [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],
          [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],
          [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],
          [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],
          [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],
          [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],
          [3,0,1,0,1,0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3],
          [3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3],
          [3,3,3,0,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,1,3,3],
          [3,3,3,1,3,1,0,1,3,1,3,1,3,1,0,1,3,1,0,1,3,0,3,3],
          [3,3,3,0,3,0,3,0,3,0,3,0,3,0,3,3,3,0,3,0,3,3,3,3],
          [3,3,3,1,3,1,0,1,3,1,0,1,3,1,0,1,3,1,3,1,3,1,3,3],
          [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],
          [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],
          [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],
          [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],
          [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],
          [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],
          [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3],
        ]
    
    #Marking map:
    MARKER_BLINKING = 20    #time in frames of the cursor blinking
    TILE_SIZE = 12          #size of the map grid in pixels
    LOCATIONS_ARRAY = [
    #[id, x, y,  w,h], # -> mapId-poketchMapXposInTiles-poketchMapYposInTiles-locWidthInTiles-locHeightInTiles
      [34,10,11,  2,2], #Eterna City
      [48,10,11,  1,1], #Eterna City PkmnCenter
      [49,10,11,  1,1], #Eterna City mart
      [40,10,11,  1,1], #Eterna City houses
      [ 4, 7,11,  2,2], #Eterna Forest
      [50,12,11,  1,1], #route 211 west
      [11, 7,13,  1,3], #route 205
      [10, 6,16,  1,2], #Route 204
    #...
    ]
    #===============================================================================
    # HOW TO ADD NEW APPS:
    # 0. Go to STEP 0 (in Poketch Script) and add the following before the line "DebugApp.new(ACTAPPS_C.length)":
    #                             "yourAppName.new(APP_NUM),"
    #    where APP_NUM is the order of the app in the poketch
    # 1. Go to STEP 1 and add a 1 or 0 in the position where you want the app to be. (aka, in position APP_NUM)
    # 2. Go to Step 2 and add in a string the name of your app (aka "yourAppName")
    #   (remember adding the new entry before the line ""Debug"")
    #   (remember adding a comma at the end of your line)
    # 3. Go to the bottom of this script and create a new class with the name of your app.
    #    IMPORTANT: Make it a subclass of the class "App".
    # 4. Define a method called "execute", where you will define the behavior of your app.
    #
    # BONUS: If you wanted to add graphics, do the following (provided that you have
    #   already placed the files in their corresponding folder):
    # 5. Define a method called "loadGraphics", where you will initialize the graphics
    # as follows (you can copy and paste it):
    
    =begin #(this is a comment line, just in case. Code begins in the next line):
      def loadGraphics
        #out of all these, the only mandatory ones are the first two. The rest are optional:
        @app["yourGraphicName"]=Sprite.new(@AppViewport)
        @app["yourGraphicName"].bitmap=Bitmap.new(GRAPHICSPATH + "your_subfolder/yourGraphicName.png")
        @app["yourGraphicName"].x = APPX
        @app["yourGraphicName"].y = APPY
        @app["yourGraphicName"].ox = 0      #set your x axis origin, relative to your graphic
        @app["yourGraphicName"].oy = 0      #set your y axis origin, relative to your graphic
        @app["yourGraphicName"].z = 0       #whether it will be place more in front or behind
        @app["yourGraphicName"].opacity = 0
        @app["yourGraphicName"].zoom_x = 0  #to change the x scale
        @app["yourGraphicName"].zoom_y = 0  #to change the y scale
    
        #to show just a rectangular area of the whole graphic (for example, from the badges file, to show only one)
        @app["yourGraphicName"].src_rect.set(0,0,0,0)  #where the parameters are: x and y of the rectangle; and width and height.
    
        #Do this for each graphic you want to add. Make sure to change "yourGraphicName" each time
      end
    =end #(this is a comment line, just in case. Code ends in the previous line)
    
    # Note: If you needed extra functions you can of course add them in.
    # Note 2: If you needed to initialize a certain variable(s) do the following:
    
    =begin #(this is a comment line, just in case. Code begins in the next line):
      def initialize(id)
        super(id)
    
        #initialize your variables here
      end
    =end #(this is a comment line, just in case. Code ends in the previous line)
    #==============================================================================#
    #                                   (STEP 1)                                   #
    #       Array of apps activated by default (when obtaining the poketch):       #
    #   NOTE: if you needed more apps, then add just a comma and your new number   #
    #==============================================================================#
    ACTAPPS_C = [1,1,1,1,0,0,0,0]
    #==============================================================================#
    #                                   (STEP 2)                                   #
    #                    Names to be shown when obtaining an app                   #
    #(The number and order of entries match with the number of elements in ACTAPPS)#
    #==============================================================================#
    APPS_INGAME_NAMES = [
      "Clock",
      "Xtransceiver",
      "Marking Map",
      "Pedometer",
      "Dot Artist",
      "",
      "",
      "",
      "Debug" #this is an extra one. Aka, don't take it into account when counting
    ]
    #==============================================================================#
    #                               DO-NOT-TOUCH STUFF                             #
    #                    (Unless you want the script to stop working)              #
    #==============================================================================#
    module AppExecutor
      def self.parse(id)
        $appArray.each { |app| return app if app.id == id }
        return nil
      end
    end
    #------------------------------------------------------------------------------#
    $dot_artist_switch = false
    $changingApp       = false
    
    APPX = POKETCHXPOS+APP_REL_X
    APPY = POKETCHYPOS+APP_REL_Y
    #==============================================================================#
    #==============================================================================#
    #                               SCRIPT STARTS HERE                             #
    #==============================================================================#
    #==============================================================================#
    class App
      @AppViewport = Viewport.new(POKETCHXPOS,POKETCHYPOS,Graphics.width,Graphics.height)
    
      attr_accessor :id
      def initialize(id)
        @id = id
        @app= {}
        @name = APPS_INGAME_NAMES[@id] #currently with no use, but prepared just in case
      end
    
      def createGraphics
        loadGraphics
        for key in @app.keys
          pbApplyRescaleRel(@app[key],POKETCHXPOS,POKETCHYPOS,POKETCH_SCALE)
        end
      end
      def loadGraphics; end
      def execute; end;
      def dispose; pbDisposeGraphicsOf(@app); end
    
      def getAppName; return @name; end #currently with no use, but prepared just in case
    end
    #==============================================================================#
    #                                  CLOCK APP                                   #
    #==============================================================================#
    class ClockApp < App
      def execute
        if @oldmin != Time.now.min || $changingApp
          @oldhour=Time.now.hour
          @oldmin=Time.now.min
    
          @clockw=@app["hour0"].bitmap.width/10
          @clockh=@app["hour0"].bitmap.height
    
          @hour=sprintf("%02d",Time.now.hour)
          @hour0=@hour[0,1].to_i
          @hour1=@hour[1,2].to_i
          @min=sprintf("%02d",Time.now.min)
          @min0=@min[0,1].to_i
          @min1=@min[1,2].to_i
    
          @app["hour0"].src_rect.set(@clockw*@hour0,0,@clockw,@clockh) #if @app["hour0"]
          @app["hour1"].src_rect.set(@clockw*@hour1,0,@clockw,@clockh) #if @app["hour1"]
          @app["min0"].src_rect.set(@clockw*@min0,0,@clockw,@clockh)   #if @app["min0"]
          @app["min1"].src_rect.set(@clockw*@min1,0,@clockw,@clockh)   #if @app["min1"]
        end
      end
    
      def loadGraphics
        @app["clockBg"]=Sprite.new(@AppViewport)
        @app["clockBg"].bitmap=Bitmap.new(GRAPHICSPATH + "Clock/background.png")
        @app["clockBg"].x = APPX
        @app["clockBg"].y = APPY
        @app["clockBg"].z = 2000
    
        @app["hour0"]=Sprite.new(@AppViewport)
        @app["hour0"].bitmap=Bitmap.new(GRAPHICSPATH + "Clock/numbers.png")
        @app["hour0"].x = APPX + 16
        @app["hour0"].y = APPY + 82
        @app["hour0"].z = 2000
    
        @app["hour1"]=Sprite.new(@AppViewport)
        @app["hour1"].bitmap=Bitmap.new(GRAPHICSPATH + "Clock/numbers.png")
        @app["hour1"].x = APPX + 96
        @app["hour1"].y = APPY + 82
        @app["hour1"].z = 2000
    
        @app["min0"]=Sprite.new(@AppViewport)
        @app["min0"].bitmap=Bitmap.new(GRAPHICSPATH + "Clock/numbers.png")
        @app["min0"].x = APPX + 208
        @app["min0"].y = APPY + 82
        @app["min0"].z = 2000
    
        @app["min1"]=Sprite.new(@AppViewport)
        @app["min1"].bitmap=Bitmap.new(GRAPHICSPATH + "Clock/numbers.png")
        @app["min1"].x = APPX + 288
        @app["min1"].y = APPY + 82
        @app["min1"].z = 2000
      end
    end
    #==============================================================================#
    #                               XTRANSCEIVER APP                               #
    #==============================================================================#
    class XtransceiverApp < App
      def initialize(id)
        super(id)
        @whNoiseFrame = 0
        @whNoiseFreq = 2
      end
    
      def execute
    
    
        if XTRANSCEIVERADDED 
          @whNoiseFrame += 1
          @whNoiseFrame = @whNoiseFrame % (@whNoiseFreq * 4)
    
          if @whNoiseFrame % @whNoiseFreq == 0
            #Graphics.update
            @app["whiteNoise"].src_rect.set(((@app["whiteNoise"].bitmap.width / 4) - 2) * (@whNoiseFrame / @whNoiseFreq),0,(
            @app["whiteNoise"].bitmap.width / 4) - 2, @app["whiteNoise"].bitmap.height)
          end
    
          if !@app["button"].disposed?
            if $mouse.leftClick?(@app["button"]) && @app["button"].opacity == 255
              pbXtransceiver
            end
          end
        end
      end
    
      def loadGraphics
        if XTRANSCEIVERADDED
          @app["xTransBg"]=Sprite.new(@AppViewport)
          @app["xTransBg"].bitmap=Bitmap.new(GRAPHICSPATH + "Xtransceiver/bgXtran.png")
          @app["xTransBg"].x=APPX
          @app["xTransBg"].y=APPY
          @app["xTransBg"].z = 2000
    
          @app["player"]=Sprite.new(@AppViewport)
          @app["player"].bitmap=Bitmap.new(GRAPHICSPATH + "Xtransceiver/" + $person + "player.png")
          @app["player"].x=APPX + 168
          @app["player"].y=APPY + 2
          @app["player"].z = 2000
          @app["player"].tone.gray = 125
          @app["player"].tone.green = 85
    
          @app["whiteNoise"]=Sprite.new(@AppViewport)
          @app["whiteNoise"].bitmap=Bitmap.new(GRAPHICSPATH + "Xtransceiver/WhiteNoise.png")
          @app["whiteNoise"].x=APPX + 2
          @app["whiteNoise"].y=APPY + 34
          @app["whiteNoise"].z = 2000
          @app["whiteNoise"].src_rect.set(0,0,(@app["whiteNoise"].bitmap.width / 4) - 2, @app["whiteNoise"].bitmap.height)
    
          @app["overlay"]=Sprite.new(@AppViewport)
          @app["overlay"].bitmap=Bitmap.new(GRAPHICSPATH + "Xtransceiver/overlay.png")
          @app["overlay"].x=APPX
          @app["overlay"].y=APPY
          @app["overlay"].z = 2000
    
          @app["button"]=Sprite.new(@AppViewport)
          @app["button"].bitmap=Bitmap.new(GRAPHICSPATH + "Xtransceiver/button.png")
          @app["button"].x=APPX + 217
          @app["button"].y=APPY + 174
          @app["button"].z = 2000
        end
      end
    end
    #==============================================================================#
    #                             MARKING MAP APP                                  #
    #==============================================================================#
    class MarkingMapApp < App
      def initialize(id)
        super(id)
        @counter = 0#map marker counter
        @mapIdx  = 0
    
        @currentPortionX = 0
        @currentPortionY = 0
      end
    #-------------------------------------------------------------------------------
      def checkChangingPortionX
        change = false
        #checking X upper bound:
        if $game_player.x - $game_map.width * @currentPortionX / LOCATIONS_ARRAY[@mapIdx][3] > 0
          @currentPortionX += 1
          change = true
        #checking X lower bound:
        elsif $game_player.x - $game_map.width * (@currentPortionX - 1) / LOCATIONS_ARRAY[@mapIdx][3] > 0
          @currentPortionX -= 1
          change = true
        end
    
        return change
      end
    
      def checkChangingPortionY
        change = false
        #checking Y upper bound:
        if $game_player.y - $game_map.height * @currentPortionY / LOCATIONS_ARRAY[@mapIdx][4] > 0
          @currentPortionY += 1
          change = true
        #checking Y lower bound:
        elsif $game_player.y - $game_map.height * (@currentPortionY - 1) / LOCATIONS_ARRAY[@mapIdx][4] > 0
          @currentPortionY -= 1
          change = true
        end
    
        return change
      end
    
      def checkChangingPortion; return checkChangingPortionX || checkChangingPortionY; end
    #-------------------------------------------------------------------------------
      def findRightPlace
        #checking in which part of the town/route/city is the player
        if LOCATIONS_ARRAY[@mapIdx][3] > 1 || LOCATIONS_ARRAY[@mapIdx][4] > 1
          #find x portion
          for i in 0...LOCATIONS_ARRAY[@mapIdx][3]
            if $game_player.x <= ($game_map.width * (i+1) / LOCATIONS_ARRAY[@mapIdx][3])
              @currentPortionX = i
              break
            end
          end
    
          #find y portion
          for i in 0...LOCATIONS_ARRAY[@mapIdx][4]
            if $game_player.y <= ($game_map.height * (i+1) / LOCATIONS_ARRAY[@mapIdx][4])
              @currentPortionY = i
              break
            end
          end
    
          @app["marker"].x = ((APP_REL_X + TILE_SIZE*(LOCATIONS_ARRAY[@mapIdx][1]+@currentPortionX))*POKETCH_SCALE) + POKETCHXPOS
          @app["marker"].y = ((APP_REL_Y + TILE_SIZE*(LOCATIONS_ARRAY[@mapIdx][2]+@currentPortionY))*POKETCH_SCALE) + POKETCHYPOS
        else
          @app["marker"].x = ((APP_REL_X + TILE_SIZE*LOCATIONS_ARRAY[@mapIdx][1])*POKETCH_SCALE) + POKETCHXPOS
          @app["marker"].y = ((APP_REL_Y + TILE_SIZE*LOCATIONS_ARRAY[@mapIdx][2])*POKETCH_SCALE) + POKETCHYPOS
        end
      end
    #-------------------------------------------------------------------------------
      def execute
        #setting marker opacity:
        @counter = (@counter + 1) % MARKER_BLINKING
        @app["marker"].opacity = 255 - @app["marker"].opacity if @counter == 0
    
        #updating cursor position:
        if $game_map.map_id != @currentMapId || $changingApp
          @currentMapId = $game_map.map_id
    
          for i in 0...LOCATIONS_ARRAY.length
            if LOCATIONS_ARRAY[i][0] == $game_map.map_id
              @mapIdx = i
              findRightPlace
              break
            end
          end
        else
          findRightPlace if LOCATIONS_ARRAY[@mapIdx] and checkChangingPortion
        end
      end
    
      def loadGraphics
        @app["background"]=Sprite.new(@AppViewport)
        @app["background"].bitmap=Bitmap.new(GRAPHICSPATH + "Marking Map/background.png")
        @app["background"].x = APPX
        @app["background"].y = APPY
        @app["background"].z = 2000
    
        @app["marker"]=Sprite.new(@AppViewport)
        @app["marker"].bitmap=Bitmap.new(GRAPHICSPATH + "Marking Map/marker")
        @app["marker"].x = APPX
        @app["marker"].y = APPY
        @app["marker"].z = 2000
        @app["marker"].ox = 8
        @app["marker"].oy = 8
        @app["marker"].opacity = 0
      end
    end
    #==============================================================================#
    #                                PEDOMETER APP                                 #
    #==============================================================================#
    class PedometerApp < App
      def pbDisplayNumberLCD(number, _digits, numDigits, numWidth, numHeight)
        daSteps = pbChDigitsAmount(number)
        daSteps = daSteps.to_s.split("")
    
        for i in 0...numDigits
          _digits[numDigits - 1 - i].src_rect.set(daSteps[i].to_i * numWidth, 0, numWidth, numHeight)
        end
      end
    
      def execute
        digits = []
        for i in 0...5
          digits[i] = @app["pedoDig" + i.to_s]
        end
        pbDisplayNumberLCD($Trainer.steps, digits, 5, 24, 59)
    
        $Trainer.steps = 0 if clicked?(@app["pedoBtn"],true,IN_APP_SOUND,100)
      end
    
      def loadGraphics
        @app["pedoBg"]=Sprite.new(@AppViewport)
        @app["pedoBg"].bitmap= Bitmap.new(GRAPHICSPATH + "Pedometer/background.png")
        @app["pedoBg"].x = APPX
        @app["pedoBg"].y = APPY
        @app["pedoBg"].z = 2000
    
        @app["pedoBtn"]=Sprite.new(@AppViewport)
        @app["pedoBtn"].bitmap= Bitmap.new(GRAPHICSPATH + "Pedometer/btn.png")
        @app["pedoBtn"].x = APPX + 134
        @app["pedoBtn"].y = APPY + 160
        @app["pedoBtn"].z = 2000
        @app["pedoBtn"].src_rect.set(0,0,@app["pedoBtn"].bitmap.width / 2, @app["pedoBtn"].bitmap.height)
    
        #digits:
        for i in 0...5
          @app["pedoDig" + i.to_s]=Sprite.new(@AppViewport)
          @app["pedoDig" + i.to_s].bitmap= Bitmap.new(GRAPHICSPATH + "Pedometer/numbers.png")
          @app["pedoDig" + i.to_s].src_rect.set(0,0,24,59)
          @app["pedoDig" + i.to_s].x = APPX + 244 - (32 * i)
          @app["pedoDig" + i.to_s].y = APPY + 66
          @app["pedoDig" + i.to_s].z = 2000
        end
      end
    end
    #==============================================================================#
    #                               DOT ARTIST APP                                 #
    #==============================================================================#
    class DotArtistApp < App
      def initDotArtist
        @DotMatrix = $PokemonGlobal.dotMatrix
        for i in 0...NUMROWS
          for j in 0...NUMCOLS
            artistColor = pbSelectDotColor(@DotMatrix[i][j])
    
            @app["dtArtBg"].draw_rectangle(
              (j*DOTSIZE + DOTSIZE/2).to_i,
              (i*DOTSIZE + DOTSIZE/2).to_i,
              DOTSIZE, DOTSIZE, artistColor, true)
          end
        end
      end
    
      def execute
        if clicked?(@app["dtArtBg"],false,"",0,0,false)
          xIdx = ($mouse.x - (APP_REL_X*POKETCH_SCALE).to_i-POKETCHXPOS)/(DOTSIZE*POKETCH_SCALE).to_i
          yIdx = ($mouse.y - (APP_REL_Y*POKETCH_SCALE).to_i-POKETCHYPOS)/(DOTSIZE*POKETCH_SCALE).to_i
    
          @DotMatrix[yIdx][xIdx] += 1
          @DotMatrix[yIdx][xIdx] %= NUMTONE
    
          artistColor = pbSelectDotColor(@DotMatrix[yIdx][xIdx])
    
    
          @app["dtArtBg"].draw_rectangle(
            (xIdx*DOTSIZE+DOTSIZE/2).to_i,
            (yIdx*DOTSIZE+DOTSIZE/2).to_i,
            DOTSIZE,DOTSIZE, artistColor, true)
    
          $PokemonGlobal.dotMatrix = @DotMatrix
        end
      end
    
      def loadGraphics
        @app["dtArtBg"] = Sprite.new(@AppViewport)
        @app["dtArtBg"].bitmap = Bitmap.new(GRAPHICSPATH + "blank.png")
        @app["dtArtBg"].x = APPX
        @app["dtArtBg"].y = APPY
        @app["dtArtBg"].z = 2000
    
        initDotArtist
      end
    end
    #==============================================================================#
    #                                  DEBUG APP                                   #
    #==============================================================================#
    class DebugApp < App
      def initialize(id)
        super(id)
        @id = ACTAPPS_C.length
        @name = APPS_INGAME_NAMES[@id]
      end
    
      def execute; pbDebugMenu if clicked?(@app["btnD"],true); end
    
      def loadGraphics
        @app["debugBg"]=Sprite.new(@AppViewport)
        @app["debugBg"].bitmap=Bitmap.new(GRAPHICSPATH + "blank.png")
        @app["debugBg"].x = APPX
        @app["debugBg"].y = APPY
        @app["debugBg"].z = 2000
        @app["debugBg"].opacity = 0
    
        @app["btnD"]=Sprite.new(@AppViewport)
        @app["btnD"].bitmap = Bitmap.new(GRAPHICSPATH + "dbgbtn")
        @app["btnD"].x = APPX + 56
        @app["btnD"].y = APPY + 104
        @app["btnD"].z = 2000
        @app["btnD"].src_rect.set(0, 0, @app["btnD"].bitmap.width/2, @app["btnD"].bitmap.height)
      end
    end
    #==============================================================================#
  6. Done! Enjoy!
Credits
A. Somersault
Marin: for "Better Bitmaps" script (and only for that. This script has been made 100% from scratch)
Author
Somersault
Views
2,153
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from Somersault

Back
Top