How do I start scripting?

Tigersong

Furry Fellow
Veteran
Joined
Oct 22, 2012
Messages
452
Reaction score
44
First Language
English
Primarily Uses
I'm frustrated. More than anything I'd like to know how to "get my feet wet" when comes to scripting- but how? What's the basic syntax? Are those comments at the beginning of others' scripts essential or just explaination for the user? If anyone can answer my questions I'll give them a cookie. No, it's not a lie.

Tiger
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
well first is usefull to know some basis in ruby~

after that you have to check wich kind of script you want to make : graphicall?

mathemitical?

Battle

field?

each part need to be study

exemple you want to make a classical title screen (really usefull for learn) with a lot of graphics you have to know how to manipulate sprites~

but for understand

I advise you tu see diamondplatinium script tutorial they are pretty awesome!
 

ShinGamix

DS Style 4Ever!
Veteran
Joined
Mar 18, 2012
Messages
3,905
Reaction score
451
First Language
April Fools
Primarily Uses
N/A
Start scripting by learning how to code in ruby.
 

Tigersong

Furry Fellow
Veteran
Joined
Oct 22, 2012
Messages
452
Reaction score
44
First Language
English
Primarily Uses
Okay. Is there a site that teaches the very basics of ruby? Or even better, a general introduction to programming?
 

djDarkX

Retro & Remastered Music Guru
Veteran
Joined
Jan 17, 2013
Messages
2,700
Reaction score
1,901
First Language
Music
Primarily Uses
RMMV
There's plenty of sites that can teach you Ruby.

Ruby - Code Academy

RubyLearning (how I got started)

Just to link two.  Google search for Ruby tutorials and you'll get a bunch of hits.  Also, looking at how other scripts function compared to how the core scripts function (especially if they alias or overwrite stuff from the core scripts) is a great way to learn how to script.
 

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 downloaded and installed Ruby at first. So I could run ruby codes on my PC.

I do not like relying on online site. So I download this Book of Ruby. It's contains most of Ruby basics
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
There's plenty of sites that can teach you Ruby.

Ruby - Code Academy

RubyLearning (how I got started)

Just to link two.  Google search for Ruby tutorials and you'll get a bunch of hits.  Also, looking at how other scripts function compared to how the core scripts function (especially if they alias or overwrite stuff from the core scripts) is a great way to learn how to script.
yup they are two good link for help you how to manipulated ruby I learned for myself at code academy the  tutorial is really easy and pretty clear to understand and they give to  each part a a lot of link for have extra documentation.

so after you learned and play a little with ruby diamond platinium tutorial can be a lot usefull he explain part by part how to create definition class en everything! 

but most important! 

have fun with ruby and also don't hesitated to ask to the forum for help we have a lot of people who can help you like mithran-kun who are pretty badass in ruby manipulation! 
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
When I got to RM I already had a very basic idea of programming, but through making scripts and looking at others, I've managed to get really far. Once you get to understand the logic behind how a computer thinks, then you'll be able to apply it well.

Ruby is a very basic and easy to use language, so it should be easy for you to learn.

With all that said, once you learn variables, methods , and classes, I suggest you start making scripts for practice. You'll get better at it over time.
 
Last edited by a moderator:

Mouser

Veteran
Veteran
Joined
Aug 19, 2012
Messages
1,245
Reaction score
264
First Language
English
Primarily Uses
If you want to really learn to script, you need to learn to code.

First, forget about games. Just learn how a language works and how to use it making simple, console programs. The algorithms you learn will carry over into games scripting later on, but you've got to learn them 'in isolation' first. You can make console games like 'guess the number' or hangman or even tic-tac-toe if you want to learn some basic AI, but you've got to learn how to really use conditional branches, loops, basic data structures, Enumerators (very important in Ruby), and how Object Oriented programming works in general.

I used to recommend reading the core scripts from the engine as a learning tools, but the deeper I dig into them the less I find myself agreeing with that. There's way too many shortcuts and just plain bad coding habits going on in the 'core' scripts to be useful for learning the right things. At least they do follow the style guidelines for Ruby, which you should know: 2 space indents, comments and whitespace, etc...

If you like books (I do), Programming Ruby 1.9 by Dave Thomas (the Pickaxe book) and The Ruby Programming Language by Flanagan and Matsumoto (Matz: the guy who created and maintains Ruby) are the two sitting on my shelf. Those I can recommend wholeheartedly. If you have to pick one, go with the Pickaxe book as it includes the library in the back with all the method calls of each class. Very Useful Stuff, that. RGSS 3 uses Ruby version 1.9 (1.9.2?), so that's the version of the book you want.

And so you know (I didn't at first), if you use the 'playtest' option from the editor (F12 or the little arrow button on the toolbar), you get a console window associated with the game. It 'hides' behind the game screen if you're playing fullscreen, but you can alt-tab to it. You can use 'puts' and any other console type commands to display stuff there. Again, very useful for debugging.

Finally, a word on the 'ternary' operator: It's often required in the 'Damage Box' due to space limitations, but in general, its better to write your code without it unless it is immediately and obviously clear whats going on (many design style documents prohibit its use altogether). Particularly in a language like Ruby where many methods end with a ? already.  Just write out the conditional, it takes five to ten extra seconds but your code will be crystal clear to anyone else reading it (which includes you a few months after you first wrote it).

If you want some very good tips on coding style, check out the documentation for Unreal Engine 4 where they list the requirements for any code submitted to them. I don't think you need to be a subscriber to see that. You'll see every style 'choice' they require, along with their rational behind those decisions.
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
Finally, a word on the 'ternary' operator: It's often required in the 'Damage Box' due to space limitations, but in general, its better to write your code without it unless it is immediately and obviously clear whats going on (many design style documents prohibit its use altogether). Particularly in a language like Ruby where many methods end with a ? already.  Just write out the conditional, it takes five to ten extra seconds but your code will be crystal clear to anyone else reading it (which includes you a few months after you first wrote it).
Some good examples of this are for checking if a variable is a proper value:

should_be_a_has.is_a?(Hash) ? nil : (should_be_a_hash = {})or for outputting debug info:

puts "Nil is Nil? #{nil.nil? ? "Yes" : "No"}"Personally, though, I don't mind it's use much. I don't find it too hard to understand, and it could just take those five to ten seconds to understand what it is. In the end, though, it all ends up being the programmer's preference.
 

whitesphere

Veteran
Veteran
Joined
Mar 14, 2014
Messages
1,688
Reaction score
784
First Language
English
The first thing I would do is download Ruby itself. You can do that here: http://rubyinstaller.org/downloads/

Then, download a simple, flexible text editor.  For Windows, you can use Jedit or Notepad++.  I use Jedit, myself.

There is a free PDF that explores Ruby.  When you install Ruby, it's called "bookofruby.pdf" and is in the doc directory.

If you are familiar with programming, in general, just not with Ruby, it will go a lot easier.  

The best approach for learning it is to walk through that book.  It creates examples and explains them.    The best way to learn in general is by doing.

Then, create a simple, standalone program in Ruby (just a text file ending in .rb).  When you are familiar with Ruby syntax, then press F11 and look at the built-in classes.  You need to understand these basics before you even think of starting scripting.

At a very high level, all scripting is doing is modifying the behavior of the existing game classes (or creating new ones) to make an RPG which behaves differently than the stock RPG Maker classes.

Good luck.
 

Tigersong

Furry Fellow
Veteran
Joined
Oct 22, 2012
Messages
452
Reaction score
44
First Language
English
Primarily Uses
Once you get to understand the logic behind how a computer thinks, then you'll be able to apply it well.
^ That right there is my problem. I'm a writer; I tend to think in complete sentences, so the "grammar" of programming drives me crazy. Does anyone have some advice on how to overcome this?
 

whitesphere

Veteran
Veteran
Joined
Mar 14, 2014
Messages
1,688
Reaction score
784
First Language
English
^ That right there is my problem. I'm a writer; I tend to think in complete sentences, so the "grammar" of programming drives me crazy. Does anyone have some advice on how to overcome this?
The biggest difference is humans reading relies heavily on context.  A computer program does not.  Computers need to be told precisely, exactly what to do and how to do it.  The only "assumptions" a computer program may make are the ones which other programmers have written (the Ruby language, the Windows desktop, BIOS, video card drivers, etc.).  And even then, the programmer must be precise with everything else.  Which is one major reason why bugs creep in --- the programmer has made an assumption which the computer does not see explicitly spelled out.

So, think of the "grammar" of programming as a way to explain all of your assumptions to the computer.   Computers are extremely fast and extremely dumb.  They must be told every little thing.  So a programming language must be extremely precise, explaining the behavior in terms the computer understands.

For example, I can ask "Can you draw me a circle on the paper?  And you'll take out a piece of paper, take out a pen, and draw a circle on the paper, then probably hand it to me.

If a computer were doing this, it would say something like:   Take out the piece of paper.  Take out the pen.  Put your finger in the center of the paper.  Call this location (0, 0) on an X/Y axis.  Hold the pen in your other hand.  Draw all of the points where X=cos(angle) and Y=sin(angle), where angle goes from 0 to 360 degrees.  

The cos and sin are trigonometry functions which another programmer has defined.

In reality, computers don't see words, Skills, Events, games, sounds or anything.  At their most basic level, they only see and move numbers around. RPG Maker takes a ton of those numbers to represent, well, the framework for an RPG -- the sound effects, Skills, Events, sounds and so forth.  Then it uses functions in Windows so we can view, edit and play our RPGs.  But the computer is only working with numbers, very, very quickly.

You see why the programming language needs to be so different and so much more precise?
 
Last edited by a moderator:

Mouser

Veteran
Veteran
Joined
Aug 19, 2012
Messages
1,245
Reaction score
264
First Language
English
Primarily Uses
^ That right there is my problem. I'm a writer; I tend to think in complete sentences, so the "grammar" of programming drives me crazy. Does anyone have some advice on how to overcome this?
How did you learn to write in complete sentences?

 

You do it over and over again until it seems natural.
 

Tigersong

Furry Fellow
Veteran
Joined
Oct 22, 2012
Messages
452
Reaction score
44
First Language
English
Primarily Uses
Thanks, guys. I forgot to hand out cookies, by the way. *smiles sheepishly, distributes cookies*
 

DemonAbyss10

Villager
Member
Joined
Oct 15, 2012
Messages
30
Reaction score
5
First Language
English
Primarily Uses
A bit late on the post but this bit of advice may help others out there. One of the best ways to learn good, efficient programming technique and habits in general is to learn at least some assembly language. The code itself may not transfer over (differences between high and low level languages), but it does help give an understanding of just how high level languages function underneath the shiny (or not so shiny) package. 

I also recommend the links djDarkX posted. In fact, go through them both, it helps drill things into your memory than just going over everything once.
 

Yuffie-chan

Warper
Member
Joined
May 15, 2014
Messages
3
Reaction score
1
First Language
swedish
Primarily Uses
There's plenty of sites that can teach you Ruby.

Ruby - Code Academy

RubyLearning (how I got started)

Just to link two.  Google search for Ruby tutorials and you'll get a bunch of hits.  Also, looking at how other scripts function compared to how the core scripts function (especially if they alias or overwrite stuff from the core scripts) is a great way to learn how to script.
When I got to RM I already had a very basic idea of programming, but through making scripts and looking at others, I've managed to get really far. Once you get to understand the logic behind how a computer thinks, then you'll be able to apply it well.

Ruby is a very basic and easy to use language, so it should be easy for you to learn.

With all that said, once you learn variables, methods , and classes, I suggest you start making scripts for practice. You'll get better at it over time.
If you want to really learn to script, you need to learn to code.

First, forget about games. Just learn how a language works and how to use it making simple, console programs. The algorithms you learn will carry over into games scripting later on, but you've got to learn them 'in isolation' first. You can make console games like 'guess the number' or hangman or even tic-tac-toe if you want to learn some basic AI, but you've got to learn how to really use conditional branches, loops, basic data structures, Enumerators (very important in Ruby), and how Object Oriented programming works in general.
This thread helped me a lot with learning the basics of Ruby, still working hard to understand how to script but it is very hard... Difficult to imagine how the Variables, Modules, Classes etc are then used to actually do things in the game! I will keep going through the tutorial I have and hopefully it will make more sense with time.

Thanks djDarkX, Zalerinian and Mouser to name a few for some good tips/advice! :)
 

whitesphere

Veteran
Veteran
Joined
Mar 14, 2014
Messages
1,688
Reaction score
784
First Language
English
This thread helped me a lot with learning the basics of Ruby, still working hard to understand how to script but it is very hard... Difficult to imagine how the Variables, Modules, Classes etc are then used to actually do things in the game! I will keep going through the tutorial I have and hopefully it will make more sense with time.

Thanks djDarkX, Zalerinian and Mouser to name a few for some good tips/advice! :)
Here are some analogies:

Think of a Class as an object you can perform actions to, or ask questions of.  How the Class performs its actions and answers its questions is only known to the Class.  Anyone else only sees what the Class will do.  What a Class will do, and what questions it will answer, are its Methods.  So, if I provided you a Car for a class, you wouldn't need to know the type of engine, transmission or how the pieces work.  All you would see are the methods (actions or questions) available, such as:  start_car, turn_left, turn_right, accelerate_to(speed), slow_to(speed) and stop_car.  I might also provide some methods which tell you about the Car such as "is_running?" or "current_speed".   

Inside the Car class, I would have implemented the methods, but you would not need to know how the Car is doing what it's doing.  This is called "encapsulation" and is an important concept.  It makes the code easier to understand and protects the insides of the Car object.

The Class is a blueprint that describes how all instances of the Car work.  An Instance is a specific, actual Car.  So I could create, say, a Mazda and, say, an Oldsmobile.  Both would be instances of Car.  But obviously one Car might be running, and the other might not. But they would both support the same Methods.

Finally, a Module is merely a container for one or more Classes.  

How do you use them to solve problems?

Well, say RPG Maker has a Class called an Actor.  This can represent one of the PCs.  It has Methods to indicate its X,Y position on the map, the ability to see if the Actor has a certain State associated with it (i.e. the player has been Poisoned), the Max HP of the player, the current XP and Level, and so on.

Then there might be a Class called Party.  A Party is the current set of Actors the player can control.

If I wanted to move the party to a location on the map, I would call a Method on the Party (which has a set of Actors, one for each PC) to change the party's location to a different X,Y position possibly on a different map.

The Methods change the internal state of the object.  The net effect is the Party is now on the new X,Y position on the new map.

And, the player sees the party on the new map location.
 

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

Latest Threads

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
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

Forum statistics

Threads
105,868
Messages
1,017,072
Members
137,578
Latest member
JamesLightning
Top