Main Menu
  • Welcome to The RPG Maker Resource Kit.

[REQUEST] scripting tutorials (advanced)

Started by Nexridia, March 28, 2007, 05:55:09 PM

0 Members and 1 Guest are viewing this topic.

Nexridia

is there somewhere a tutorial for advanced scripting?
i only found basic tutorials everywhere
what!? ur not supposed to see this!

Irock

You need to start with the basics and learn from them as the progress in difficulty.

:)

Watch out for: HaloOfTheSun

Kokowam

Omg! I forgot about that XD I'm going to try to learn scripting :]

:)

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.
Watch out for: HaloOfTheSun

Kokowam

Oh... Don't answer my question in the other thing.

:)

I did I think..I posted this before you posted to apply. =D
Watch out for: HaloOfTheSun

Kokowam

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

Zeriab

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
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
Wikipedia.org

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.

Nexridia

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
what!? ur not supposed to see this!

Blizzard

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 )
Get King of Booze for Android, for iOS, for OUYA or for Windows!
Visit our website.
You can also love/hate us on Facebook or the game itself.



Get DropBox, the best free file syncing service there is!

Kokowam

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?

Blizzard

#12
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.
Get King of Booze for Android, for iOS, for OUYA or for Windows!
Visit our website.
You can also love/hate us on Facebook or the game itself.



Get DropBox, the best free file syncing service there is!

Zeriab

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)

Blizzard

Get King of Booze for Android, for iOS, for OUYA or for Windows!
Visit our website.
You can also love/hate us on Facebook or the game itself.



Get DropBox, the best free file syncing service there is!

Nexridia

lol i will love it too! it sounds great! ok i will wait for your tut blizzard
what!? ur not supposed to see this!

Nexridia

sorry for double post but have you finished something more on your tut blizzard?
what!? ur not supposed to see this!

Blizzard

Get King of Booze for Android, for iOS, for OUYA or for Windows!
Visit our website.
You can also love/hate us on Facebook or the game itself.



Get DropBox, the best free file syncing service there is!