After Learning Ruby

Polar_Bearity

Bespectacled Old Bear
Member
Joined
Dec 4, 2014
Messages
9
Reaction score
8
First Language
English
Primarily Uses
I hope this is the right place to post this thread.

I've been feeling really confused and lost as to what should I do next - I finished my Ruby lessons on Codecademy (not sure what everyone thinks about the site but it's been very friendly) and like a naive little boy, I thought that I'd be able to freely code in RGSS after I gave the existing scripts a read. But no, that really wasn't the case.

I've been scrolling through some of the topics posted in "Learning Ruby and RGSS" and I still haven't gotten much of an idea on what to do or where to start. Though, one thing I realized (and I admit) is that I get the syntax, but not the semantics. Like, how do codes really work and what actually does what? I really need to get some practice but... where do I get it? And how? I tried Googling for websites that offered practice projects and wound up on CodeWars shortly thereafter. But I couldn't solve even the most basic questions (because of which I got so discouraged that I didn't touch Ruby for half a week, until I somehow started revising my notes).

So yeah, I just wanted to ask if anyone could give me a pointer or some advice on what should I do now? _:)'3_/T_)_ I'veneverfeltsolostinmylifeI'msorrytobotherya'll
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,545
Reaction score
3,715
First Language
Java's Crypt
Primarily Uses
RMMZ
You should first think of what you want to do with a script: Think of something simple but that could actually be useful to someone. Then try to write a script for that. Looking at existing scripts is one of the best ways to find out how to do something, but if you don't know what you want to do, you won't be able to learn much from it.
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
I need some information in order to understand what your level of knowledge is, and respond to you accordingly.

1] What is your programming experience? For instance, do you know how to code on other programming languages?

2] Are you self taught or did you learned some stuff at school or College?

Please answer me these questions and I might be able to help you out.
 

Polar_Bearity

Bespectacled Old Bear
Member
Joined
Dec 4, 2014
Messages
9
Reaction score
8
First Language
English
Primarily Uses
You should first think of what you want to do with a script: Think of something simple but that could actually be useful to someone. Then try to write a script for that. Looking at existing scripts is one of the best ways to find out how to do something, but if you don't know what you want to do, you won't be able to learn much from it.
I thought I'd start out simple and try to do something very, very basic: make a window. Like, without any text or anything in it. Just a window somewhere on the screen. But it didn't turn out all that well. I kept reading Window_Base (in RMVX/RGSS2), trying to understand line-by-line what the code actually meant and I haven't made any significant progress, to be honest. Actually, I still have no idea what I'm doing. :(

I need some information in order to understand what your level of knowledge is, and respond to you accordingly.

1] What is your programming experience? For instance, do you know how to code on other programming languages?

2] Are you self taught or did you learned some stuff at school or College?

Please answer me these questions and I might be able to help you out.
Okay... please bear with me since I'm gonna sound like a complete newbie here but yeah:

1] I know Ruby and a bit of Python. My programming experience is nil except for all the programs I made for the exercises on the site. But to be very frank, it feels like they just held my hand and walked me through the lessons, telling me what to code and how to do it. So yeah.

2] I'm self-taught, finished my lessons about a week ago and have been looking for more online tutorials and any e-books I could get my hands on for Ruby.

I know I sound really imposing (and annoying) but I really, really appreciate that you guys are taking your time to help me out. It means a lot to me.
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,545
Reaction score
3,715
First Language
Java's Crypt
Primarily Uses
RMMZ
I thought I'd start out simple and try to do something very, very basic: make a window. Like, without any text or anything in it. Just a window somewhere on the screen. But it didn't turn out all that well. I kept reading Window_Base (in RMVX/RGSS2), trying to understand line-by-line what the code actually meant and I haven't made any significant progress, to be honest. Actually, I still have no idea what I'm doing. :(
Instead of looking in Window_Base, try looking at some piece of code that uses Window_Base, like Scene_Menu.
 

Polar_Bearity

Bespectacled Old Bear
Member
Joined
Dec 4, 2014
Messages
9
Reaction score
8
First Language
English
Primarily Uses
Instead of looking in Window_Base, try looking at some piece of code that uses Window_Base, like Scene_Menu.
Just tried to and still feeling a bit lost but get most of what the Create Command Window is saying. ; v ;
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,359
Reaction score
7,672
First Language
German
Primarily Uses
RMMV
2] I'm self-taught, finished my lessons about a week ago and have been looking for more online tutorials and any e-books I could get my hands on for Ruby.
From what you said so far, you have learned the syntax but are missing the understanding of programming logic.
That last part has nothing to do with any single programming language, which is why you won't find tutorials for it if you're looking for Ruby tutorials (or any other language-specific tutorials).


What you need is to look for logic tutorials and for tutorials how to make a flowchart, because that is the part you're missing.


The sequence needed in programming is usually


Idea -> Logic structure/Flowchart -> Coding/Syntax


My post on this topic describes the theoretical part of where you're currently stuck, it might help you to get a better idea:


http://forums.rpgmakerweb.com/index.php?/topic/31354-can-the-scripting-system-be-easier/#entry304792
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
English is not my native language, but I will give it a try.

Press spoiler, but warning! This will be huge!

Hope this will help you out!

Good. Let's let RPG Maker aside for a while.

What you really wanna know is  how to make programs.

You have to understand the steps of the process we make.

First of all a program might be also called an application (an app) or you might even see it called a "solution".

Programs solve problems. Thus we call them "solutions" sometimes.

So in order to write a solution, you must first know what the problem is. 

That is what @Hudell told you and he is right! ;)

So let's see, how do we start.

1] What is the problem?

Gee I want to make a number guessing game!

I don't know which programming language I will use.

But I know I wanna make a game that the player will guess one number.

So... what do we do?

Let's make a description of the problem, before we try to make a solution!

a)The number that must be guessed must be from 1 to 9001. (IT'S OVER 9 THOUSAAAAAND)

Yeah! that's the one thing we wanna know...

What else?

What will the game do?

B) It will show a message "Please Guess the number" Or something, and ask for a number guess!

Okay.

Then?

If the number the player puts is bigger?

c) It will show a message "This number is bigger, sorry" or something.

And for a smaller?

d) It will show a message "This number is smaller, sorry" or something.

And what if he/she finds it out?

e) It will show a message "GOOD JOB YOU FOUND IT!" or something.

Did we forget about something???

ZOMG!

The number! How will the program decide what will the number should be?

Let's change a) accordingly

a) The program will choose a secret random number between 1 and 9001.

Let's put all these together.

The program will choose a secret random number between 1 and 9001 , then  

*  

it will show a message "Please Guess the number" or something, and ask for a number guess, then if the number is bigger  it will show a message "This number is bigger, sorry" or something, if the number is smaller it will show a message "This number is smaller, sorry" or something and finally if the guess is right  it will show a message "GOOD JOB YOU FOUND IT!" or something!

So you got a description.

Can you write a program?

Well, not yet...

Let's pause the problem solution for a while.

Let me talk to you about foreign languages.

I speak well my native language, that is not English and I try to be fluent in English, because English is the universal speaking language.

Many people can understand English. And that's a good thing.

Same goes for... programming languages.

Let's say I am fluent in Java.

If I will give you a program written in Java and you know nothing about Java... you might say...

http://i2.kym-cdn.com/photos/images/original/000/216/899/23608610-d0b9-4658-9740-f98463148d30.jpg

so...

in order everyone would understand a solution, people invented a universal programming language called pseudocode.

You can Google it. I will not teach you this here. 

But I am gonna use it.

It is a mixture of good ol human English language and simple code.

So let's make a lame yet useful pseudocode:

ALGORITHM Guess_game_code

! Exclamation mark means this is a comment, not a part of code

! A <- B in pseudocode means that A takes as its new value, what B value is.

! So A <- 10 means that A now is 10!!! Got it?

! In programming you might have seen it as A = 10

Variable Declaration:

Variable A integer 

Variable B integer

Variable F boolean

! This F variable was not expected from start. While I was writing the pseudocode, I saw that just an IF statement would run only once.

! So the player would have 1/9001 chances to win.

! So I wanted to make the program run forever until the player would guess the correct number.

! This is done using a loop. So I must left out of the loop the random number (so it remains unchanged) and loop the player input right?

! I will color the loop with brown color. Notice that this loop was discovered that it was needed, while I started writing in pseudocode the solution. 

! It wasn't on the description. This is a common mistake.

! The description should include the loop at the * position  like

"Until the user finds out the correct answer the program will do the !following:

!" Then the description would be ok. Ever wonder why I had an empty line with just that asterisk? :p

!Let's go on with the pseudocode:

A <- Choose a Random number between 1 and 9001

WHILE (F = 0) DO

Show message "Please Guess the number"

Show message "What is your guess bro?"

B <- User Input

   IF B > A THEN

      Show  message "This number is bigger, sorry"

   ELSE IF B < A THEN

      Show message"This number is smaller, sorry"

   ELSE

      Show message "GOOD JOB YOU FOUND IT!"

       F <- 1

   END IF

LOOP

END Guess_game_code

So that was a pseudocode.

Now EVERYONE can understand how to make this right?

All turing-complete programming languages (most of them are) can do these things.

Anyone fluent in Visual Basic or Python or C++ or C or C# or Ruby, or Java, or Fortran, or whatever, can do that in that language.

Remember the asterisk that pointed a missing part on the problem description?

Describing a problem is the hardest thing to do right in programming.

If you make an algorithm written in pseudo code, then you can convert it in any programming language, having an idea what to do.

In our scenario

 We needed three variables.

Two for integers and one for a boolean value.

Then we need a WHILE loop. How will we implement it in RUBY? Well, Ruby has a While equivalent under a certain syntax right?

Same goes for assigning values.

Ruby can also handle IF statements, using certain syntax rules right?

Also ruby can get input from the user and then show messages, right?

WE CAN DO THIS IN RUBY.

Since you know the programming concepts (tools)

IF

CASE

WHILE

LOOP

FOR

DECLARE VARIABLES

VALUE ASSIGNMENT

FUNCTION DECLARATION

FUNCTION CALL

you can actually do a lot of things combining them, in ANY programming language.

Now this example was a simple one, that will use the debug console of Ruby (VX ACE) to get and give info.

It is procedural programming concepts (also apply in object oriented programming).

These concepts are the fundamentals.

====================================================================================

If you wanna learn an object oriented language, like Java or Ruby, you have to learn a few more stuff. 

CLASS

INSTANCE

   MEMBER

       METHOD

           CONSTRUCTOR

            DESTRUCTOR

       ATTRIBUTE

ENCAPSULATION

INHERITANCE

POLYMORPHISM

   OVERRIDE

EVENT

LISTENERS

====================================================================================

After understanding some stuff, you have to understand what RGSS is.

It is a game engine.

That means it is a script driven collection of code methods (functions) that can do stuff.

What stuff? 

Well stuff like show a map made of tiles, move a hero in it, show events in it, according to the events in a map, use stuff from database to a map, create a battle screne (and use a battle engine) and show menus and change ,music and stuff....

So RGSS 3

Show graphics

Draws menus and other windows

contains a Battle system

it is actually a huge collection of small scripts.

Check out something I suggested that involves RGSS3 scripts

A copy paste from another reply I gave on another thread,

Script editor.

Under Windows group,

Script: Window_MenuCommand

Put a # in front of Line 40

#    add_save_command

This will remove the save command from the menu, because commenting out the command will not execute it.

See line 40 and the rest of them.

These construct the main menu.

See? There are places that you can understand.

Go slowly and not so deep into it.  ;)

And remember... Show message can be implememnted in just a debug console... but if you have an engine for game graphics, it can be implemented in a window. You actually do that while eventing in VX Ace... ;)

Can't believe I actually wrote all these stuff! :p
 
Last edited by a moderator:

Polar_Bearity

Bespectacled Old Bear
Member
Joined
Dec 4, 2014
Messages
9
Reaction score
8
First Language
English
Primarily Uses
I'm sorry I haven't replied in a while - I was visiting the hospital for a while and then got busy with studies. ^ - ^;

From what you said so far, you have learned the syntax but are missing the understanding of programming logic.

That last part has nothing to do with any single programming language, which is why you won't find tutorials for it if you're looking for Ruby tutorials (or any other language-specific tutorials).

What you need is to look for logic tutorials and for tutorials how to make a flowchart, because that is the part you're missing.
The sequence needed in programming is usually

Idea -> Logic structure/Flowchart -> Coding/Syntax

My post on this topic describes the theoretical part of where you're currently stuck, it might help you to get a better idea:
http://forums.rpgmakerweb.com/index.php?/topic/31354-can-the-scripting-system-be-easier/#entry304792
Thank you so much for replying! I'm about to read your topic so yeah, thank you for linking me to it~ And yes, I admit having no idea about the logic used behind programming. So yes, I'm really thankful to you for posting that.

English is not my native language, but I will give it a try.

Press spoiler, but warning! This will be huge!

Hope this will help you out!

[spoilered]

Can't believe I actually wrote all these stuff! :p
My gosh, that is one hell of an amazing explanation. I don't care if English isn't your native language, I completely understood each and every bit of it. Thank you so, so much for that! You have no idea how grateful I am to you for taking your time to write that all. ( T w T)/
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
I made a tips about script experiment template if you just want to get started
http://www.rpgmakervxace.net/topic/22608-rgss23-tips-script-experiment-template/
 
Though you need to login to see the post.
If you don't have VXAN account, then here is the post

Okay, this is not a really tutorial. It just a template that I used long time ago to made a little experiments. It works on RGSS2 or RGSS3. I'm sure it works on RGSS also but I haven't tried it yet.
 
It just a simple script that make a blank screen so you can easily do an experiment from built-in library classes / functions. Especially for graphics related object such as Sprite, Plane, and Window. All you need to do is insert this script below material above mainDataManager.init # Initialize database # basic update methoddef updates  # Do basic update  Graphics.update  Input.update    # Put another update here  end # Do some initializations hereupdates while true # Do a infinite loopSo, what is this templates for?
As I said before, it used to test some methods / attributes which are written in helpfile. Due to blank screen, you don't need to confuse about how do you insert a graphical objects in Scenes. You only need to focus on one (or more) object you create. How to modify the object, trying some built-in methods, or even try some crazy ideas.
 
Okay, I admit it I can't speak english well . Below this line are examples of my (old) experiment using the template above when I began to learn RGSS3. Don't forget to turn on the console debug.

I hope you guys understand what I was talking about.
 
Note :
You don't need to add DataManager.init in RGSS2
P.S:
After learnt Ruby, I took around 1-2 months to get started in RGSS3 and made my very first script. 

So, just be patient. Always look at default script. If you've burntout, take some break.
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
The secret to game scripting is to think of something that would be cool and then write something that does it.


Programming isn't just learning how to write code. It's learning how to translate ideas into code.


I'd start with simple short scripts that are only a few lines of code and figure out what it's doing.
 
Last edited by a moderator:

whitesphere

Veteran
Veteran
Joined
Mar 14, 2014
Messages
1,688
Reaction score
784
First Language
English
I would also download some simple scripts and see how they work.  When I first learned programming (BASIC, back in the late 1970s), I started by making extremely simple programs that did REALLY simple things, like "Calculate the temperature in Celsius given the temperature in Fahrenheit" .

Then I would type in simple example programs and start playing with them to see what happened.

I would download Ruby and run these types of examples in it.  You can use Notepad++ as a free editor that understands some Ruby syntax (just use ".rb" for the file extension).

Converting an idea into a program does take practice.  You are basically breaking down a complex idea into a series of steps which do what you want.

In the case of RGSS scripting, you also need to understand that your scripts are not running by themselves in isolation, but they are running within the game engine.  When you press F11, the long list of things you see are the default scripts that, together, with some non-Ruby code, make the game run.

That makes your task more complicated.  I think, until you are very comfortable with converting an idea you have into a sample, standalone program, you shouldn't even try RGSS scripting because that adds more complexity if you are just starting out learning how to program in general. 

When I started RGSS scripting and learning Ruby, I already had a lot of experience with converting ideas to program logic, so I didn't need to learn that at the same time.  And I'm sure the expert scripters will say it takes them time to master RGSS to do what they need, because they may be changing the behavior of quite a few objects in the game to implement their changes.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,019
Members
137,564
Latest member
McFinnaPants
Top