Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

A great Ruby/RGSS tutorial for RMVX please?

wharfe

Member

Hi, I'm a noob at scripting. And want to learn Ruby to use with RMVX. I cant find any tutorials on rmvx.org so i'm making this thread.

I would like tutorial(s) which you actually do stuff in RMVX with.

I would appreciate help, thanks.
 
Well, I'm sure you could find a tutorial somewhere, but most of them are based on RGSS 1 (RPGXP), not RGSS2 (RPGVX).

However, I'll be glad to *try* and answer any general VX scripting questions you might have for now. My knowledge is mostly XP related though, VX is similar but defines certain things differently.
 

wharfe

Member

Thanks for the information Arbiter. I'm reading through a really basic Ruby tutorial at the moment.

I'll post questions in here when I'm stuck.

And when im advanced at RGSS2 I will make some good tutorials :)
 

wharfe

Member

Hey, I've been looking through the code.

Code:
  # Level
  def self.level
    return $data_system.terms.level
  end

  # Level (Abbreviation)
  def self.level_a
    return $data_system.terms.level_a
  end

  # HP
  def self.hp
    return $data_system.terms.hp
  end

I dont get how that works?
What is def? how does it work? What is return $data_system.terms.hp etc.
 
The basic set up of any script is usually like so... (rough and plain example)

Code:
#===============================================================================
# ~* Apples Vs Oranges *~
#===============================================================================
# Written by   : You
# Version      : 0.0?
# Last Update  : 4/20/69
# Created      : 4/20/69
#===============================================================================
# These constants need to be set to variable ID's in the database.
Apples = 1
Oranges = 2
#===============================================================================
# ** Apples_Vs_Oranges
#===============================================================================
class Apples_Vs_Oranges
  #--------------------
  # * Initialize Method
  #--------------------
  def initialize
    # Initialize Method here, the values the variables will start out at
    # when the script is first called.
    @apples = apples
    # If you notice, these variables look the same, one is an Instance variable,
    # the other is a class variable.
    @oranges = apples
    # Now, you're going to execute the 'main' method
    main
  end
  #----------------
  # * Update Method
  #----------------
  def main
    if @apples > @oranges
      print("You have more apples than oranges.")
    elsif @apples < @oranges
      print("You have more oranges than apples.")
    elsif @apples == @oranges
      print("You have the same ammount of apples and oranges.")
    end
  end
  #----------------
  # * Apples Method
  #----------------
  def apples
    if $game_variables[Apples] != @apples
      return $game_variables[Oranges]
    end
  end
  #-----------------
  # * Oranges Method
  #-----------------
  def oranges
    if $game_variables[Oranges] != @oranges
      return $game_variables[Oranges]
    end
  end
end

Very generic example, copy and paste it into your editor to get a better view of it and read the comments. If you have any questions, like "Well what exactly is '$game_variables[Oranges]' do?" then let me know.

The variables are probably the most confusing part to a new scripter, which one is used for what...

First off, a '@variable' is an instance variable, it doesn't really store any data unless the script is called. I set an instance variable to be the same value as a class or method variable, so it can do the math and the class variable isn't changed unless it needs to be.

Secondly a 'variable' is a class or method variable, these are more permanently referenced to in the script, and are determined by a method. Not sure how to explain it, just look at the example and let me know if I've already lost you.

Thirdly, a 'Constant' or 'CONSTANT' (ie Apples and Oranges) is a variable that you usually use for public settings, these always start with an Uppercase letter and cannot be changed mid-script. This is very useful for people who make public scripts, as they can be defined up top of the script without being inside a 'class', and it makes great for public settings. (ie USER_BGM is a constant telling the user to specify which BGM they want the script to play.)

A '$variable' is known as a global variable (which serious scripters know not to use very often), but is useful for multi-class scripts, as these variables can be read and written from any and all scripts... if you notice, I don't use any global variables in this script because they're not needed.

I'm not sure what else you might want to know, but try to read the help file if you need to understand basic terminology and functions, then come back here if you're unclear on a certain aspect of Ruby/RGSS(2?)


If you've got a good understanding of that thus far, then maybe tonight I'll try to teach you how to make a simple Window and Scene script from scratch (although I've never made one for VX before.) But before I go that far in helping you, I want to make sure you're understanding the basic gist of RGSS/2 scripting. Good luck with it wharfe! :thumb:
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top