Need some very basic Ruby help

Hi everyone,

I'm slowly starting to learn ruby coding. I want to make just a simple snippet to place a skill name from the database into a variable.

I know how to add strings to variables ($game_variables[147] = "This is text", but I can't seem to come across the skill names in the game code. I'm sure the veteran coders out there can figure this out easily, but I'm still new.

I tried $game_variables[147] = $game_skills[8] but it just returned "0", so my guess was wrong.

Thanks in advance,

Sindaine
Well, it's:

$data_skills[8].name
But I don't actually recommend setting variables to hold strings. It is very easy to run into problems down the line. If you do it just to show it in a message, I recommend you immediately set the variable back to 0 once you're done. Better yet, use a message system that allows you to show skill names without messing around with variables.
Wow! Thanks for the very quick reply. I'm not using it for any specific purpose, just expanding my knowledge a bit. Thanks for all the help though! What message system would you suggest?

Thanks again,

Sindaine
Well, I've written one myself: ATS Series. Yanfly also has an amazing Ace Message System

Other than that, I am sure a lot of message scripts would have a feature like that, but I am not familiar with them all.
Thanks for listing those for me. One last question. Is there a place that references all the properties of parts of the engine? IE: How did you know that it was $data_skills(8).name? Is "name" a common extension? I want to know how to grab different portions of things in the engine. 

I guess I'm looking for a reference that is something like:

$data_skills(n).id - number of the skill

$data_skills(n).name - name of the skill

etc.

Thanks again for all your help,

Sindaine
First off, you need to use [square brackets] to access an element in an array.

Secondly, $data_skills is an array of RPG::Skill objects. You can see all methods for the RPG::Skill class in the Ace help menu. I believe RPG::Skill inherits from RPG::UsableItem and RPG::BaseItem, so you can check those classes for more methods as well. I don't have Ace in front of me atm, so I can't 100% guarentee those class names. Should be easy enough to find in the help menu though. : )
Thank you so much. This will help a lot.

This can be closed now, thank you.

Sindaine
The help file (F1 in the editor) gives you the layout of all the RPG classes (held in the $data_* arrays, so everything you see in the database tabs, and more). Looking through the scripts (F11 in the editor) gives you pretty much everything else (data held in the $game_* arrays that save the player's progress, plus everything that causes "stuff" to happen in the game, and the menus). Studying those will reveal a wealth of information.


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/need-some-very-basic-ruby-help.22202/