How do you query what is in the scene?

● ARCHIVED · READ-ONLY
Started by DivideByZero 7 posts View original ↗
  1. Hi Guys,

    I am learning scripting by going in deep, tearing everything out, and learning how it all hangs together. Some might call it 're-inventing the wheel' to an extent, but I find this method works well for me. :)

    Assuming I have taken out all of the scripts and am mainly observing the debug output window, I am wondering how you query what is in the map? For example, how would I get the player characters, position, etc?

    I have tried;

    Code:
    p $gamePlayer.x

    But it returns 'nil', so I am assuming that $gamePlayer is most likely defined in scripts that are no longer in the project.

    Any advice would be greatly appreciated.
  2. This actually belongs in Learning Ruby, as RGSSx scripts is for scripts you've made. Easy mistake to make though.

    Moved to Learning Ruby



    (the blue is just so you know a moderator moved it officially)
  3. bgillisp said:
    This actually belongs in Learning Ruby, as RGSSx scripts is for scripts you've made. Easy mistake to make though.

    No worries, I posted it there as I thought the question would have been more VX Ace specific, as Ruby would have no knowledge of what is in the RPG Maker IDE (specifically the Map).

    [edit]
    Although re-reading the forum information, I can see the difference now :)
  4. Honestly, if you plan to learn the default engine, don't strip out all the defaults. Instead, try to learn why those script structured that way, which that by I mean "reverse engineering" it.

    But to answer your question, player object is abstract, you can just defined it by your own, can call it player, that's up to you. If you refers to game engine tho, there is RPG::System that defines the start_x and start_y. You use that by loading the object
    Code:
    load_data("Data/System.rvdata2")
    However, it just the starting position. What is the player actually is, is your 'responsibility' to handle the object player.
  5. Cool thanks for the info. I'll dig into the default scripts and do some experimenting.
  6. If I remember correctly, VXAce uses $game_player naming convention. $gamePlayer is for MV.
  7. from my tools drawer

    Code:
    class whatever < parent
      alias originit initialize
      def initialize(*args)
        list |= []
        list |= [:method_name, :method_name, :another_method_name]
        originit(*args)
      
        list.each{|method|
          ismethod = self.respond_to?(method.to_s, true)
          isaccessor = self.respond_to?(method.to_s+"=",true)
          isprivate = !self.respond_to?(method.to_s) && self.respond_to?(method.to_s, true)
          p sprintf("%s, %s, %s", method.to_s, ismethod, isprivate ? "private" : (isaccessor ? "accessor" : ""))
          p sprintf("%s = %s", method.to_s, self.send(method)) if ismethod && isaccessor
        }
      end
    end
    
    module Input
      def self.hold
        p "Halted"
        loop do
          Graphics.update
          update
          break if repeat?(:F8)
        end
      end
    end

    replace "whatever", "parent" and "method_xxx" accordingly, by whatever class name, parent and property you want to inspect.
    add "Input.hold" at any point in the code to halt the execution and be able to read the console (resume with F8)