The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Tutorials and Eventing => Topic started by: Nexridia on March 28, 2007, 05:55:09 PM

Title: [REQUEST] scripting tutorials (advanced)
Post by: Nexridia on March 28, 2007, 05:55:09 PM
is there somewhere a tutorial for advanced scripting?
i only found basic tutorials everywhere
Title: Re: skripting tutorials (advanced)
Post by: Irock on March 28, 2007, 05:56:22 PM
You need to start with the basics and learn from them as the progress in difficulty.
Title: Re: [REQUEST] scripting tutorials (advanced)
Post by: :) on March 28, 2007, 11:43:20 PM
you can sign up for lessons here:

http://rmrk.net/index.php/topic,11045.0.html
Title: Re: [REQUEST] scripting tutorials (advanced)
Post by: Kokowam on March 29, 2007, 12:08:45 AM
Omg! I forgot about that XD I'm going to try to learn scripting :]
Title: Re: [REQUEST] scripting tutorials (advanced)
Post by: :) on March 29, 2007, 12:10:14 AM
Quote from: mastermoo420 on March 29, 2007, 12:08:45 AM
Omg! I forgot about that XD I'm going to try to learn scripting :]

darklord is no more teaching basic. so you would need to start higher. since this request was for advanced I thought the person wouldn't mind signing up for blizz.
Title: Re: [REQUEST] scripting tutorials (advanced)
Post by: Kokowam on March 29, 2007, 12:14:36 AM
Oh... Don't answer my question in the other thing.
Title: Re: [REQUEST] scripting tutorials (advanced)
Post by: :) on March 29, 2007, 12:18:22 AM
I did I think..I posted this before you posted to apply. =D
Title: Re: [REQUEST] scripting tutorials (advanced)
Post by: Kokowam on March 29, 2007, 12:20:53 AM
Argh. The whole "when I posted, when you posted" is confusing me. And I can't seem to find any more basic tutorials. All the tutorials are more into teaching on making a CMS (and only that >_>) than really teaching lots about something or a little about everything. Plus, the thing on dublealex/creation asylum is never updated. WAHHHHH T_T XP
Title: Re: [REQUEST] scripting tutorials (advanced)
Post by: Zeriab on March 29, 2007, 05:38:08 PM
I have written a tutorial about recursion, which probably is my most advanced scripting tutorial: http://z.crankeye.com/index.php?option=com_content&task=view&id=16&Itemid=29
It is one of the first I wrote, so it bears certain marks.

I haven't really written many scripting tuts, and besides whatever is posted at z.crankeye.com are the two tutorials I made for xLeD:

[spoiler=xLeD's 1st tutorial - Simple Sorting]
[size=15]Lesson 1[/size]
[size=10]Today's topic: Simple Sorting[/size]

Hey xLeD

First of I will start with a little something I have written about Arrays. Just skip what you know.
Then I will teach you the search algorithm Insertion-Sort.

Quote[SIZE=8]Array[/SIZE]
Just skip the parts on theory you don't understand. I will not use pictures.

Theory
An array is a list of elements. A vector of elements is also correct. Just a different wording.
Let us assume that the elements are integers (whole numbers).
Try to think of a table with 1 column and a number of rows, let's say 10 rows.
In each cell is an integer. This integer is what is meant as an element. This is how the data is stored
There are 10 integers (elements) in all because there are 10 rows. This is an array with 10 elements.

Let's go back to the rows again and say we want 1 of the integers out from a certain cell.
We must have a way of finding the right cell. We have. It is called the index.
Think about us looking on the top row. Think that if you look at the bottom cell it will be farther away than the top cell. You can say that there is a distance between a certain cell and the top cell.
We can use this distance to get the cell we want. We could say that we wanted the cell with distance 5.
The top cell would of course have distance = 0 and the bottom cell would have the amount of elements - 1. Continuing the example the bottom cell would have distance = 9
Wow... amount of elements - 1... What does that mean?
Remember when we said that there were 10 rows? This is the amount of elements.  So we have 10 - 1 = 9.
If we now call distance for index you we have solved the question about what index means.

I hope it was understandable

Ruby
All the above might be very well, but it does not explain how to you it in ruby.
In Ruby everything is build of objects, which are created from classes. So naturally there is an Array-class.
Before going further I must point you to Ruby references on the Array-class (http://www.rubycentral.com/ref/ref_c_array.html)
The above is just basically the syntax with comments.  Therefore you should read there instead of here.
Just a quick example though: (Same elements are allowed)
[6, 2, 4, 9, 2]   #<--- is an array
array = [6, 2, 4, 9, 2]   #<---- for before

# Getting the elements out
p array[0]  #---> 6
p array[4]  #---> 2
p array[5]  #---> nil

# A little trick
p array[-1] #---> 2
p array[-2] #---> 9

# -1 returns the last element in the array
# -2 returns the element before the last element and so on


I don't know what else there is to say as most of it is in the references.
Just ask if there is something you can't understand in the references.

References
Ruby references (http://www.rubycentral.com/ref/ref_c_array.html)
Wikipedia.org (http://en.wikipedia.org/wiki/Array)

Insertion-Sort:
Let A be an array. The pseudo code for the algorithm is:
Insertion-Sort(A)
1  for j = 2 to length[A]
2      do key = A[j]
3          i = j - 1
4          while i > 0 and A[i] > key
5              do A[i + 1] = A[i]
6                    i = i - 1
7          A[i + 1] = key


Is it difficult to understand?
You should note that pseudo code isn't just pseudo code. This is my version of pseudo code.
Note that how much they are indented tells in which branch they are in.
For example is line 7 not in the while loop, but in the for-loop.
Line 6 is however in the for-loop.
And so on...

I know I haven't explained it well, and for that I apologize.
I have saved it for the tasks. You'll see ^_~

The tasks:
Reading is good, but alas reading alone is not as giving as tasks to follow up the read text.
Task 1:
A = [7, 12, 30, 12, 6, 29]
Put this array into the algorithm.
Calculate manually what A each time it is at the start of the for-loop.
Also calculate the output. (The sorted array).

Task 2:
Implement the algorithm into RMXP. Yup write it in Ruby.
Use the example from above to test.

Task 3:
Rewrite the algorithm so it sorts in decreasing order instead of increasing order.
In Ruby I mean.

Task 4: (optional)
Make the insertion sort as an extension to the Array class.
That is make a method insertion_sort that can be called like this:
[7, 12, 30, 12, 6, 29].insertion_sort
Good luck with the tasks.
- Zeriab

Sources:
Recursion @ Wikipedia - http://en.wikipedia.org/wiki/Insertion_sort
Introduction to Algorithms - http://mitpress.mit.edu/algorithms/
My head - Sorry, no link to my head
[/spoiler]

I have attached the second one, which is in my opinion easier.


I don't really know how difficult the stuff I've made is, so sorry if it's too hard or too easy.
Title: Re: skripting tutorials (advanced)
Post by: Nexridia on March 31, 2007, 10:17:32 AM
Quote from: Irockman1 on March 28, 2007, 05:56:22 PM
You need to start with the basics and learn from them as the progress in difficulty.

no problem i know basic skripting already :P i can make scenes and cms.
i want to get better!
thx for everybody posting ill search more
Title: Re: [REQUEST] scripting tutorials (advanced)
Post by: Blizzard on March 31, 2007, 11:27:56 AM
Hold your breath until I finish my scripting tutorial.
... maybe better don't... You might die until it's finished. :B

(BTW, it scripting with a c =P )
Title: Re: [REQUEST] scripting tutorials (advanced)
Post by: Kokowam on March 31, 2007, 11:44:31 AM
Lol. I noticed that too :P Anyways, OMFG!!! A scripting tut by Blizzard? :D Should we get our hopes up on having it finished before May? :P Also, what's it going to teach?
Title: Re: [REQUEST] scripting tutorials (advanced)
Post by: Blizzard on March 31, 2007, 12:04:16 PM
Here's the contents list.

QuoteContents:

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. Tricky Bitmaps
4.5. HUD Basics
4.6. The Problem with non-vital Information being displayed
4.7. RAM or CPU?
5. Decrease the Lag
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. On Screen
5.6. RAM or CPU?
6. Compact Code or just wannabe cool Scripting?
6.1. Scripts with {} brackets
6.2. One line functions
6.3. Inefficient RAM usage
6.4. Too much Code
6.5. Too many useless and pointless things
6.6. Too much SephirothSpawn
6.7. Avoid being an Idiot
6.8. Re-invent the Wheel
6.9. Enforcing Standards
6.10. Scripts the World doesn't need
6.11. RAM or CPU?
7. Hints and Tricks
7.1. Train your Brain
7.2. First this or that?
7.3. The Trick with "unless"
7.4. Class Variable Access
7.5. Bug Hunter
7.6. Global, Local, Class Variable or Constants?
7.7. Superclass
7.8. Comments and Debug
7.9. RAM or CPU?
8. Useful Links
9. Summary

The red stuff needs to be done yet.
Title: Re: [REQUEST] scripting tutorials (advanced)
Post by: Zeriab on March 31, 2007, 08:17:15 PM
I love some of the section names.

Especially 5.4. Don't fear more Code and 6.7. Avoid being an Idiot
I like sound of chapter 6 XD

@Blizz:
Just tell me if you want some help be it to proofread or whatever.
I got the writer's block with the tutorial I'm making, so doing something else might loosen it up ^_^

@Nexridia:
I guess you just have to do with what you can find of basic tutorials until Blizzard releases his.
Then again... As you know the basics you can try to search for some object-oriented programming tutorials. (Or OOP tutorial)
Title: Re: [REQUEST] scripting tutorials (advanced)
Post by: Blizzard on April 01, 2007, 11:37:48 AM
I think you will love the tute. ;8
Title: Re: [REQUEST] scripting tutorials (advanced)
Post by: Nexridia on April 12, 2007, 07:29:09 PM
lol i will love it too! it sounds great! ok i will wait for your tut blizzard
Title: Re: [REQUEST] scripting tutorials (advanced)
Post by: Nexridia on April 12, 2007, 07:29:33 PM
sorry for double post but have you finished something more on your tut blizzard?
Title: Re: [REQUEST] scripting tutorials (advanced)
Post by: Blizzard on April 12, 2007, 07:34:27 PM
Erm, no... not yet... (-_-')