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
Click here to go to the first staff post in this thread.  
Thread Tools
  #26    
Old May 23rd, 2013, 07:42 AM
Obito Uchiha's Avatar
Obito Uchiha
 
Join Date: Apr 2013
Gender: Male
Thank you, but I already put this command-line. I can access to the mystery gift option, but I can't make the window to show the mystery gift option, cause this conditional branch doesn't work (Sorry that I hadn't mentioned this before). Unfortunalety, things like "something else like" or "around" doesn't help me. I'm not a coder as you see.
__________________
Reply With Quote
  #27    
Old May 23rd, 2013, 11:33 AM
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
Quote:
Originally Posted by Obito Uchiha View Post
Thank you, but I already put this command-line. I can access to the mystery gift option, but I can't make the window to show the mystery gift option, cause this conditional branch doesn't work (Sorry that I hadn't mentioned this before). Unfortunalety, things like "something else like" or "around" doesn't help me. I'm not a coder as you see.
Try removing the brackets, rescue and false...

Where is the Mystery Gift event in Essentials? I'll take a quick look at how Mystery Gift works and take a look myself
Reply With Quote
  #28    
Old May 23rd, 2013, 01:19 PM
Obito Uchiha's Avatar
Obito Uchiha
 
Join Date: Apr 2013
Gender: Male
You can find the events on the "Lerucean Town Mart"-Map.
__________________
Reply With Quote
  #29    
Old May 23rd, 2013, 01:55 PM
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
I'll go take a look now and see what's up...

EDIT:

If the mystery gift works during the game... Why would you want it to appear on the load screen?
It would seem so far that I can't get mystery gift to appear on the load screen anyway, so I don't think I can help you unless I can get that to work

EDIT:

So I figured out everything.

Code:
class PokemonLoadScene # :doc:
  def pbUpdate
    pbUpdateSpriteHash(@sprites)
  end

  def pbStartScene
    @sprites={}
    @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
    @viewport.z=99998
    savefile=RTP.getSaveFileName("Game.rxdata")
    
    @sprites["overlay"]=BitmapSprite.new(Graphics.width, Graphics.height)
    @sprites["overlay"].z = 99999
    @overlay=@sprites["overlay"].bitmap
    @overlay.clear
    baseColor=Color.new(239, 239, 239)
    shadowColor=Color.new(140,140,140)
    pbSetSystemFont(@sprites["overlay"].bitmap)
        
    if safeExists?(savefile)      
      @sprites["Continue"] = Sprite.new
      @sprites["Continue"].x = 52
      @sprites["Continue"].y = 4
      @sprites["Continue"].z = 99998
      @sprites["Continue"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Continue")
      @sprites["Continue"].opacity = 210
      
      @sprites["NewGame"] = Sprite.new
      @sprites["NewGame"].x = 68
      @sprites["NewGame"].y = 232
      @sprites["NewGame"].z = 99998
      @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
      @sprites["NewGame"].opacity = 210      
      
      @sprites["MysteryGift"] = Sprite.new
      @sprites["MysteryGift"].x = 68
      @sprites["MysteryGift"].y = 282
      @sprites["MysteryGift"].z = 99998
      @sprites["MysteryGift"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
      @sprites["MysteryGift"].opacity = 210
      
      @sprites["Options"] = Sprite.new
      @sprites["Options"].x = 68
      @sprites["Options"].y = 332
      @sprites["Options"].z = 99998
      @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
      @sprites["Options"].opacity = 210
      
      textpos=[
      [_INTL("CONTINUE"),84,10,false,baseColor,shadowColor],
      [_INTL("NEW GAME"),84,238,false,baseColor,shadowColor],
      [_INTL("MYSTERY GIFT"),84,288,false,baseColor,shadowColor],
      [_INTL("OPTIONS"),84,338,false,baseColor,shadowColor],
      #[_INTL(
      ]
      pbDrawTextPositions(@overlay,textpos)
    else
      @sprites["NewGame"] = Sprite.new
      @sprites["NewGame"].x = 68
      @sprites["NewGame"].y = 142
      @sprites["NewGame"].z = 99998
      @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
      @sprites["NewGame"].opacity = 210
      
      @sprites["Options"] = Sprite.new
      @sprites["Options"].x = 68
      @sprites["Options"].y = 192
      @sprites["Options"].z = 99998
      @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
      @sprites["Options"].opacity = 210
      
      textpos=[
      [_INTL("NEW GAME"),84,148,false,baseColor,shadowColor],
      [_INTL("OPTIONS"),84,198,false,baseColor,shadowColor],
      ]
      pbDrawTextPositions(@overlay,textpos)
      
    end
    
    addBackgroundOrColoredPlane(@sprites,"background","loadbg",
       Color.new(96,96,248),@viewport)
    @sprites["locwindow"]=Window_AdvancedTextPokemon.new("")
    @sprites["locwindow"].viewport=@viewport
    @sprites["locwindow"].visible=false
    @sprites["cmdwindow"]=Window_CommandPokemon.new([])
    @sprites["cmdwindow"].x=512
    @sprites["cmdwindow"].y=0
    @sprites["cmdwindow"].viewport=@viewport
    @sprites["cmdwindow"].visible=false
    pbFadeInAndShow(@sprites) { pbUpdate }
  end

  def pbSetAuxiliaryWindow(loctext)
     @sprites["locwindow"].resizeToFit(loctext,Graphics.width-@sprites["cmdwindow"].width)
     @sprites["locwindow"].width=228 if @sprites["locwindow"].width<228
     @sprites["locwindow"].height=Graphics.height
     @sprites["locwindow"].x=512#Graphics.width-@sprites["locwindow"].width
     @sprites["locwindow"].visible=true
     @sprites["locwindow"].text=loctext
  end

  def pbSetParty(trainer,hasPokedex=false)
    for i in 0...trainer.party.length
      @sprites["party#{i}"]=PokemonIconSprite.new(trainer.party[i])
      @sprites["party#{i}"].z=99999
      @sprites["party#{i}"].x=80+60*i
      @sprites["party#{i}"].y=150
    end
  end

  def pbChoose(commands)
    @sprites["cmdwindow"].resizeToFit(commands)
    @sprites["cmdwindow"].commands=commands
    @sprites["cmdwindow"].x=512
    @sprites["cmdwindow"].y=0
    @sprites["cmdwindow"].visible=true
    loop do
      Graphics.update
      Input.update
      pbUpdate
      savefile=RTP.getSaveFileName("Game.rxdata")
      if safeExists?(savefile)
        if @sprites["cmdwindow"].index==0
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["Continue"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Continue_S")
          @sprites["MysteryGift"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
        elsif @sprites["cmdwindow"].index==1
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar_S")
          @sprites["Continue"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Continue")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
        elsif @sprites["cmdwindow"].index==2
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["Continue"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Continue")
          @sprites["MysteryGift"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar_S")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
        elsif @sprites["cmdwindow"].index==3
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["Continue"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Continue")
          @sprites["MysteryGift"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar_S")
        end
      else
        if @sprites["cmdwindow"].index==0
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar_S")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
        elsif @sprites["cmdwindow"].index==1
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar_S")
        end
      end
      
      if Input.trigger?(Input::C)
        return @sprites["cmdwindow"].index
      end
    end
  end

  def pbEndScene
    pbFadeOutAndHide(@sprites) { pbUpdate }
    pbDisposeSpriteHash(@sprites)
    @viewport.dispose
  end

  def pbCloseScene
    pbDisposeSpriteHash(@sprites)
    @viewport.dispose
  end
end



module FontInstaller # :doc:
  # filenames of fonts to be installed
  Filenames = [
     'pkmnem.ttf',
     'pkmnemn.ttf',
     'pkmnems.ttf',
     'pkmnrs.ttf',
     'pkmndp.ttf',
     'pkmnfl.ttf'
  ]    
  # names (not filenames) of fonts to be installed
  Names = [
    'Power Green',
    'Power Green Narrow',
    'Power Green Small',
    'Power Red and Blue',
    'Power Clear',
    'Power Red and Green'
  ]
  # whether to notify player (via pop-up message) that fonts were installed
  Notify = true
  # location of fonts (relative to game folder)
  Source = 'Fonts/'

  def self.getFontFolder
    fontfolder=MiniRegistry.get(MiniRegistry::HKEY_CURRENT_USER,
       "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
       "Fonts")
    return fontfolder+"\\" if fontfolder
    if ENV['SystemRoot']
      return ENV['SystemRoot'] + '\\Fonts\\'
    elsif ENV['windir']
      return ENV['windir'] + '\\Fonts\\'
    else
      return '\\Windows\\Fonts\\'
    end   
  end

  AFR = Win32API.new('gdi32', 'AddFontResource', ['P'], 'L')
  WPS = Win32API.new('kernel32', 'WriteProfileString', ['P'] * 3, 'L')
  SM = Win32API.new('user32', 'PostMessage', ['L'] * 4, 'L')
  WM_FONTCHANGE = 0x001D
  HWND_BROADCAST = 0xffff

  def self.copy_file(src,dest)
    File.open(src,  'rb') {|r|
       File.open(dest, 'wb') {|w|
          while s = r.read(4096)
            w.write s
          end
       }
    }
  end

  def self.pbResolveFont(name)
    RTP.eachPathFor(Source+name) {|file|
       return file if safeExists?(file)
    }
    return Source+name
  end

  def self.install
    success = []
    # Check if all fonts already exist
    filesExist=true
    fontsExist=true
    dest=self.getFontFolder()
    for i in 0...Names.size
      if !safeExists?(dest + Filenames[i])
        filesExist=false
      end
      if !Font.exist?(Names[i])
        fontsExist=false
      end
    end
    return if filesExist
    # Check if all source fonts exist
    exist=true
    for i in 0...Names.size
      if !RTP.exists?(Source + Filenames[i])
        exist=false
        break
      end
    end
    return if !exist # Exit if not all source fonts exist
    Kernel.pbMessage(_INTL("One or more fonts used in this game do not exist on the system.\1"))
    Kernel.pbMessage(_INTL("The game can be played, but the look of the game's text will not be optimal.\1"))
    failed=false
    for i in 0...Filenames.size
      f = Filenames[i]
      if safeExists?(dest + f) && !Font.exist?(Names[i])
        File.delete(dest + f) rescue nil
      end
      # check if already installed...
      if not safeExists?(dest + f)
        # check to ensure font is in specified location...
        if RTP.exists?(Source + f)
          # copy file to fonts folder
          succeeded=false
          begin
            copy_file(pbResolveFont(f), dest + f)
            # add font resource
            AFR.call(dest + f)
            # add entry to win.ini/registry
            WPS.call('Fonts', Names[i] + ' (TrueType)', f)
            succeeded=safeExists?(dest + f)
            rescue SystemCallError
            # failed
            succeeded=false
          end
          if succeeded
            success.push(Names[i])
          else
            failed=true
          end
        end
      else
        success.push(Names[i]) # assume success
      end
    end
    if success.length>0 # one or more fonts successfully installed
      SM.call(HWND_BROADCAST,WM_FONTCHANGE,0,0)
      if Notify
        fonts = ''
        success.each do |f|
          fonts << f << ', '
        end
        if failed
          Kernel.pbMessage(_INTL("Some of the fonts were successfully installed.\1"))
          Kernel.pbMessage(_INTL("To install the other fonts, copy the files in this game's Fonts folder to the Fonts folder in Control Panel."))
        else
          Kernel.pbMessage(_INTL("The fonts were successfully installed.\1"))
        end
        if Kernel.pbConfirmMessage(_INTL("Would you like to restart the game and apply the changes?"))
          a = Thread.new { system('Game') }
          exit
        end
      end
    else
      # No fonts were installed.
      Kernel.pbMessage(_INTL("To install the necessary fonts, copy the files in this game's Fonts folder to the Fonts folder in Control Panel."))
    end
  end
end



class PokemonLoad
  def initialize(scene)
    @scene=scene
  end

  def pbDisplay(text,brief=false)
    @scene.pbDisplay(text,brief)
  end

  def pbDisplayPaused(text)
    @scene.pbDisplayPaused(text)
  end

  def pbConfirm(text)
    return @scene.pbConfirm(text)
  end

  def pbTryLoadFile(savefile)
    trainer=nil
    framecount=nil
    game_system=nil
    pokemonSystem=nil
    mapid=nil
    File.open(savefile){|f|
       trainer=Marshal.load(f)
       framecount=Marshal.load(f)
       game_system=Marshal.load(f)
       pokemonSystem=Marshal.load(f)
       mapid=Marshal.load(f)
    }
    raise "Corrupted file" if !trainer.is_a?(PokeBattle_Trainer)
    raise "Corrupted file" if !framecount.is_a?(Numeric)
    raise "Corrupted file" if !game_system.is_a?(Game_System)
    raise "Corrupted file" if !pokemonSystem.is_a?(PokemonSystem)
    raise "Corrupted file" if !mapid.is_a?(Numeric)
    return [trainer,framecount,game_system,pokemonSystem,mapid]
  end

  def pbStartDeleteScreen
    savefile=RTP.getSaveFileName("Game.rxdata")
    @scene.pbStartScene
    if safeExists?(savefile)
      if Kernel.pbConfirmMessageSerious(_INTL("Delete all saved data?"))
        Kernel.pbMessage(_INTL("Once data has been deleted, there is no way to recover it.\1"))
        if Kernel.pbConfirmMessageSerious(_INTL("Delete the saved data anyway?"))
          Kernel.pbMessage(_INTL("Deleting all data.\r\nDon't turn off the power.\\wtnp[0]"))
          begin; File.delete(savefile); rescue; end
          begin; File.delete(savefile+".bak"); rescue; end
          Kernel.pbMessage(_INTL("The save file was deleted."))
        end
      end
    else
      Kernel.pbMessage(_INTL("No save file was found."))
    end
    @scene.pbEndScene
    $scene=pbCallTitle
  end

  def pbStartLoadScreen
    $PokemonTemp   = PokemonTemp.new
    $game_temp     = Game_Temp.new
    $game_system   = Game_System.new
    $PokemonSystem = PokemonSystem.new if !$PokemonSystem
    @scene.pbStartScene
    cmdContinue=-1
    cmdNewGame=0
    cmdOption=1
    cmdLanguage=-1
    commands=[]
    savefile=RTP.getSaveFileName("Game.rxdata")
    FontInstaller.install
    data_system = pbLoadRxData("Data/System")
    mapfile=$RPGVX ? sprintf("Data/Map%03d.rvdata",data_system.start_map_id) :
                     sprintf("Data/Map%03d.rxdata",data_system.start_map_id)
    if data_system.start_map_id==0 || !pbRgssExists?(mapfile)
      Kernel.pbMessage(_INTL("No starting position was set in the map editor.\1"))
      Kernel.pbMessage(_INTL("The game cannot continue."))
      @scene.pbEndScene
      $scene=nil
      return
    end
    if safeExists?(savefile)
      trainer=nil
      framecount=0
      showContinue=false
      haveBackup=false
      begin
        trainer, framecount, $game_system, $PokemonSystem, mapid=pbTryLoadFile(savefile)
        showContinue=true
        rescue
        if safeExists?(savefile+".bak")
          begin
            trainer, framecount, $game_system, $PokemonSystem, mapid=pbTryLoadFile(savefile+".bak")
            haveBackup=true
            showContinue=true
            rescue
          end
        end
        if haveBackup
          Kernel.pbMessage(_INTL("The save file is corrupt.  The previous save file will be loaded."))
        else
          Kernel.pbMessage(_INTL("The save file is corrupt, or is incompatible with this game."))
          if !Kernel.pbConfirmMessageSerious(_INTL("Do you want to delete the save file and start anew?"))
            raise "scss error - Corrupted or incompatible save file."
          end
          begin; File.delete(savefile); rescue; end
          begin; File.delete(savefile+".bak"); rescue; end
          $PokemonSystem=PokemonSystem.new if !$PokemonSystem
          $game_system=Game_System.new
          Kernel.pbMessage(_INTL("The save file was deleted."))
        end
      end
      if showContinue
        if !haveBackup
          begin; File.delete(savefile+".bak"); rescue; end
          end
        totalsec = framecount / Graphics.frame_rate
        hour = totalsec / 60 / 60
        min = totalsec / 60 % 60
        mapname=pbGetMapNameFromId(mapid)
        mapname.gsub!(/\\PN/,trainer.name)
        textColor=["0070F8,78B8E8","E82010,F8A8B8","0070F8,78B8E8"][trainer.gender]
        loctext=_INTL("<ac><c2=06644bd2>{1}</c2></ac>",mapname)
        loctext+=_INTL("Player<r><c3={1}>{2}</c3><br>",textColor,fmtescape(trainer.name))
        loctext+=_ISPRINTF("Time<r><c3={1:s}>{2:02d}:{3:02d}</c3><br>",textColor,hour,min)
        loctext+=_INTL("Badges<r><c3={1}>{2}</c3><br>",textColor,trainer.numbadges)
        if trainer.pokedex
          loctext+=_INTL("Pokédex<r><c3={1}>{2}/{3}</c3><br>",textColor,trainer.pokedexOwned,trainer.pokedexSeen)
        end
        
        @sprites={}
        @sprites["overlay"]=BitmapSprite.new(Graphics.width, Graphics.height)
        @sprites["overlay"].z = 99999
        @overlay=@sprites["overlay"].bitmap
        @overlay.clear
        baseColor=Color.new(239, 239, 239)
        shadowColor=Color.new(140,140,140)
        pbSetSystemFont(@sprites["overlay"].bitmap)
    
        textpos=[
        [_INTL("{1}",trainer.name),84,60,false,Color.new(57,165,255),Color.new(57,107,173)],
        [_INTL("{1}",mapname),84,90,false,baseColor,shadowColor],
        [_INTL("Badges: {1}",trainer.numbadges),84,135,false,baseColor,shadowColor],
        [_ISPRINTF("Time: {1:02d}:{2:02d}",hour,min),220,135,false,baseColor,shadowColor],
        ]
        pbDrawTextPositions(@overlay,textpos)
          
        loctext+=_INTL("Party") if trainer.party.length>0
        @scene.pbSetAuxiliaryWindow(loctext)
        @scene.pbSetParty(trainer,trainer.pokedex)
      end
      commands[cmdContinue=commands.length]=_INTL("Continue") if showContinue
      commands[cmdNewGame=commands.length]=_INTL("New Game")
      commands[cmdMysteryGift=commands.length]=_INTL("Mystery Gift") if (trainer.mysterygiftaccess rescue false)
      commands[cmdOption=commands.length]=_INTL("Options")
    else
      commands[cmdNewGame=commands.length]=_INTL("New Game")
      commands[cmdOption=commands.length]=_INTL("Options")
    end
    if LANGUAGES.length>=2
      commands[cmdLanguage=commands.length]=_INTL("Language")
    end
    loop do
      command=@scene.pbChoose(commands)
      if cmdNewGame>=0 && command==cmdNewGame
        savefile=RTP.getSaveFileName("Game.rxdata")
        if safeExists?(savefile)
          @sprites["overlay"].opacity = 0
        end
        @scene.pbEndScene
        if $game_map && $game_map.events
          for event in $game_map.events.values
            event.clear_starting
          end
        end
        $game_temp.common_event_id=0 if $game_temp
        $scene               = Scene_Map.new
        Graphics.frame_count = 0
        $game_system         = Game_System.new
        $game_switches       = Game_Switches.new
        $game_variables      = Game_Variables.new
        $game_self_switches  = Game_SelfSwitches.new
        $game_screen         = Game_Screen.new
        $game_player         = Game_Player.new
        $ItemData            = readItemList("Data/items.dat")
        $PokemonMap          = PokemonMapMetadata.new
        $PokemonGlobal       = PokemonGlobalMetadata.new
        $PokemonStorage      = PokemonStorage.new
        $PokemonEncounters   = PokemonEncounters.new
        $PokemonTemp.begunNewGame=true
        $data_system         = pbLoadRxData("Data/System")
        $MapFactory          = PokemonMapFactory.new($data_system.start_map_id) # calls setMapChanged
        $game_player.moveto($data_system.start_x, $data_system.start_y)
        $game_player.refresh
        $game_map.autoplay
        $game_map.update
        return
      elsif cmdLanguage>=0 && command==cmdLanguage
        @scene.pbEndScene
        $PokemonSystem.language=pbChooseLanguage
        pbLoadMessages("Data/"+LANGUAGES[$PokemonSystem.language][1])
        savedata=[]
        if safeExists?(savefile)
          File.open(savefile,"rb"){|f|
             14.times {    savedata.push(Marshal.load(f)) }
          }
          savedata[3]=$PokemonSystem
          begin
            File.open(RTP.getSaveFileName("Game.rxdata"),"wb"){|f|
               14.times {|i| Marshal.dump(savedata[i],f) }
            }
          rescue; end
        end
        $scene=pbCallTitle
        return
      elsif cmdContinue>=0 && command==cmdContinue
        unless safeExists?(savefile)
          pbPlayBuzzerSE()
          next
        end
        @sprites["overlay"].opacity = 0
        @scene.pbEndScene
        metadata=nil
        File.open(savefile){|f|
           $Trainer             = Marshal.load(f)
           Graphics.frame_count = Marshal.load(f)
           $game_system         = Marshal.load(f)
           Marshal.load(f) # PokemonSystem already loaded
           Marshal.load(f) # Current map id no longer needed
           $game_switches       = Marshal.load(f)
           $game_variables      = Marshal.load(f)
           $game_self_switches  = Marshal.load(f)
           $game_screen         = Marshal.load(f)
           $MapFactory          = Marshal.load(f)
           $game_map            = $MapFactory.map
           $game_player         = Marshal.load(f)
           $PokemonGlobal       = Marshal.load(f)
           metadata             = Marshal.load(f)
           $ItemData            = readItemList("Data/items.dat")
           $PokemonBag          = Marshal.load(f)
           $PokemonStorage      = Marshal.load(f)
           magicNumberMatches=false
           if $data_system.respond_to?("magic_number")
             magicNumberMatches=($game_system.magic_number==$data_system.magic_number)
           else
             magicNumberMatches=($game_system.magic_number==$data_system.version_id)
           end
           if !magicNumberMatches || $PokemonGlobal.safesave
             if pbMapInterpreterRunning?
               pbMapInterpreter.setup(nil,0)
             end
             begin
               $MapFactory.setup($game_map.map_id) # calls setMapChanged
               rescue Errno::ENOENT
               if $DEBUG
                 Kernel.pbMessage(_INTL("Map {1} was not found.",$game_map.map_id))
                 map=pbWarpToMap()
                 if map
                   $MapFactory.setup(map[0])
                   $game_player.moveto(map[1],map[2])
                 else
                   $game_map=nil
                   $scene=nil
                   return
                 end
               else
                 $game_map=nil
                 $scene=nil
                 Kernel.pbMessage(_INTL("The map was not found. The game cannot continue."))
               end
             end
             $game_player.center($game_player.x, $game_player.y)
           else
             $MapFactory.setMapChanged($game_map.map_id)
           end
        }
        if !$game_map.events # Map wasn't set up
          $game_map=nil
          $scene=nil
          Kernel.pbMessage(_INTL("The map is corrupt. The game cannot continue."))
          return
        end
        $PokemonMap=metadata
        $PokemonEncounters=PokemonEncounters.new
        $PokemonEncounters.setup($game_map.map_id)
        pbAutoplayOnSave
        $game_map.update
        $PokemonMap.updateMap
        $scene = Scene_Map.new
        return
      elsif cmdMysteryGift>=0 && command==cmdMysteryGift
        pbFadeOutIn(99999){
           trainer=pbDownloadMysteryGift(trainer)
        }
      elsif cmdOption>=0 && command==cmdOption
        scene=PokemonOptionScene.new
        screen=PokemonOption.new(scene)
        pbFadeOutIn(99999) { screen.pbStartScreen }
      end
    end
    @sprites["overlay"].opacity = 0
    @scene.pbEndScene
    return
  end
end
Replace your code with this one, made it look neat and tidy too...
This was tested with a gift waiting, it will look silly if there isn't one... If you want it to look better, I'll let you figure that out, since all the code is there, you can learn to edit it yourself.

Last edited by Nickalooose; May 23rd, 2013 at 03:43 PM.
Reply With Quote
  #30    
Old May 23rd, 2013, 08:52 PM
ppooookkkkkkk
Banned
 
Join Date: May 2012
Location: Newbud town (Pokemon Morning/Night)
Age: 13
Gender: Male
Nature: Gentle
this doesn't work:
---------------------------
Pokemon Essentials
---------------------------
Exception: NoMethodError
Message: undefined method `>=' for nil:NilClass
PokemonLoad:611:in `pbStartLoadScreen'
PokemonLoad:483:in `loop'
PokemonLoad:620:in `pbStartLoadScreen'
DebugIntro:6:in `main'
Main:37:in `mainFunctionDebug'
Mainin `mainFunction'
Mainin `pbCriticalCode'
Mainin `mainFunction'
Main:47
Main:46:in `loop'

This exception was logged in
C:\Users\Mohammad\Saved Games/Pokemon Essentials/errorlog.txt.
Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK
---------------------------
Reply With Quote
  #31    
Old May 24th, 2013, 08:04 AM
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
What doesn't work?
It works fine for me...



EDIT
at line 387, try putting:
Code:
    cmdMysteryGift=-1

Last edited by Nickalooose; May 24th, 2013 at 08:20 AM.
Reply With Quote
  #32    
Old July 11th, 2013, 09:44 AM
Phaelitico
 
Join Date: Jul 2013
Gender: Male
Quote:
Originally Posted by Nickalooose View Post
I'll go take a look now and see what's up...

EDIT:

If the mystery gift works during the game... Why would you want it to appear on the load screen?
It would seem so far that I can't get mystery gift to appear on the load screen anyway, so I don't think I can help you unless I can get that to work

EDIT:

So I figured out everything.

Actually, there's a error on this code too, whe you select "Continue" it will reload the file before the mystery gift was downloaded. I have done my own editing and it's working fine like this:

Code:
class PokemonLoadScene # :doc:
  def pbUpdate
    pbUpdateSpriteHash(@sprites)
  end

  def pbStartScene
    @sprites={}
    @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
    @viewport.z=99998
    savefile=RTP.getSaveFileName("Game.rxdata")
    
    @sprites["overlay"]=BitmapSprite.new(Graphics.width, Graphics.height)
    @sprites["overlay"].z = 99999
    @overlay=@sprites["overlay"].bitmap
    @overlay.clear
    baseColor=Color.new(239, 239, 239)
    shadowColor=Color.new(140,140,140)
    pbSetSystemFont(@sprites["overlay"].bitmap)
        
    if safeExists?(savefile)      
      @sprites["Continue"] = Sprite.new
      @sprites["Continue"].x = 52
      @sprites["Continue"].y = 4
      @sprites["Continue"].z = 99998
      @sprites["Continue"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Continue")
      @sprites["Continue"].opacity = 210
      
      @sprites["NewGame"] = Sprite.new
      @sprites["NewGame"].x = 68
      @sprites["NewGame"].y = 232
      @sprites["NewGame"].z = 99998
      @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
      @sprites["NewGame"].opacity = 210
      
      @sprites["Options"] = Sprite.new
      @sprites["Options"].x = 68
      @sprites["Options"].y = 282
      @sprites["Options"].z = 99998
      @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
      @sprites["Options"].opacity = 210
      
      @sprites["MysteryGift"] = Sprite.new
      @sprites["MysteryGift"].x = 68
      @sprites["MysteryGift"].y = 332
      @sprites["MysteryGift"].z = 99998
      @sprites["MysteryGift"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
      @sprites["MysteryGift"].opacity = 210
      
      textpos=[
      [_INTL("CONTINUE"),84,10,false,baseColor,shadowColor],
      [_INTL("NEW GAME"),84,238,false,baseColor,shadowColor],
      [_INTL("OPTIONS"),84,288,false,baseColor,shadowColor],
      [_INTL("MYSTERY GIFT"),84,338,false,baseColor,shadowColor],
      #[_INTL(
      ]
      pbDrawTextPositions(@overlay,textpos)
    else
      @sprites["NewGame"] = Sprite.new
      @sprites["NewGame"].x = 68
      @sprites["NewGame"].y = 142
      @sprites["NewGame"].z = 99998
      @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
      @sprites["NewGame"].opacity = 210
      
      @sprites["Options"] = Sprite.new
      @sprites["Options"].x = 68
      @sprites["Options"].y = 192
      @sprites["Options"].z = 99998
      @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
      @sprites["Options"].opacity = 210
      
      textpos=[
      [_INTL("NEW GAME"),84,148,false,baseColor,shadowColor],
      [_INTL("OPTIONS"),84,198,false,baseColor,shadowColor],
      ]
      pbDrawTextPositions(@overlay,textpos)
      
    end
    
    addBackgroundOrColoredPlane(@sprites,"background","loadbg",
       Color.new(96,96,248),@viewport)
    @sprites["locwindow"]=Window_AdvancedTextPokemon.new("")
    @sprites["locwindow"].viewport=@viewport
    @sprites["locwindow"].visible=false
    @sprites["cmdwindow"]=Window_CommandPokemon.new([])
    @sprites["cmdwindow"].x=512
    @sprites["cmdwindow"].y=0
    @sprites["cmdwindow"].viewport=@viewport
    @sprites["cmdwindow"].visible=false
    pbFadeInAndShow(@sprites) { pbUpdate }
  end

  def pbSetAuxiliaryWindow(loctext)
     @sprites["locwindow"].resizeToFit(loctext,Graphics.width-@sprites["cmdwindow"].width)
     @sprites["locwindow"].width=228 if @sprites["locwindow"].width<228
     @sprites["locwindow"].height=Graphics.height
     @sprites["locwindow"].x=512#Graphics.width-@sprites["locwindow"].width
     @sprites["locwindow"].visible=true
     @sprites["locwindow"].text=loctext
  end

  def pbSetParty(trainer,hasPokedex=false)
    for i in 0...trainer.party.length
      @sprites["party#{i}"]=PokemonIconSprite.new(trainer.party[i])
      @sprites["party#{i}"].z=99999
      @sprites["party#{i}"].x=80+60*i
      @sprites["party#{i}"].y=150
    end
  end

  def pbChoose(commands)
    @sprites["cmdwindow"].resizeToFit(commands)
    @sprites["cmdwindow"].commands=commands
    @sprites["cmdwindow"].x=512
    @sprites["cmdwindow"].y=0
    @sprites["cmdwindow"].visible=true
    loop do
      Graphics.update
      Input.update
      pbUpdate
      savefile=RTP.getSaveFileName("Game.rxdata")
      if safeExists?(savefile)
        if @sprites["cmdwindow"].index==0
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["Continue"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Continue_S")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["MysteryGift"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
        elsif @sprites["cmdwindow"].index==1
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar_S")
          @sprites["Continue"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Continue")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["MysteryGift"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
       elsif @sprites["cmdwindow"].index==2
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["Continue"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Continue")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar_S")
          @sprites["MysteryGift"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
       elsif @sprites["cmdwindow"].index==3
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["Continue"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Continue")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["MysteryGift"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar_S")
       end
      else
        if @sprites["cmdwindow"].index==0
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar_S")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
        elsif @sprites["cmdwindow"].index==1
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar_S")
        end
      end
      
      if Input.trigger?(Input::C)
        return @sprites["cmdwindow"].index
      end
    end
  end

  def pbEndScene
    pbFadeOutAndHide(@sprites) { pbUpdate }
    pbDisposeSpriteHash(@sprites)
    @viewport.dispose
  end

  def pbCloseScene
    pbDisposeSpriteHash(@sprites)
    @viewport.dispose
  end
end



module FontInstaller # :doc:
  # filenames of fonts to be installed
  Filenames = [
     'pkmnem.ttf',
     'pkmnemn.ttf',
     'pkmnems.ttf',
     'pkmnrs.ttf',
     'pkmndp.ttf',
     'pkmnfl.ttf'
  ]    
  # names (not filenames) of fonts to be installed
  Names = [
    'Power Green',
    'Power Green Narrow',
    'Power Green Small',
    'Power Red and Blue',
    'Power Clear',
    'Power Red and Green'
  ]
  # whether to notify player (via pop-up message) that fonts were installed
  Notify = true
  # location of fonts (relative to game folder)
  Source = 'Fonts/'

  def self.getFontFolder
    fontfolder=MiniRegistry.get(MiniRegistry::HKEY_CURRENT_USER,
       "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
       "Fonts")
    return fontfolder+"\\" if fontfolder
    if ENV['SystemRoot']
      return ENV['SystemRoot'] + '\\Fonts\\'
    elsif ENV['windir']
      return ENV['windir'] + '\\Fonts\\'
    else
      return '\\Windows\\Fonts\\'
    end   
  end

  AFR = Win32API.new('gdi32', 'AddFontResource', ['P'], 'L')
  WPS = Win32API.new('kernel32', 'WriteProfileString', ['P'] * 3, 'L')
  SM = Win32API.new('user32', 'PostMessage', ['L'] * 4, 'L')
  WM_FONTCHANGE = 0x001D
  HWND_BROADCAST = 0xffff

  def self.copy_file(src,dest)
    File.open(src,  'rb') {|r|
       File.open(dest, 'wb') {|w|
          while s = r.read(4096)
            w.write s
          end
       }
    }
  end

  def self.pbResolveFont(name)
    RTP.eachPathFor(Source+name) {|file|
       return file if safeExists?(file)
    }
    return Source+name
  end

  def self.install
    success = []
    # Check if all fonts already exist
    filesExist=true
    fontsExist=true
    dest=self.getFontFolder()
    for i in 0...Names.size
      if !safeExists?(dest + Filenames[i])
        filesExist=false
      end
      if !Font.exist?(Names[i])
        fontsExist=false
      end
    end
    return if filesExist
    # Check if all source fonts exist
    exist=true
    for i in 0...Names.size
      if !RTP.exists?(Source + Filenames[i])
        exist=false
        break
      end
    end
    return if !exist # Exit if not all source fonts exist
    Kernel.pbMessage(_INTL("One or more fonts used in this game do not exist on the system.\1"))
    Kernel.pbMessage(_INTL("The game can be played, but the look of the game's text will not be optimal.\1"))
    failed=false
    for i in 0...Filenames.size
      f = Filenames[i]
      if safeExists?(dest + f) && !Font.exist?(Names[i])
        File.delete(dest + f) rescue nil
      end
      # check if already installed...
      if not safeExists?(dest + f)
        # check to ensure font is in specified location...
        if RTP.exists?(Source + f)
          # copy file to fonts folder
          succeeded=false
          begin
            copy_file(pbResolveFont(f), dest + f)
            # add font resource
            AFR.call(dest + f)
            # add entry to win.ini/registry
            WPS.call('Fonts', Names[i] + ' (TrueType)', f)
            succeeded=safeExists?(dest + f)
            rescue SystemCallError
            # failed
            succeeded=false
          end
          if succeeded
            success.push(Names[i])
          else
            failed=true
          end
        end
      else
        success.push(Names[i]) # assume success
      end
    end
    if success.length>0 # one or more fonts successfully installed
      SM.call(HWND_BROADCAST,WM_FONTCHANGE,0,0)
      if Notify
        fonts = ''
        success.each do |f|
          fonts << f << ', '
        end
        if failed
          Kernel.pbMessage(_INTL("Some of the fonts were successfully installed.\1"))
          Kernel.pbMessage(_INTL("To install the other fonts, copy the files in this game's Fonts folder to the Fonts folder in Control Panel."))
        else
          Kernel.pbMessage(_INTL("The fonts were successfully installed.\1"))
        end
        if Kernel.pbConfirmMessage(_INTL("Would you like to restart the game and apply the changes?"))
          a = Thread.new { system('Game') }
          exit
        end
      end
    else
      # No fonts were installed.
      Kernel.pbMessage(_INTL("To install the necessary fonts, copy the files in this game's Fonts folder to the Fonts folder in Control Panel."))
    end
  end
end



class PokemonLoad
  def initialize(scene)
    @scene=scene
  end

  def pbDisplay(text,brief=false)
    @scene.pbDisplay(text,brief)
  end

  def pbDisplayPaused(text)
    @scene.pbDisplayPaused(text)
  end

  def pbConfirm(text)
    return @scene.pbConfirm(text)
  end

  def pbTryLoadFile(savefile)
    trainer=nil
    framecount=nil
    game_system=nil
    pokemonSystem=nil
    mapid=nil
    File.open(savefile){|f|
       trainer=Marshal.load(f)
       framecount=Marshal.load(f)
       game_system=Marshal.load(f)
       pokemonSystem=Marshal.load(f)
       mapid=Marshal.load(f)
    }
    raise "Corrupted file" if !trainer.is_a?(PokeBattle_Trainer)
    raise "Corrupted file" if !framecount.is_a?(Numeric)
    raise "Corrupted file" if !game_system.is_a?(Game_System)
    raise "Corrupted file" if !pokemonSystem.is_a?(PokemonSystem)
    raise "Corrupted file" if !mapid.is_a?(Numeric)
    return [trainer,framecount,game_system,pokemonSystem,mapid]
  end

  def pbStartDeleteScreen
    savefile=RTP.getSaveFileName("Game.rxdata")
    @scene.pbStartScene
    if safeExists?(savefile)
      if Kernel.pbConfirmMessageSerious(_INTL("Delete all saved data?"))
        Kernel.pbMessage(_INTL("Once data has been deleted, there is no way to recover it.\1"))
        if Kernel.pbConfirmMessageSerious(_INTL("Delete the saved data anyway?"))
          Kernel.pbMessage(_INTL("Deleting all data.\r\nDon't turn off the power.\\wtnp[0]"))
          begin; File.delete(savefile); rescue; end
          begin; File.delete(savefile+".bak"); rescue; end
          Kernel.pbMessage(_INTL("The save file was deleted."))
        end
      end
    else
      Kernel.pbMessage(_INTL("No save file was found."))
    end
    @scene.pbEndScene
    $scene=pbCallTitle
  end

  def pbStartLoadScreen
    $PokemonTemp   = PokemonTemp.new
    $game_temp     = Game_Temp.new
    $game_system   = Game_System.new
    $PokemonSystem = PokemonSystem.new if !$PokemonSystem
    @scene.pbStartScene
    cmdContinue=-1
    cmdNewGame=0
    cmdOption=1
    cmdLanguage=-1
    cmdMysteryGift=-1
    commands=[]
    savefile=RTP.getSaveFileName("Game.rxdata")
    FontInstaller.install
    data_system = pbLoadRxData("Data/System")
    mapfile=$RPGVX ? sprintf("Data/Map%03d.rvdata",data_system.start_map_id) :
                     sprintf("Data/Map%03d.rxdata",data_system.start_map_id)
    if data_system.start_map_id==0 || !pbRgssExists?(mapfile)
      Kernel.pbMessage(_INTL("No starting position was set in the map editor.\1"))
      Kernel.pbMessage(_INTL("The game cannot continue."))
      @scene.pbEndScene
      $scene=nil
      return
    end
    if safeExists?(savefile)
      trainer=nil
      framecount=0
      showContinue=false
      haveBackup=false
      begin
        trainer, framecount, $game_system, $PokemonSystem, mapid=pbTryLoadFile(savefile)
        showContinue=true
        rescue
        if safeExists?(savefile+".bak")
          begin
            trainer, framecount, $game_system, $PokemonSystem, mapid=pbTryLoadFile(savefile+".bak")
            haveBackup=true
            showContinue=true
            rescue
          end
        end
        if haveBackup
          Kernel.pbMessage(_INTL("The save file is corrupt.  The previous save file will be loaded."))
        else
          Kernel.pbMessage(_INTL("The save file is corrupt, or is incompatible with this game."))
          if !Kernel.pbConfirmMessageSerious(_INTL("Do you want to delete the save file and start anew?"))
            raise "scss error - Corrupted or incompatible save file."
          end
          begin; File.delete(savefile); rescue; end
          begin; File.delete(savefile+".bak"); rescue; end
          $PokemonSystem=PokemonSystem.new if !$PokemonSystem
          $game_system=Game_System.new
          Kernel.pbMessage(_INTL("The save file was deleted."))
        end
      end
      if showContinue
        if !haveBackup
          begin; File.delete(savefile+".bak"); rescue; end
          end
        totalsec = framecount / Graphics.frame_rate
        hour = totalsec / 60 / 60
        min = totalsec / 60 % 60
        mapname=pbGetMapNameFromId(mapid)
        mapname.gsub!(/\\PN/,trainer.name)
        textColor=["0070F8,78B8E8","E82010,F8A8B8","0070F8,78B8E8"][trainer.gender]
        loctext=_INTL("<ac><c2=06644bd2>{1}</c2></ac>",mapname)
        loctext+=_INTL("Player<r><c3={1}>{2}</c3><br>",textColor,fmtescape(trainer.name))
        loctext+=_ISPRINTF("Time<r><c3={1:s}>{2:02d}:{3:02d}</c3><br>",textColor,hour,min)
        loctext+=_INTL("Badges<r><c3={1}>{2}</c3><br>",textColor,trainer.numbadges)
        if trainer.pokedex
          loctext+=_INTL("Pokédex<r><c3={1}>{2}/{3}</c3><br>",textColor,trainer.pokedexOwned,trainer.pokedexSeen)
        end
        
        @sprites={}
        @sprites["overlay"]=BitmapSprite.new(Graphics.width, Graphics.height)
        @sprites["overlay"].z = 99999
        @overlay=@sprites["overlay"].bitmap
        @overlay.clear
        baseColor=Color.new(239, 239, 239)
        shadowColor=Color.new(140,140,140)
        pbSetSystemFont(@sprites["overlay"].bitmap)
    
        textpos=[
        [_INTL("{1}",trainer.name),84,60,false,Color.new(57,165,255),Color.new(57,107,173)],
        [_INTL("{1}",mapname),84,90,false,baseColor,shadowColor],
        [_INTL("Badges: {1}",trainer.numbadges),84,135,false,baseColor,shadowColor],
        [_ISPRINTF("Time: {1:02d}:{2:02d}",hour,min),220,135,false,baseColor,shadowColor],
        ]
        pbDrawTextPositions(@overlay,textpos)
          
        loctext+=_INTL("Party") if trainer.party.length>0
        @scene.pbSetAuxiliaryWindow(loctext)
        @scene.pbSetParty(trainer,trainer.pokedex)
      end
      commands[cmdContinue=commands.length]=_INTL("Continue") if showContinue
      commands[cmdNewGame=commands.length]=_INTL("New Game")
      commands[cmdOption=commands.length]=_INTL("Options")
      commands[cmdMysteryGift=commands.length]=_INTL("Mystery Gift") if (trainer.mysterygiftaccess rescue false)
    else
      commands[cmdNewGame=commands.length]=_INTL("New Game")
      commands[cmdOption=commands.length]=_INTL("Options")
    end
    if LANGUAGES.length>=2
      commands[cmdLanguage=commands.length]=_INTL("Language")
    end
    
    loop do
      command=@scene.pbChoose(commands)
      if cmdNewGame>=0 && command==cmdNewGame
        savefile=RTP.getSaveFileName("Game.rxdata")
        if safeExists?(savefile)
          @sprites["overlay"].opacity = 0
        end
        @scene.pbEndScene
        if $game_map && $game_map.events
          for event in $game_map.events.values
            event.clear_starting
          end
        end
        $game_temp.common_event_id=0 if $game_temp
        $scene               = Scene_Map.new
        Graphics.frame_count = 0
        $game_system         = Game_System.new
        $game_switches       = Game_Switches.new
        $game_variables      = Game_Variables.new
        $game_self_switches  = Game_SelfSwitches.new
        $game_screen         = Game_Screen.new
        $game_player         = Game_Player.new
        $ItemData            = readItemList("Data/items.dat")
        $PokemonMap          = PokemonMapMetadata.new
        $PokemonGlobal       = PokemonGlobalMetadata.new
        $PokemonStorage      = PokemonStorage.new
        $PokemonEncounters   = PokemonEncounters.new
        $PokemonTemp.begunNewGame=true
        $data_system         = pbLoadRxData("Data/System")
        $MapFactory          = PokemonMapFactory.new($data_system.start_map_id) # calls setMapChanged
        $game_player.moveto($data_system.start_x, $data_system.start_y)
        $game_player.refresh
        $game_map.autoplay
        $game_map.update
        return
      elsif cmdLanguage>=0 && command==cmdLanguage
        @scene.pbEndScene
        $PokemonSystem.language=pbChooseLanguage
        pbLoadMessages("Data/"+LANGUAGES[$PokemonSystem.language][1])
        savedata=[]
        if safeExists?(savefile)
          File.open(savefile,"rb"){|f|
             14.times {    savedata.push(Marshal.load(f)) }
          }
          savedata[3]=$PokemonSystem
          begin
            File.open(RTP.getSaveFileName("Game.rxdata"),"wb"){|f|
               14.times {|i| Marshal.dump(savedata[i],f) }
            }
          rescue; end
        end
        $scene=pbCallTitle
        return
      elsif cmdContinue>=0 && command==cmdContinue
        unless safeExists?(savefile)
          pbPlayBuzzerSE()
          next
        end
        @sprites["overlay"].opacity = 0
        @scene.pbEndScene
        metadata=nil
        File.open(savefile){|f|
           Marshal.load(f) # Trainer already loaded
           $Trainer             = trainer
           Graphics.frame_count = Marshal.load(f)
           $game_system         = Marshal.load(f)
           Marshal.load(f) # PokemonSystem already loaded
           Marshal.load(f) # Current map id no longer needed
           $game_switches       = Marshal.load(f)
           $game_variables      = Marshal.load(f)
           $game_self_switches  = Marshal.load(f)
           $game_screen         = Marshal.load(f)
           $MapFactory          = Marshal.load(f)
           $game_map            = $MapFactory.map
           $game_player         = Marshal.load(f)
           $PokemonGlobal       = Marshal.load(f)
           metadata             = Marshal.load(f)
           $ItemData            = readItemList("Data/items.dat")
           $PokemonBag          = Marshal.load(f)
           $PokemonStorage      = Marshal.load(f)
           magicNumberMatches=false
           if $data_system.respond_to?("magic_number")
             magicNumberMatches=($game_system.magic_number==$data_system.magic_number)
           else
             magicNumberMatches=($game_system.magic_number==$data_system.version_id)
           end
           if !magicNumberMatches || $PokemonGlobal.safesave
             if pbMapInterpreterRunning?
               pbMapInterpreter.setup(nil,0)
             end
             begin
               $MapFactory.setup($game_map.map_id) # calls setMapChanged
               rescue Errno::ENOENT
               if $DEBUG
                 Kernel.pbMessage(_INTL("Map {1} was not found.",$game_map.map_id))
                 map=pbWarpToMap()
                 if map
                   $MapFactory.setup(map[0])
                   $game_player.moveto(map[1],map[2])
                 else
                   $game_map=nil
                   $scene=nil
                   return
                 end
               else
                 $game_map=nil
                 $scene=nil
                 Kernel.pbMessage(_INTL("The map was not found. The game cannot continue."))
               end
             end
             $game_player.center($game_player.x, $game_player.y)
           else
             $MapFactory.setMapChanged($game_map.map_id)
           end
        }
        if !$game_map.events # Map wasn't set up
          $game_map=nil
          $scene=nil
          Kernel.pbMessage(_INTL("The map is corrupt. The game cannot continue."))
          return
        end
        $PokemonMap=metadata
        $PokemonEncounters=PokemonEncounters.new
        $PokemonEncounters.setup($game_map.map_id)
        pbAutoplayOnSave
        $game_map.update
        $PokemonMap.updateMap
        $scene = Scene_Map.new
        return
      elsif cmdOption>=0 && command==cmdOption
        scene=PokemonOptionScene.new
        screen=PokemonOption.new(scene)
        pbFadeOutIn(99999) { screen.pbStartScreen }
      elsif cmdMysteryGift>=0 && command==cmdMysteryGift
       pbFadeOutIn(99999){
           trainer=pbDownloadMysteryGift(trainer)
        }
      end
    end
    @sprites["overlay"].opacity = 0
    @scene.pbEndScene
    return
  end
end
See that in the Continue part you "Reloaded" the $Trainer from the file?

basically you change this:
Code:
           $Trainer             = Marshal.load(f)
to this:
Code:
           Marshal.load(f) # Trainer already loaded
           $Trainer             = trainer
It's 100% Working, the only "issue" know is that every save file will have the "Mystery Gift" on the Menu regardless the access.

PS: Sorry about bad english and stuff
Reply With Quote
  #33    
Old July 12th, 2013, 06:27 AM
lauerolus's Avatar
lauerolus
 
Join Date: Mar 2013
Gender: Male
Thank you for this, definitely using and crediting you for it.
Reply With Quote
  #34    
Old July 12th, 2013, 01:42 PM
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
There were more errors in my code, it was a quick mock up.
Anyway... You're having the problem because the load is reading:
New Game
Options

as one set of commands, and once a save is made
Continue
New Game
Options
Mystery Gift

as another set of commands... There is no in betweeny.
Unfortunately there is no tidy fix for this except doing it this way.
Code:
class PokemonLoadScene # :doc:
  def pbUpdate
    pbUpdateSpriteHash(@sprites)
  end

  def pbStartScene
    @sprites={}
    @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
    @viewport.z=99998
    savefile=RTP.getSaveFileName("Game.rxdata")
    
    @sprites["overlay"]=BitmapSprite.new(Graphics.width, Graphics.height)
    @sprites["overlay"].z = 99999
    @overlay=@sprites["overlay"].bitmap
    @overlay.clear
    baseColor=Color.new(239, 239, 239)
    shadowColor=Color.new(140,140,140)
    pbSetSystemFont(@sprites["overlay"].bitmap)
        
    if safeExists?(savefile)      
      @sprites["Continue"] = Sprite.new
      @sprites["Continue"].x = 52
      @sprites["Continue"].y = 4
      @sprites["Continue"].z = 99998
      @sprites["Continue"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Continue")
      @sprites["Continue"].opacity = 210
      
      @sprites["NewGame"] = Sprite.new
      @sprites["NewGame"].x = 68
      @sprites["NewGame"].y = 232
      @sprites["NewGame"].z = 99998
      @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
      @sprites["NewGame"].opacity = 210
      
      @sprites["Options"] = Sprite.new
      @sprites["Options"].x = 68
      @sprites["Options"].y = 282
      @sprites["Options"].z = 99998
      @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
      @sprites["Options"].opacity = 210
    if (trainer.mysterygiftaccess rescue false)
      @sprites["MysteryGift"] = Sprite.new
      @sprites["MysteryGift"].x = 68
      @sprites["MysteryGift"].y = 332
      @sprites["MysteryGift"].z = 99998
      @sprites["MysteryGift"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
      @sprites["MysteryGift"].opacity = 210    
      textpos=[
      [_INTL("CONTINUE"),84,10,false,baseColor,shadowColor],
      [_INTL("NEW GAME"),84,238,false,baseColor,shadowColor],
      [_INTL("OPTIONS"),84,288,false,baseColor,shadowColor],
      [_INTL("MYSTERY GIFT"),84,338,false,baseColor,shadowColor],
      #[_INTL(
      ]
      pbDrawTextPositions(@overlay,textpos)
    else   
      textpos=[
      [_INTL("CONTINUE"),84,10,false,baseColor,shadowColor],
      [_INTL("NEW GAME"),84,238,false,baseColor,shadowColor],
      [_INTL("OPTIONS"),84,288,false,baseColor,shadowColor],
      ]
      pbDrawTextPositions(@overlay,textpos)
    end  
    else
      @sprites["NewGame"] = Sprite.new
      @sprites["NewGame"].x = 68
      @sprites["NewGame"].y = 142
      @sprites["NewGame"].z = 99998
      @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
      @sprites["NewGame"].opacity = 210
      
      @sprites["Options"] = Sprite.new
      @sprites["Options"].x = 68
      @sprites["Options"].y = 192
      @sprites["Options"].z = 99998
      @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
      @sprites["Options"].opacity = 210
      
      textpos=[
      [_INTL("NEW GAME"),84,148,false,baseColor,shadowColor],
      [_INTL("OPTIONS"),84,198,false,baseColor,shadowColor],
      ]
      pbDrawTextPositions(@overlay,textpos)
      
    end
    
    addBackgroundOrColoredPlane(@sprites,"background","loadbg",
       Color.new(96,96,248),@viewport)
    @sprites["locwindow"]=Window_AdvancedTextPokemon.new("")
    @sprites["locwindow"].viewport=@viewport
    @sprites["locwindow"].visible=false
    @sprites["cmdwindow"]=Window_CommandPokemon.new([])
    @sprites["cmdwindow"].x=512
    @sprites["cmdwindow"].y=0
    @sprites["cmdwindow"].viewport=@viewport
    @sprites["cmdwindow"].visible=false
    pbFadeInAndShow(@sprites) { pbUpdate }
  end

  def pbSetAuxiliaryWindow(loctext)
     @sprites["locwindow"].resizeToFit(loctext,Graphics.width-@sprites["cmdwindow"].width)
     @sprites["locwindow"].width=228 if @sprites["locwindow"].width<228
     @sprites["locwindow"].height=Graphics.height
     @sprites["locwindow"].x=512#Graphics.width-@sprites["locwindow"].width
     @sprites["locwindow"].visible=true
     @sprites["locwindow"].text=loctext
  end

  def pbSetParty(trainer,hasPokedex=false)
    for i in 0...trainer.party.length
      @sprites["party#{i}"]=PokemonIconSprite.new(trainer.party[i])
      @sprites["party#{i}"].z=99999
      @sprites["party#{i}"].x=80+60*i
      @sprites["party#{i}"].y=150
    end
  end

  def pbChoose(commands)
    @sprites["cmdwindow"].resizeToFit(commands)
    @sprites["cmdwindow"].commands=commands
    @sprites["cmdwindow"].x=512
    @sprites["cmdwindow"].y=0
    @sprites["cmdwindow"].visible=true
    loop do
      Graphics.update
      Input.update
      pbUpdate
      savefile=RTP.getSaveFileName("Game.rxdata")
      if safeExists?(savefile)
        if @sprites["cmdwindow"].index==0
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["Continue"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Continue_S")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["MysteryGift"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar") if (trainer.mysterygiftaccess rescue false)
        elsif @sprites["cmdwindow"].index==1
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar_S")
          @sprites["Continue"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Continue")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["MysteryGift"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar") if (trainer.mysterygiftaccess rescue false)
       elsif @sprites["cmdwindow"].index==2
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["Continue"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Continue")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar_S")
          @sprites["MysteryGift"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar") if (trainer.mysterygiftaccess rescue false)
       elsif @sprites["cmdwindow"].index==3 && (trainer.mysterygiftaccess rescue false)
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["Continue"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Continue")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["MysteryGift"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar_S") if (trainer.mysterygiftaccess rescue false)
       end
      else
        if @sprites["cmdwindow"].index==0
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar_S")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
        elsif @sprites["cmdwindow"].index==1
          @sprites["NewGame"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar")
          @sprites["Options"].bitmap = BitmapCache.load_bitmap("Graphics/Pictures/Bar_S")
        end
      end
      
      if Input.trigger?(Input::C)
        return @sprites["cmdwindow"].index
      end
    end
  end

  def pbEndScene
    pbFadeOutAndHide(@sprites) { pbUpdate }
    pbDisposeSpriteHash(@sprites)
    @viewport.dispose
  end

  def pbCloseScene
    pbDisposeSpriteHash(@sprites)
    @viewport.dispose
  end
end



module FontInstaller # :doc:
  # filenames of fonts to be installed
  Filenames = [
     'pkmnem.ttf',
     'pkmnemn.ttf',
     'pkmnems.ttf',
     'pkmnrs.ttf',
     'pkmndp.ttf',
     'pkmnfl.ttf'
  ]    
  # names (not filenames) of fonts to be installed
  Names = [
    'Power Green',
    'Power Green Narrow',
    'Power Green Small',
    'Power Red and Blue',
    'Power Clear',
    'Power Red and Green'
  ]
  # whether to notify player (via pop-up message) that fonts were installed
  Notify = true
  # location of fonts (relative to game folder)
  Source = 'Fonts/'

  def self.getFontFolder
    fontfolder=MiniRegistry.get(MiniRegistry::HKEY_CURRENT_USER,
       "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
       "Fonts")
    return fontfolder+"\\" if fontfolder
    if ENV['SystemRoot']
      return ENV['SystemRoot'] + '\\Fonts\\'
    elsif ENV['windir']
      return ENV['windir'] + '\\Fonts\\'
    else
      return '\\Windows\\Fonts\\'
    end   
  end

  AFR = Win32API.new('gdi32', 'AddFontResource', ['P'], 'L')
  WPS = Win32API.new('kernel32', 'WriteProfileString', ['P'] * 3, 'L')
  SM = Win32API.new('user32', 'PostMessage', ['L'] * 4, 'L')
  WM_FONTCHANGE = 0x001D
  HWND_BROADCAST = 0xffff

  def self.copy_file(src,dest)
    File.open(src,  'rb') {|r|
       File.open(dest, 'wb') {|w|
          while s = r.read(4096)
            w.write s
          end
       }
    }
  end

  def self.pbResolveFont(name)
    RTP.eachPathFor(Source+name) {|file|
       return file if safeExists?(file)
    }
    return Source+name
  end

  def self.install
    success = []
    # Check if all fonts already exist
    filesExist=true
    fontsExist=true
    dest=self.getFontFolder()
    for i in 0...Names.size
      if !safeExists?(dest + Filenames[i])
        filesExist=false
      end
      if !Font.exist?(Names[i])
        fontsExist=false
      end
    end
    return if filesExist
    # Check if all source fonts exist
    exist=true
    for i in 0...Names.size
      if !RTP.exists?(Source + Filenames[i])
        exist=false
        break
      end
    end
    return if !exist # Exit if not all source fonts exist
    Kernel.pbMessage(_INTL("One or more fonts used in this game do not exist on the system.\1"))
    Kernel.pbMessage(_INTL("The game can be played, but the look of the game's text will not be optimal.\1"))
    failed=false
    for i in 0...Filenames.size
      f = Filenames[i]
      if safeExists?(dest + f) && !Font.exist?(Names[i])
        File.delete(dest + f) rescue nil
      end
      # check if already installed...
      if not safeExists?(dest + f)
        # check to ensure font is in specified location...
        if RTP.exists?(Source + f)
          # copy file to fonts folder
          succeeded=false
          begin
            copy_file(pbResolveFont(f), dest + f)
            # add font resource
            AFR.call(dest + f)
            # add entry to win.ini/registry
            WPS.call('Fonts', Names[i] + ' (TrueType)', f)
            succeeded=safeExists?(dest + f)
            rescue SystemCallError
            # failed
            succeeded=false
          end
          if succeeded
            success.push(Names[i])
          else
            failed=true
          end
        end
      else
        success.push(Names[i]) # assume success
      end
    end
    if success.length>0 # one or more fonts successfully installed
      SM.call(HWND_BROADCAST,WM_FONTCHANGE,0,0)
      if Notify
        fonts = ''
        success.each do |f|
          fonts << f << ', '
        end
        if failed
          Kernel.pbMessage(_INTL("Some of the fonts were successfully installed.\1"))
          Kernel.pbMessage(_INTL("To install the other fonts, copy the files in this game's Fonts folder to the Fonts folder in Control Panel."))
        else
          Kernel.pbMessage(_INTL("The fonts were successfully installed.\1"))
        end
        if Kernel.pbConfirmMessage(_INTL("Would you like to restart the game and apply the changes?"))
          a = Thread.new { system('Game') }
          exit
        end
      end
    else
      # No fonts were installed.
      Kernel.pbMessage(_INTL("To install the necessary fonts, copy the files in this game's Fonts folder to the Fonts folder in Control Panel."))
    end
  end
end



class PokemonLoad
  def initialize(scene)
    @scene=scene
  end

  def pbDisplay(text,brief=false)
    @scene.pbDisplay(text,brief)
  end

  def pbDisplayPaused(text)
    @scene.pbDisplayPaused(text)
  end

  def pbConfirm(text)
    return @scene.pbConfirm(text)
  end

  def pbTryLoadFile(savefile)
    trainer=nil
    framecount=nil
    game_system=nil
    pokemonSystem=nil
    mapid=nil
    File.open(savefile){|f|
       trainer=Marshal.load(f)
       framecount=Marshal.load(f)
       game_system=Marshal.load(f)
       pokemonSystem=Marshal.load(f)
       mapid=Marshal.load(f)
    }
    raise "Corrupted file" if !trainer.is_a?(PokeBattle_Trainer)
    raise "Corrupted file" if !framecount.is_a?(Numeric)
    raise "Corrupted file" if !game_system.is_a?(Game_System)
    raise "Corrupted file" if !pokemonSystem.is_a?(PokemonSystem)
    raise "Corrupted file" if !mapid.is_a?(Numeric)
    return [trainer,framecount,game_system,pokemonSystem,mapid]
  end

  def pbStartDeleteScreen
    savefile=RTP.getSaveFileName("Game.rxdata")
    @scene.pbStartScene
    if safeExists?(savefile)
      if Kernel.pbConfirmMessageSerious(_INTL("Delete all saved data?"))
        Kernel.pbMessage(_INTL("Once data has been deleted, there is no way to recover it.\1"))
        if Kernel.pbConfirmMessageSerious(_INTL("Delete the saved data anyway?"))
          Kernel.pbMessage(_INTL("Deleting all data.\r\nDon't turn off the power.\\wtnp[0]"))
          begin; File.delete(savefile); rescue; end
          begin; File.delete(savefile+".bak"); rescue; end
          Kernel.pbMessage(_INTL("The save file was deleted."))
        end
      end
    else
      Kernel.pbMessage(_INTL("No save file was found."))
    end
    @scene.pbEndScene
    $scene=pbCallTitle
  end

  def pbStartLoadScreen
    $PokemonTemp   = PokemonTemp.new
    $game_temp     = Game_Temp.new
    $game_system   = Game_System.new
    $PokemonSystem = PokemonSystem.new if !$PokemonSystem
    @scene.pbStartScene
    cmdContinue=-1
    cmdNewGame=0
    cmdOption=1
    cmdLanguage=-1
#    cmdMysteryGift=-1
    commands=[]
    savefile=RTP.getSaveFileName("Game.rxdata")
    FontInstaller.install
    data_system = pbLoadRxData("Data/System")
    mapfile=$RPGVX ? sprintf("Data/Map%03d.rvdata",data_system.start_map_id) :
                     sprintf("Data/Map%03d.rxdata",data_system.start_map_id)
    if data_system.start_map_id==0 || !pbRgssExists?(mapfile)
      Kernel.pbMessage(_INTL("No starting position was set in the map editor.\1"))
      Kernel.pbMessage(_INTL("The game cannot continue."))
      @scene.pbEndScene
      $scene=nil
      return
    end
    if safeExists?(savefile)
      trainer=nil
      framecount=0
      showContinue=false
      haveBackup=false
      begin
        trainer, framecount, $game_system, $PokemonSystem, mapid=pbTryLoadFile(savefile)
        showContinue=true
        rescue
        if safeExists?(savefile+".bak")
          begin
            trainer, framecount, $game_system, $PokemonSystem, mapid=pbTryLoadFile(savefile+".bak")
            haveBackup=true
            showContinue=true
            rescue
          end
        end
        if haveBackup
          Kernel.pbMessage(_INTL("The save file is corrupt.  The previous save file will be loaded."))
        else
          Kernel.pbMessage(_INTL("The save file is corrupt, or is incompatible with this game."))
          if !Kernel.pbConfirmMessageSerious(_INTL("Do you want to delete the save file and start anew?"))
            raise "scss error - Corrupted or incompatible save file."
          end
          begin; File.delete(savefile); rescue; end
          begin; File.delete(savefile+".bak"); rescue; end
          $PokemonSystem=PokemonSystem.new if !$PokemonSystem
          $game_system=Game_System.new
          Kernel.pbMessage(_INTL("The save file was deleted."))
        end
      end
      if showContinue
        if !haveBackup
          begin; File.delete(savefile+".bak"); rescue; end
          end
        totalsec = framecount / Graphics.frame_rate
        hour = totalsec / 60 / 60
        min = totalsec / 60 % 60
        mapname=pbGetMapNameFromId(mapid)
        mapname.gsub!(/\\PN/,trainer.name)
        textColor=["0070F8,78B8E8","E82010,F8A8B8","0070F8,78B8E8"][trainer.gender]
        loctext=_INTL("<ac><c2=06644bd2>{1}</c2></ac>",mapname)
        loctext+=_INTL("Player<r><c3={1}>{2}</c3><br>",textColor,fmtescape(trainer.name))
        loctext+=_ISPRINTF("Time<r><c3={1:s}>{2:02d}:{3:02d}</c3><br>",textColor,hour,min)
        loctext+=_INTL("Badges<r><c3={1}>{2}</c3><br>",textColor,trainer.numbadges)
        if trainer.pokedex
          loctext+=_INTL("Pokédex<r><c3={1}>{2}/{3}</c3><br>",textColor,trainer.pokedexOwned,trainer.pokedexSeen)
        end
        
        @sprites={}
        @sprites["overlay"]=BitmapSprite.new(Graphics.width, Graphics.height)
        @sprites["overlay"].z = 99999
        @overlay=@sprites["overlay"].bitmap
        @overlay.clear
        baseColor=Color.new(239, 239, 239)
        shadowColor=Color.new(140,140,140)
        pbSetSystemFont(@sprites["overlay"].bitmap)
    
        textpos=[
        [_INTL("{1}",trainer.name),84,60,false,Color.new(57,165,255),Color.new(57,107,173)],
        [_INTL("{1}",mapname),84,90,false,baseColor,shadowColor],
        [_INTL("Badges: {1}",trainer.numbadges),84,135,false,baseColor,shadowColor],
        [_ISPRINTF("Time: {1:02d}:{2:02d}",hour,min),220,135,false,baseColor,shadowColor],
        ]
        pbDrawTextPositions(@overlay,textpos)
          
        loctext+=_INTL("Party") if trainer.party.length>0
        @scene.pbSetAuxiliaryWindow(loctext)
        @scene.pbSetParty(trainer,trainer.pokedex)
      end
      commands[cmdContinue=commands.length]=_INTL("Continue") if showContinue
      commands[cmdNewGame=commands.length]=_INTL("New Game")
      commands[cmdOption=commands.length]=_INTL("Options")
      commands[cmdMysteryGift=commands.length]=_INTL("Mystery Gift") if (trainer.mysterygiftaccess rescue false)
    else
      commands[cmdNewGame=commands.length]=_INTL("New Game")
      commands[cmdOption=commands.length]=_INTL("Options")
    end
    if LANGUAGES.length>=2
      commands[cmdLanguage=commands.length]=_INTL("Language")
    end
    loop do
      command=@scene.pbChoose(commands)
      if cmdNewGame>=0 && command==cmdNewGame
        savefile=RTP.getSaveFileName("Game.rxdata")
        if safeExists?(savefile)
          @sprites["overlay"].opacity = 0
        end
        @scene.pbEndScene
        if $game_map && $game_map.events
          for event in $game_map.events.values
            event.clear_starting
          end
        end
        $game_temp.common_event_id=0 if $game_temp
        $scene               = Scene_Map.new
        Graphics.frame_count = 0
        $game_system         = Game_System.new
        $game_switches       = Game_Switches.new
        $game_variables      = Game_Variables.new
        $game_self_switches  = Game_SelfSwitches.new
        $game_screen         = Game_Screen.new
        $game_player         = Game_Player.new
        $ItemData            = readItemList("Data/items.dat")
        $PokemonMap          = PokemonMapMetadata.new
        $PokemonGlobal       = PokemonGlobalMetadata.new
        $PokemonStorage      = PokemonStorage.new
        $PokemonEncounters   = PokemonEncounters.new
        $PokemonTemp.begunNewGame=true
        $data_system         = pbLoadRxData("Data/System")
        $MapFactory          = PokemonMapFactory.new($data_system.start_map_id) # calls setMapChanged
        $game_player.moveto($data_system.start_x, $data_system.start_y)
        $game_player.refresh
        $game_map.autoplay
        $game_map.update
        return
      elsif cmdLanguage>=0 && command==cmdLanguage
        @scene.pbEndScene
        $PokemonSystem.language=pbChooseLanguage
        pbLoadMessages("Data/"+LANGUAGES[$PokemonSystem.language][1])
        savedata=[]
        if safeExists?(savefile)
          File.open(savefile,"rb"){|f|
             14.times {    savedata.push(Marshal.load(f)) }
          }
          savedata[3]=$PokemonSystem
          begin
            File.open(RTP.getSaveFileName("Game.rxdata"),"wb"){|f|
               14.times {|i| Marshal.dump(savedata[i],f) }
            }
          rescue; end
        end
        $scene=pbCallTitle
        return
      elsif cmdContinue>=0 && command==cmdContinue
        unless safeExists?(savefile)
          pbPlayBuzzerSE()
          next
        end
        @sprites["overlay"].opacity = 0
        @scene.pbEndScene
        metadata=nil
        File.open(savefile){|f|
           Marshal.load(f) # Trainer already loaded
           $Trainer             = trainer
           Graphics.frame_count = Marshal.load(f)
           $game_system         = Marshal.load(f)
           Marshal.load(f) # PokemonSystem already loaded
           Marshal.load(f) # Current map id no longer needed
           $game_switches       = Marshal.load(f)
           $game_variables      = Marshal.load(f)
           $game_self_switches  = Marshal.load(f)
           $game_screen         = Marshal.load(f)
           $MapFactory          = Marshal.load(f)
           $game_map            = $MapFactory.map
           $game_player         = Marshal.load(f)
           $PokemonGlobal       = Marshal.load(f)
           metadata             = Marshal.load(f)
           $ItemData            = readItemList("Data/items.dat")
           $PokemonBag          = Marshal.load(f)
           $PokemonStorage      = Marshal.load(f)
           magicNumberMatches=false
           if $data_system.respond_to?("magic_number")
             magicNumberMatches=($game_system.magic_number==$data_system.magic_number)
           else
             magicNumberMatches=($game_system.magic_number==$data_system.version_id)
           end
           if !magicNumberMatches || $PokemonGlobal.safesave
             if pbMapInterpreterRunning?
               pbMapInterpreter.setup(nil,0)
             end
             begin
               $MapFactory.setup($game_map.map_id) # calls setMapChanged
               rescue Errno::ENOENT
               if $DEBUG
                 Kernel.pbMessage(_INTL("Map {1} was not found.",$game_map.map_id))
                 map=pbWarpToMap()
                 if map
                   $MapFactory.setup(map[0])
                   $game_player.moveto(map[1],map[2])
                 else
                   $game_map=nil
                   $scene=nil
                   return
                 end
               else
                 $game_map=nil
                 $scene=nil
                 Kernel.pbMessage(_INTL("The map was not found. The game cannot continue."))
               end
             end
             $game_player.center($game_player.x, $game_player.y)
           else
             $MapFactory.setMapChanged($game_map.map_id)
           end
        }
        if !$game_map.events # Map wasn't set up
          $game_map=nil
          $scene=nil
          Kernel.pbMessage(_INTL("The map is corrupt. The game cannot continue."))
          return
        end
        $PokemonMap=metadata
        $PokemonEncounters=PokemonEncounters.new
        $PokemonEncounters.setup($game_map.map_id)
        pbAutoplayOnSave
        $game_map.update
        $PokemonMap.updateMap
        $scene = Scene_Map.new
        return
      elsif cmdOption>=0 && command==cmdOption
        scene=PokemonOptionScene.new
        screen=PokemonOption.new(scene)
        pbFadeOutIn(99999) { screen.pbStartScreen }
      elsif cmdMysteryGift>=0 && command==cmdMysteryGift
       pbFadeOutIn(99999){
           trainer=pbDownloadMysteryGift(trainer)
        }
      end
    end
    @sprites["overlay"].opacity = 0
    @scene.pbEndScene
    return
  end
end
That's the problem with defining windows and such, directly, not when it's needed.
This will fix your problem, Phaelitico... As long as you don't look at the code, it does what is needed and can be considered neat and tidy (even though it's ugly and a mess).
Reply With Quote
  #35    
Old July 16th, 2013, 11:18 AM
mewlover22's Avatar
mewlover22
Pokemon Creator
 
Join Date: Oct 2008
Gender: Male
Nature: Quiet
By any chance are using version 12?
__________________
My first two Pokemon games.

Reply With Quote
  #36    
Old July 18th, 2013, 06:01 AM
mustafa505's Avatar
mustafa505
Developer
 
Join Date: Apr 2010
Location: Hoenn Region :P
Age: 15
Gender: Male
Nature: Lonely
Send a message via Windows Live Messenger to mustafa505 Send a message via Yahoo to mustafa505
i am using version 11 and i get this error whenever i goto new game:
Code:
---------------------------
Pokemon Essentials
---------------------------
Exception: NoMethodError

Message: undefined method `pbQuantity' for nil:NilClass

Hud:35:in `initialize'

Scene_Map:29:in `new'

Scene_Map:29:in `createSpritesets'

Scene_Map:28:in `each'

Scene_Map:28:in `createSpritesets'

Scene_Map:63:in `cng_dayseason_map_main'

Season:162:in `main'

Main:37:in `mainFunctionDebug'

Main:15:in `mainFunction'

Main:15:in `pbCriticalCode'



This exception was logged in 

C:\Users\Mansoor\Saved Games/Pokemon Essentials/errorlog.txt.

Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK   
---------------------------
__________________
~Red~ Signature


My GPX Page: GPX - User Page
Mustafa505

XD
My (H)acks:
Pokemon Chronicles
PC Page:

The Pokecommunity Mustafa505 - User Page
Projects:

Epic Words From a Mod From PC:
"What I mean by this is,
I'm not strict like MOST people *cough* Admins/Mods *cough* on this site.
And no not all Admins/Mods are like that,
but MOST are,
Post this in your sign.
if you are PC Viruse free!"





Reply With Quote
  #37    
Old July 20th, 2013, 03:44 PM
pokemonmercury's Avatar
pokemonmercury
 
Join Date: Jul 2013
Gender: Male
Thank you for this!
I will use this... And of course... I'll give credit.
Reply With Quote
  #38    
Old July 23rd, 2013, 04:10 PM
linkthehero's Avatar
linkthehero
 
Join Date: Sep 2012
Gender: Male
Im Using essentials And everething Works Fine And i 'Versionen Never got an error
Ok the Misters Gift Sitzfläche Don 't work ,but this is Not so Big Problem .(Sorry for my Bad english)
Reply With Quote
  #39    
Old October 14th, 2013, 04:03 AM
Yero
 
Join Date: Aug 2011
Gender: Male
Thanks heaps, looks great. But when I try using it, I keep getting
Quote:
The safe file is corrupt, or is incompatible with this game
followed by the question to delete the previous safe file.
Once I press no I get this error:

Spoiler:
---------------------------
Shadows of the Past
---------------------------
Exception: RuntimeError

Message: scss error - Corrupted or incompatible save file.

PokemonLoad:432:in `pbStartLoadScreen'

DebugIntro:6:in `main'

Main:37:in `mainFunctionDebug'

Mainin `mainFunction'

Mainin `pbCriticalCode'

Mainin `mainFunction'

Main:47

Main:46:in `loop'

Main:55



This exception was logged in

C:\Users\Yero R. Kuethe\Saved Games/Shadows of the Past/errorlog.txt.

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


How to fix that?
Reply With Quote
  #40    
Old October 14th, 2013, 10:39 AM
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
Delete the save file... The error gives you the solution and the fix, you chose to say no when you need to say yes... It will work when you do that.
Reply With Quote
  #41    
Old October 14th, 2013, 11:23 AM
Yero
 
Join Date: Aug 2011
Gender: Male
I have tried that too. Started a new game by deleting the previous saved file, got at least 2 new pokemon, saved the file again and restart. But I keep getting that same error.
Reply With Quote
  #42    
Old October 14th, 2013, 11:33 AM
Maruno's Avatar
Maruno
Lead Dev of Pokémon Essentials
 
Join Date: Jan 2008
Location: England
Which version of Essentials are you putting this script into? This script only works for Essentials version 6 or later.
__________________
Reply With Quote
  #43    
Old October 14th, 2013, 11:50 AM
Yero
 
Join Date: Aug 2011
Gender: Male
If the version numbers are on the left of the Download page on the wiki, then version 10 or 11. I have replaced the script with the one given on the thread, deleted the old PokemonLoad file. Restarted over and over again, everytime saving a new file as it keeps saying that the safe file is Corrupted or incompatible save file.

Quote:
---------------------------
Shadows of the Past
---------------------------
Exception: RuntimeError

Message: scss error - Corrupted or incompatible save file.

PokemonLoad:432:in `pbStartLoadScreen'

DebugIntro:6:in `main'

Main:37:in `mainFunctionDebug'

Mainin `mainFunction'

Mainin `pbCriticalCode'

Mainin `mainFunction'

Main:47

Main:46:in `loop'

Main:55
Reply With Quote
  #44    
Old October 14th, 2013, 12:26 PM
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
delete the save file... It's the only solution, sorry to say.
Reply With Quote
  #45    
Old November 5th, 2013, 07:07 PM
monkeyking's Avatar
monkeyking
 
Join Date: Nov 2013
Location: new york
Gender: Female
Thanks. I want to say appreciate the details provided
__________________
I often relax on friv after hours of hard work.
Reply With Quote
  #46    
Old January 2nd, 2014, 10:27 AM
dydd90's Avatar
dydd90
 
Join Date: Dec 2013
Location: Italy
Gender: Male
it's great!! i'll use it of course
__________________
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 02:57 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.