View Single Post
Old July 23rd, 2013 (5:27 PM).
FL's Avatar
FL FL is offline
Pokémon Island Creator
    Join Date: Sep 2010
    Gender: Male
    Posts: 1,722
    Originally Posted by jim42 View Post
    I think you're missing the point of my rewrite, FL. That solution hardcodes the start selections into the script. I'm trying to make it such that it can use any three Pokémon as denoted by the script call. So, instead of calling pbShowStarterSelection and having to pick between Bulbasaur, Charmander or Squirtle, you could call pbShowStarterSelection(x,y,z) or pbShowStarterSelection(a,b,c) and have the script display choices for completely different sets of Pokémon.

    The problem with that is that in order to pass x,y,z/a,b,c to the part of the script that actually displays the scene, I would have to add parameters to several method calls along the way, none of which actually use them. If I could put them straight into a set of quote-unquote "global" variables accessible from anywhere inside that script, that would be really helpful. It'd be kind of like the OO classes I've been writing in C++.
    Sorry for my misunderstanding!

    Since you call a method in a different class, you need, at least, put it in two parameters declarations, there ways to put in only one using a Global Variable ($), but this is really a bad idea, use an Instance Variable (@) instead:

    def pbShowStarterSelection(starterOne, starterTwo, starterThree, nameLater=false)
      pbFadeOutIn(99999) {
         screen.pbStartScreen(starterOne, starterTwo, starterThree) # You can put these parameters in the constructor.
    def pbStartScene(starterOne, starterTwo, starterThree) 
        # Some code
        # Some code
    So, only use @starterOne, @starterTwo and @starterThree in the rest of the class. For accessing these parameters in other classes, search about attr_accessor, attr_reader and attr_writer.
    Reply With Quote