[VX] Seeking more info on the "$" commands.

● ARCHIVED · READ-ONLY
Started by Rhaeami 14 posts View original ↗
  1. This is probably an extremely basic question, but I've not been able to find any info on it at all - possibly due to most Google searches ignoring symbols and such.

    Anyway, in doing some events and basic script edits for my game, I've come across some very useful whatchamacallits.  I'd like to call them "variables", or perhaps "scripts", but I doubt those are the right terms.  They look like this:

    $game_actors[n].name

    $data_items[n].name

    So far I've only been able to puzzle out these two, but they've helped me tremendously in figuring out how to tweak my battle system and give the player some useful info prompts.  What I'd really like is some sort of database or manual that describes each and every one of these sorts of commands.  The things you can put after "$" to define what to pull info from, and the things that you can put after the "." to define what kind of info to pull out of them.  These seem like super basic commands that any scripter should know, but I can't find any mention of them whatsoever, after two days of searching!

    To make things more specific, in case something like a full listing of everything is impractical... I've been trying to figure out how to reference a Key Item's Description.  I can neither figure out how to reference Key Items, nor how to reference Descriptions of any sort of item.

    Any help at all in either pointing me towards where to learn more about these "$" things, or help with my specific problem, or even just telling me what to call them so I don't have to call them whatchamacallits anymore... would be greatly appreciated.  Thank you! ;)
  2. $ = global variable that you can reference anywhere in the game IIRC.
  3. Archeia said:
    $ = global variable that you can reference anywhere in the game IIRC.
    Ah, thank you, so they're global variables.  I wish that was enough, but searching around on the internet only turns up information about user-made global variables, not the ones that come with the program by default. :(
  4. Raemyi said:
    Ah, thank you, so they're global variables.  I wish that was enough, but searching around on the internet only turns up information about user-made global variables, not the ones that come with the program by default. :(
    If you use the search-bar in the forums (top of the page) you will restrict your search to these forums only and thereby make sure they are at least referring to ones in, or that work with, RPG Maker.
  5. You could also check the help file. It has most of the classes defined, and the ones that aren't are listed in the script editor itself.


    $ means a global variable, accessible from any script (including script calls from events).


    $game_* means data that is saved in a save file (usually). So you have $game_player, $game_party, $game_map ...


    $data_* means the database where you set up all your actors, enemies, items, skills, etc. So you have $data_actors, $data_enemies, $data_troops, $data_items, etc.


    Details of all of those can be found in the help file or in the scripts.
  6. You can see where most of the global variables are created in the DataManager if you want something resembling a list. Lines 36 to 51 have all the $data_ objects. Lines 83 to 94 have all the $game_ objects.


    Nevermind, just noticed you tagged this as VX. The same methods are located in Scene_Title for VX. Lines 79 to 93 for $data_ and 114 to 126 for $game_.


    Generally speaking, you'll need to check the help file for methods of $data and the editor for $game.


    $TEST and $BTEST are only other global variables that come to mind. They're set to true if you are playing through the editor or battle test respectively and false otherwise.
  7. Eugene222 and Archeia:  I tried that topic a while ago, but it seemed to list out full scripts that the author had written themselves for various purposes.  Not quite what I was after, but a good try.

    Shaz:  Your description was incredibly helpful, thank you.  As far as the help file goes, I wasn't able to find anything in it when I looked, but I'll give it a second try when I get home. :)

    Yato:  Perfect, just what I was looking for!  As I said before, I wasn't able to find anything about $data or $game the last time I checked the help file, but I'll give it a second try after I get home.  I figured out a way to circumvent the whole thing in the worst case scenario, but hopefully I can still learn this stuff for future reference. :cutesmile:
  8. I'm not at my computer, but if the VX help file is similar to Ace's, there are two main sections when you first hit F1. The first section is "how to" use the engine. The second section is all the technical script stuff. Go into that and look through the sections. I can't even tell you the name of the section I use in Ace that has all the internal classes. I think it's the third one in the list.


    Post back if you can't find it, and I'll check again when I get home this afternoon and give you the exact location.
  9. I feel silly now - I actually am using VX Ace, not VX.  It wasn't until re-reading some of your replies that I realized that there even *was* a plain old VX.  My apologies for that. :blush:

    Anyway, I got home and took a look around.  I looked through the help section you mentioned, but I still couldn't find much.  I think a lot of it was that I didn't know what relevance any of the information had to actual string writing.  In my head, something like "$game_actors[n].name" is a single command, but that help section listed things like "actors" without any of the surrounding context - to be precise, it didn't say how to plug it into a line of code.  I think this stuff might be a bit beyond me at this point.

    What's worse, using what Yato said, I dug around in the game's scripts and found all of the other variations on $game and $data, but you know what?  Nothing on key items.  There's items, even armor, but no key items.  I'm starting to think the engine treats them differently, or maybe it considers them to be just regular "items" on its end.  Complication after complication, it seems. :dizzy:
  10. I think the section of the help menu Shaz was referring to was RPGVXAce Data Structures. I usually just search for whatever particular one I'm wanting to look for at the time. The help menu doesn't specifically tell you which $data_ is which, but it should be fairly easy to figure it out. For example, $data_items is an array of RPG::Item s. So if you wanted to know if the first item in your database was a key item, you could use $data_items[1].itype_id == 2 or $data_items[1].key_item?. If you wanted to get an array of key items, you could do something like the following:

    key = $data_items.select {|item| item and item.key_item?}The attributes and methods list in the help menu tells you every method you can use with that class. So with, for example, Items, you have itype_id, price, consumable, and key_item?. On top of that, you also have every attribute and method of the super class, RPG::UsableItem. Here you find things like scope, occasion, and menu_ok?. These are methods that are common among items and skills.
    All the information is there, it's just helpful if you know what exactly you're looking for. In general though, most of what you can access in the $data items are things you set in the database.
  11. Hmm, interesting.  If nothing else, I feel like I have a better idea of how things work behind the scenes, now.

    Thanks for the help, everyone.  I'll consider this question officially answered, now.  Back to work. :ninja:
  12. F1 (Help) > RGSS Reference Manual > Game Library > RPGVXAce Data Structures > RPG::BaseItem > RPG::UsableItem > RPG::Item


    There's nothing in there on 'key' items. That's in the script editor itself (although the help file will tell you the itype_id field of an RPG::Item object tells you whether it's a key item or not, but that's about it.


    The link between the $data_* classes and the data structures listed in the help file are a little bit harder than just searching for the same name. $data_items is an array where every element (that is not nil) is an RPG::Item object. $data_actors is an array where every non-nil element is an RPG::Actor object. And so on.