View Single Post
Old July 17th, 2013 (6:33 AM).
BlackWaltz3's Avatar
BlackWaltz3 BlackWaltz3 is offline
    Join Date: Jul 2009
    Gender: Male
    Posts: 188

    Okay so this is a huge necropost. Sorry if that's a problem. I've gone back to my Starter Selection screen, and rewritten it from the ground up in order to be able to accept parameters such that it can be initialised with any three Pokémon as specified in the method call.

    What I've built seems more or less structurally sound, but I've come to realise the variables passed into the method call have no way of reaching their target destinations. The code compiles, but throws an exception when called due to the "missing" variable values.

    As far as I've seen, the only self-contained way I can pass those variables all the way down to the required code is to pass them through each and every method along the way. It's pretty safe to say that with several variables this becomes quite lengthy and unpleasant to read. Is there an easier way by which I might pass these variables though to their intended code?

    I've included the code below for your convenience.

    # Pokémon Starter Selection module Version 1.1
    # This is a script to display and handle a basic starter selection scene. It   #
    # displays three Pokeballs, their corresponding Pokemon, and their basic data. #
    # The player may use the arrow keys to select a Pokemon, and the C input to    #
    # confirm their selection.                                                     #
    #                                                                              #
    # The method can be called by using a script command in an event containing    #
    # the string, "pbShowStarterSelection(<x>, <y>, <z>, <a>)", where <x>, <y> and #
    # <z> are the species one wishes to display as starters, and where <a> is an   #
    # optional value (false by default) to determine whether the acquisition and   #
    # nicknaming prompts are displayed.
    # Copyright Aaron Richards a.k.a. BlackWaltzTheThird, 2012                     #

    #CHANGED 2153 27 JUN 13 included in new project #CHANGED 2358 17 JUL 13 updated to version 1.1; changes too numerous to tag

    class PokemonStarterSelectionScene def update pbUpdateSpriteHash(@sprites) end

    def pbStartScene @sprites={},0,Graphics.width,Graphics.height) @viewport.z=99999 addBackgroundPlane(@sprites,"bg","StarterSelectionBackground_BW3rd",@viewport) @sprites["overlay"],Graphics.height,@viewport) pbSetSystemFont(@sprites["overlay"].bitmap) pbDrawStarterSelection pbFadeInAndShow(@sprites) { update } end

    def pbDrawStarterSelection [email protected]["overlay"].bitmap overlay.clear,72,72),185,185) textPositions=[] imagePositions=[]


    call variables need to get to this section mainly (starterOne, etc) if $game_variables[26]!=0 textPositions.push([_INTL("Pokémon"),370,72,1, baseColor,shadowColor]) if $game_variables[26]==1 textPositions.push([_INTL("{1}",PBSpecies.getName(starterOne)), 16,40,1, baseColor,shadowColor]) textPositions.push([_INTL("{1}",pbGetMessage(MessageTypes::Kinds,starterOne)), 370, 40, baseColor,shadowColor]) imagePositions.push([_INTL("Graphics/Battlers/%03d",starterOne),180,8,0,0,-1,-1]) imagePositions.push(["Graphics/Pictures/boxpoint2",96,170,0,0,-1,-1]) pbPlayCry(starterOne) elsif $game_variables[26]==2 textPositions.push([_INTL("{1}",PBSpecies.getName(starterTwo)), 16,40,1, baseColor,shadowColor]) textPositions.push([_INTL("{1}",pbGetMessage(MessageTypes::Kinds,starterTwo)), 370, 40, baseColor,shadowColor]) imagePositions.push([_INTL("Graphics/Battlers/%03d",starterTwo),180,8,0,0,-1,-1]) imagePositions.push(["Graphics/Pictures/boxpoint2",240,200,0,0,-1,-1]) pbPlayCry(starterTwo) elsif $game_variables[26]==3 textPositions.push([_INTL("{1}",PBSpecies.getName(starterThree)), 16,40,1, baseColor,shadowColor]) textPositions.push([_INTL("{1}",pbGetMessage(MessageTypes::Kinds,starterThree)), 370, 40, baseColor,shadowColor]) imagePositions.push([_INTL("Graphics/Battlers/%03d",starterThree),180,8,0,0,-1,-1]) imagePositions.push(["Graphics/Pictures/boxpoint2",400,170,0,0,-1,-1]) pbPlayCry(starterThree) end end

    pbDrawImagePositions(overlay,imagePositions) pbDrawTextPositions(overlay,textPositions)"Graphics/Pictures/pokedexTypes")),CHANGEME*32,96,32),CHANGEME2*32,96,32) @sprites["overlay"].bitmap.blt(16,72,typebitmap.bitmap,type1rect) @sprites["overlay"].bitmap.blt(50,72,typebitmap.bitmap,type2rect) if type1!=type2 typebitmap.dispose end

    def pbStarterSelection loop do Graphics.update Input.update self.update if Input.trigger?(Input::LEFT) $game_variables[26]-=1 if $game_variables[26]<1 $game_variables[26]+=3 end pbPlayCursorSE() pbDrawStarterSelection elsif Input.trigger?(Input::RIGHT) $game_variables[26]+=1 if $game_variables[26]>3 $game_variables[26]-=3 end pbPlayCursorSE() pbDrawStarterSelection elsif Input.trigger?(Input::C) if Kernel.pbConfirmMessage(_INTL("Is this the Pokémon you want?")) if namelater pbAddToPartySilent(,5,$Trainer)) else pbAddToParty(,5,$Trainer)) end $game_variables[26]==0 return end end end end

    def pbGetStarterSelected if $game_variables[26]==1 starterchosen=starterOne elsif $game_variables[26]==2 starterchosen=starterTwo elsif $game_variables[26]==3 starterchosen=starterThree end return starterchosen end

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

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

    def pbStartScreen @scene.pbStartScene @scene.pbStarterSelection @scene.pbEndScene end end

    method called here with three or four parameters. def pbShowStarterSelection(starterOne, starterTwo, starterThree, nameLater=false) pbFadeOutIn(99999) { screen.pbStartScreen } end

    Reply With Quote