Scripting in RGSS Ruby for Intermediate and Experts

Started by Blizzard, January 07, 2008, 09:31:07 pm

Previous topic - Next topic

Blizzard

January 07, 2008, 09:31:07 pm Last Edit: October 19, 2021, 05:21:02 pm by Blizzard
Scripting in RGSS Ruby for Intermediate and Experts
½th Edition
Author: Boris Mikić alias Blizzard



This is the ½th Edition! There might be typing and other mistakes!

Contents:

1. Introduction
  • 1.1. Why RAM or CPU?
2. Compatibility
  • 2.1. Aliasing
  • 2.2. Thinking in Advance
  • 2.3. Names and Problems
  • 2.4. "Stack level too deep"
  • 2.5. RAM or CPU?
3. Data Processing and Storage
  • 3.1. Why "looping"?
  • 3.2. Why Methods/Functions?
  • 3.3. How to handle Data efficiently
  • 3.4. Module or Class?
  • 3.5. RAM or CPU?
4. Windows
  • 4.1. The Basics
  • 4.2. The wrong Way to create a Window
  • 4.3. Do they look nice?
  • 4.4. Window or Sprite
  • 4.5. HUD Basics
  • 4.6. The Problem with non-vital Information being displayed
  • 4.7. RAM or CPU?
5. Lag-weg
  • 5.1. Algorithm Complexity
  • 5.2. What lags and why it lags (RGSS specific)
  • 5.3. Decrease Process Time
  • 5.4. Don't fear more Code
  • 5.5. RAM or CPU?
6. Wannabe-Cool Scripting
  • 6.1. Scripts with {} Brackets
  • 6.2. One Line Functions/Methods
  • 6.3. Too many useless and pointless Things
  • 6.4. Too much SephirothSpawn
  • 6.5. Avoid being an Idiot
  • 6.6. Re-invent the Wheel
  • 6.7. Enforcing Standards
  • 6.8. Scripts the World doesn't need
  • 6.9. RAM or CPU?
7. Hints and Tricks
  • 7.1. Pen on Paper or train your Brain
  • 7.2. "Game_System" is your save data's best friend
  • 7.3. Boolean Algebra
  • 7.4. The evil Bug in "if" Branching
  • 7.5. First this or that? - When "if" goes crazy
  • 7.6. The Trick with "unless" - De Morgan's Law
  • 7.7. Comparisons
  • 7.8. Instance Variable Access aka Encapsulation
  • 7.9. Powerful implemented Iterator Method "each"
  • 7.10. Bug Hunter
  • 7.11. Global, Local, Instance Variable or Constant?
  • 7.12. Inside-Outside or Outside-Inside
  • 7.13. "Uh, what does this Knob do?"
  • 7.14. About Superclasses and Mix-ins
  • 7.15. NFS - Need for Sorting
  • 7.16. RAM or CPU?
8. Useful Links
9. Summary



1. Introduction

Are you reading this to learn how to script? Then this is NOT for you. If you want to understand this e-book fully, you need basic scripting knowledge. You can read this, of course, but you'll end up wasting your time by not understanding even half of it.
Instead, this e-book will teach you how to become a better scripter. There are far too many scripters who know just a few basics and in the best case they can make a CMS. I will teach you how to handle data, how to make windows look nice and handle them efficiently, how to avoid lag, how to hunt down bugs and how to not be an idiot when scripting. At the end of each chapter there is a little summary, also teaching you how to choose between RAM and CPU specific for that chapter.
Note that I will explain you several things, but these are only the basics. You can't become a better scripter just by reading this e-book, it will only give you a head start in becoming a better scripter. You simply can't become a better scripter without practical experience.


2. Compatibility

This chapter will show you how to make your scripts work with scripts of other scripters more conveniently. If you don't make your scripts compatible, most won't be used. If a user has three cool scripts from three other scripters that work together just fine and yours just won't fit in, he will kick yours most likely and keep using the other three. Another reason for compatibility is to save your time and effort. If your script doesn't work with another one, you will need time to merge it with the other ones for that user.
If your script can be configured and/or has options, make a working precondition and turn off all critical options that need to be first set up correctly by users. It's always a good idea to make your script work Plug 'n' Play as most people don't bother reading instructions.


3. Data Processing and Storage

In this chapter you will learn how to handle data and data processing. In other words, this chapter IS RAM or CPU. You will learn how you can decrease the number of coded lines.


4. Windows

No, it's not the operating system. This chapter will teach you how to handle windows, since they are actually consisting out of several sprites and sprites are the ones that can cause the most lag, especially if they are large.


5. Lag-weg

This chapter will teach you about the worst archenemy of every programmer and scripter: Lag. Lag-weg literally means Lag-away as weg means away in German.


6. Wannabe-Cool Scripting

You are a scripter/programmer, but before all, you are a human being like everybody else. There just are people in the world who seem to believe they would be better than other for either no real or some really idiotic reason. You won't come over as cool if you're being an idiot and rude to people. In this chapter we will work on your relations to the world around you, since it doesn't evolve around you: You evolve around it.


7. Hints and Tricks

This chapter will show you some interesting ideas how to make your scripts work faster, be more compatible, be shorter and on top of that have a cool and professional looking code. Most probably you will enjoy this chapter most as it teaches you actually something to script and doesn't teach you the theory behind all of it too much. This chapter also includes a lot of practical experience.


8. Useful Links

Since this e-book explains just a few basics, here are several links for those who are eager to learn more.

Ruby
http://en.wikipedia.org/wiki/Ruby_(programming_language)
Stack
http://en.wikipedia.org/wiki/Stack_(data_structure)
Recursion
http://en.wikipedia.org/wiki/Recursion_(computer_science)
Interpreter
http://en.wikipedia.org/wiki/Interpreter_(computing)
Compiler
http://en.wikipedia.org/wiki/Compiler
Machine Language
http://en.wikipedia.org/wiki/Machine_language
CPU
http://en.wikipedia.org/wiki/Central_processing_unit
http://en.wikipedia.org/wiki/CPU_design
Object-oriented programming
http://en.wikipedia.org/wiki/Object-oriented_programming
RAM
http://en.wikipedia.org/wiki/Random_access_memory
Array
http://en.wikipedia.org/wiki/Array
Hash
http://en.wikipedia.org/wiki/Hash_table
HUD
http://en.wikipedia.org/wiki/HUD_(computer_gaming)
Algorithm complexity
http://en.wikipedia.org/wiki/Complexity
http://en.wikipedia.org/wiki/Computational_complexity_theory
Logarithm
http://en.wikipedia.org/wiki/Logarithm
Boolean Algebra
http://en.wikipedia.org/wiki/Boolean_algebra_(structure)
Call by Value/Call by Reference
http://en.wikipedia.org/wiki/Evaluation_strategy


9. Summary

Don't compare yourself with other scripters. You might lose your motivation by thinking "I will never get as good as him..." On the other hand you could also DO compare yourself with other scripters. You might be the type of person who says "I want to do better. I can do better. I will do better." instead. It's up to you. None of the good and known scripters today was just born with his skills. He has earned them through work and experience. This e-book is a part of my knowledge as a gift to all of you. It's not only what I have learned from scripting in RGSS, it's also what I have learned from programming in general, from what I have been taught in college and from life itself. Every scripter is unique and his experience and skills are incomparable with the experience and skills of any other scripter. One day you will just realize "Hey, I became better than that other guy..."
The RPG Maker XP help file is always a big help when you get into a dilemma asking yourself "Can I do that?" or "Does that class support that?" or... That's why I have included an enhanced English help file with an extra chapter by an unknown author and the Scripts.rxdata with English commented code, improved iteration coding, recoded to avoid the built-in RGSS bug with conditioning and overworked code to shorten the and improve the code. Many of you might not have a legal copy of RPG Maker XP and therefore not the English files. But this does not mean that I encourage illegal copies! I only give support regardless of the fact that your copy is legal or not! If you like the RMXP editor and engine, buy it! Reading through the help file once completely will help you a lot. You will find many useful methods that can give you results, instead of using your own code for that. I also included a copy of the RGSS102E.dll
By reading this e-book I hope right now you got the itches to make something more than just a CMS. And even if it's a CMS, I hope its moving windows that move from behind a window to the side and then back over the other window will look cool, since they don't lag at all.


10. Download

Full e-book download link
e-book PDF ONLY download link
e-book DOC ONLY download link

If you have problems, you can also try the .txt file download:
http://www.megaupload.com/?d=18E7942R
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Fantasist

Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Nortos

can't wait for it I still haven't finished reading this one

Zeriab

Quote from: fantasist on January 08, 2008, 12:38:25 am
When will this be complete? (the 1st edition)

I am afraid Blizz is waiting for my review >_>

Fantasist

Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Nortos

How would I be able to make this a .txt file as my new mp3 only uses these ones to read and whenever I try to put it on notepad and save it as .txt says it can't use certain things in it and I save anyway and there's only two letters on the document CC...

Blizzard

Just paste it into a .txt file. The formatting will be lost, but you're gonna hear it, so who cares about the formatting. xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Nortos

January 12, 2008, 12:18:28 am #7 Last Edit: January 12, 2008, 12:19:51 am by Nortos
you don't hear it unless I'm gonna put it in text to speech but I would prefer to read it on MP3 screen :P I can't understand those microsoft voices...lol but if it's hard then I guess I'll just makedo unless it's just a quick 2-5minute thing

Juan

@Blizzard I can't open the Scripting in RGSS Ruby for Intermediate and Experts from the download. Something about can't load graphics message.
Dropbox Who need luck when you can make your own.
3ds Friend code: ShowHide
 4468 1422  6617

Calintz

I can't wait until I'm a high enuff lvl scripter to use this!!  ;D

Blizzard

Updated topic links. Try downloading the pdf instead, Juan.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Juan

@Blizzard 
I can't even open pdf file at all. Anything I need to download to view this?
Dropbox Who need luck when you can make your own.
3ds Friend code: ShowHide
 4468 1422  6617

Blizzard

January 18, 2008, 06:30:11 pm #12 Last Edit: January 18, 2008, 06:34:41 pm by Blizzard
You can either opne the doc or the pdf. You can open pdfs with Adobe Acrobat Reader or docs with Microsoft Office or Word Viewer.

Adobe Reader

Word Viewer
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Nortos

if u want me to upload the .txt document just ask

Juan

@Nortos Yea that would help.

@Blizzard I'm a limited account. I would need my dad to approve the download.
Dropbox Who need luck when you can make your own.
3ds Friend code: ShowHide
 4468 1422  6617

Blizzard

Ouch! I see... Alright, wait for Nortos' text version then. =/
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Nortos

here it's :) you can put in first post maybe Blizz, it's only the actual document so it won't have the other files Blizz put in it
It's megaupload sorry sendspace wasn't working for me atm
Rggs Blizz's Tut .txt file download

Juan

Dropbox Who need luck when you can make your own.
3ds Friend code: ShowHide
 4468 1422  6617

Nortos

it's cool if need it hosted on different site just ask

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.