Can anyone explain this method.

Status
Not open for further replies.

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
def make_command_list end #-------------------------------------------------------------------------- # * Add Command # name : Command name # symbol : Corresponding symbol # enabled : Activation state flag # ext : Arbitrary extended data #-------------------------------------------------------------------------- def add_command(name, symbol, enabled = true, ext = nil) @list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext}) endWhy method make_command_list is empty? Preserve for something?

:name  and :symbol? I went over that in ruby tutorial somewhere but can't remember. where is a constant?

what is ext = nil, what is with this whole line {:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext}

@list.push ? seem like append something in the list? 

That is the reason I am not fond to this Ruby language because two many ways to deal with one thing. Which often make confusion for newbies.
 

Dr.Yami

。◕‿◕。
Developer
Joined
Mar 5, 2012
Messages
1,003
Reaction score
757
First Language
Vietnamese
Primarily Uses
Other
You should learn more about programming, most of them are the basic things. Ruby is easy for newbies doesn't mean that newbies can use ruby without learning.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Window_Command does not add any commands to the list by default. Classes that inherit from it do. But since there's a call to that method in Window_Command.initialize, the method must still be there, even if it's empty. When a class inherits from Window_Command, the Window_Command.initialize will call make_command_list, and the inheriting class's make_command_list will be called. You will notice classes that inherit from Window_Command overwrite this method; they do not alias it, and they do not call super to process the parent's commands. So it's just a placeholder that says "when you make a class based on this, you have to have this method and you actually have to fill it in".


@list is an array. Its elements are hashes.


:name and :symbol are symbols. They are keys to the hash. So it's just adding a new hash to the array of hashes, where the keys are :name, :symbol, :enabled and :ext, and the values are what is passed in as parameters.


There's nothing wrong with the language. It's just that you've encountered some syntax that's unfamiliar to you, and there's a learning curve you have to go through. It would be exactly the same with you or someone else who's learning a new language other than Ruby and has encountered something unfamiliar for the first time :) No language can be picked up immediately by newbies. There is ALWAYS a learning curve, and even when you're comfortable with it, you'll still encounter things that you have to learn, simply because you haven't come across a need to use them yet.
 
Last edited by a moderator:

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
Thank you Shaz,

Yeh, I remember the Array. Now that recall my basic java that I have not been touching for years.

If I am not wrong the push() is built in Ruby which function to append anything after?

Another question  draw_text (). How many argument this method takes? I just checked Window_base draw_text takes almost everything.

Speaking Ruby, I'm not saying it is wrong. It makes thing more complicate. I checked out Python. The language structure is so easy to learn, straight to point, no bull=shiit.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
You need to go to the help file for that one.

def draw_text(*args) contents.draw_text(*args)endcontents is a bitmap (method create_contents), so you have to look at the Bitmap class's draw_text method.According to the help file, under Bitmap, this is the method:

draw_text(x, y, width, height, str[, align])

draw_text(rect, str[, align])

It can actually be called with a Rect object or with the location and dimensions.
 

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
Ok another question that we did not go to detail.

The hash that you mention earlier :name=>name

The colon I bold it. Is it an class instant inside the hash? it has defined as attr_asscessor :name somewhere else? then they put them inside the hash?

Seem need to open ruby book on hashes.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
: just means a symbol.


:name is just something that's used as a key. It could just as easily be "Name", 1, "name" or any string or constant value. There may be more to it, but I just see it as a nice, easy way to define what it is or what it's used for, without having to define string literals.


You would obtain the value using @list[index][:name] where @list[index] gives you the hash, and :name gives you the element in the hash.
 
Last edited by a moderator:

BadMinotaur

You can do it!
Veteran
Joined
Mar 13, 2012
Messages
260
Reaction score
115
First Language
English
Primarily Uses
RMVXA
: just means a symbol.

:name is just something that's used as a key. It could just as easily be "Name", 1, "name" or any string or constant value. There may be more to it,
I think it's this: when you run the script, symbols are assigned a unique integer value per unique symbol, and so comparisons using symbols really use integer comparison methods instead of string comparison methods (which are much slower). So symbols are a really fancy way of having string identifiers that act fast, which is why you see them in hashes all the time.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Speaking Ruby, I'm not saying it is wrong. It makes thing more complicate. I checked out Python. The language structure is so easy to learn, straight to point, no bull=shiit.
Python has a lot of BS as well. I thought Python was pretty awesome since it was my first language, until I learned more languages. Well, python is still pretty nice, but not for the reasons that most people bring up (when they compare it to ruby)
 
Last edited by a moderator:

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
Python has a lot of BS as well. I thought Python was pretty awesome since it was my first language, until I learned more languages. Well, python is still pretty nice, but not for the reasons that most people bring up (when they compare it to ruby)
You might have thanked to Python, because it made you understand Ruby much more easier that you did not realize. Considered people who happen to learn programming language which Python was not first. In this case I am, was frustrated as hell. I never have Python as my first language, I wish RPGmaker written in Python so I have reason to learn it, and does not have to deal with this confusion philosophy. I learn Ruby because I want to fulfill my gaming passion, which is making a game, no more use or no less for programming.

For newbie like me with very little knowledge of programming background, I looked at two sheet of programming languages written in Python and Ruby, which do the same thing I could understand Python much easier. 

Let take look at Ruby and its confusing syntax, the Array and Hashes why it is so confusing. You have attr variable defined as :name then you have another hash symbol just look that same which is :name that was why I was confused I thought they put the attr variable into the hash but in fact it is nothing but just key index.

Another thing which also very confusing you have Array defined as [ ] and Hash as { } they made Array and Hash to distinguish, GOOD,  but get confusing when both use the same way to access what I meant by that take a look at

Ruby   [1] = "something"

Ruby1 [1] = "something"

Can you distinguish the two which one is array and which one is hash let say if you dont know the Ruby1 really defined as Ruby1 = {}. They could make  things better if they have Ruby [1] and Ruby1 {1} since that was their intention in the beginning when they tried to distinguish these two with this [ ] and this { }
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Python supports the same thing.

myArr = ["one", "two", "three"]myDict = {1:"one", 2:"two", 3:"three"}myArr[1] = "something"myDict[1] = "something"print(myArr)print(myDict)If you don't understand certain Ruby syntaxes, then either read about it or ask someone.attr_reader, attr_writer, and attr_accessor are wonderful constructs. I don't understand what is confusing about them. If you're a beginner, then read about it and look at examples.

A symbol is a symbol, that's all there is to it. It's up to you to understand how it's being used.

If you have suggestions how to make it clearer then I suppose you could suggest it to the ruby community, since ruby is open-source, but the people who actually write programming languages can give you better reasons why they wrote it a certain way.
 
Last edited by a moderator:

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
In here, I only argue with you which langues is easier to learn, Python and Ruby and I pointed out some confusions which Ruby has for non-programmer like me.

If I am really some guru hard-core programmer or some Ruby developer, trust me I would contact the guy who develop this language to make improvement. In this case, I am not. I was some newbie and said that Python is much easier to learn than Ruby and you seemed to opposed that so I pointed out things I mentioned above.

Since I am not expert in Python and you have mentioned about Python Hash and Array are the same as Ruby then it is screwed. Since it's philosophy to make the language readable, avoid confusions.

Gods dont want my fate to be programmers otherwise I could contribute a whole lot of things for programming. Because, I could put all my time for something I really have passion to that including abandon my girl friends, my family, sacrifice my outdoor activity, my holidays just to do I have passionate for. . Unfortunately, my job is not a programmer. 
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
It's not because you're a non-programmer, it's because you're not a ruby programmer.

I didn't have any idea how symbols or attributes worked either until I read about it.

Anyone that just looks at a ruby script and tries to figure out how to write ruby is going to have the exact same questions as you: they see things like

Code:
attr_reader :name
And then think that's how symbols are used, and then have no idea why this works

Code:
h = {:name => "name" }
This is why people tell you to learn programming the "proper" way by understanding what a particular syntax means. And also why people discourage you from trying to pick up scripting by reading other scripts, whether you have a programming background or not.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Any language will cause confusion for a non programmer. Learning one language makes other languages easier to understand. Learning one thing WITHIN a language does NOT necessarily make other things in that same language easier to understand. You've just got to do it a bit at a time.
 

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
It's not because you're a non-programmer, it's because you're not a ruby programmer.

I didn't have any idea how symbols or attributes worked either until I read about it.

Anyone that just looks at a ruby script and tries to figure out how to write ruby is going to have the exact same questions as you: they see things like

attr_reader :nameAnd then think that's how symbols are used, and then have no idea why this works

Code:
h = {:name => "name" }
This is why people tell you to learn programming the "proper" way by understanding what a particular syntax means. And also why people discourage you from trying to pick up scripting by reading other scripts, whether you have a programming background or not.
I am not programmer, I dont know how I qualified to be programmer since I dont master any programming languages neither I write program for living. The first programming language that I ever took a basic course was C which was 10 years ago when I was in college and it was my optional course. I thought I can make game from it to fulfill my childhood passion but it is not as simple, required too much time. 

The second attempted to learn another programming language was 4-5 years ago when I find out a program to make games written in Python. I tried to learn python and found out "wow" so much easier. Yet, I ended up no time for that making game childhood passion. Whole lot of things out there to do in life. When I have sometime, attempt to fulfill passion again I found out RPGMaker

Tried to learn Ruby, so similar to python but more complicate when you read someone's scripts. You have to remember more than just one way to do things.

I don't know what you mean by learn the programming by proper way, I dont have time to be programmer or intend to making living with game. If I would want to be programmer or wanted to make living with making game, I would dive into C++ and Unreal Engine. 

The reasons I chose RPGmaker because it was made as toy for kids and for people with no programming knowledge. Many of RPGmakers are kids and non-programmers with different professions background, many dont have time to dive into hard core programming things, they want something grab and go. That's why I suggested Python for this maker. Simply it is easier for non-tech.

You on another hand suggest me to become programmer. Again, If ever wanted to be programmer to make game. C++ and Unreal Engine out there is way to go pal.

Here, I repeat again, I am argue with you which langue easier to learn for non-programmer Ruby vs Python. I am not argue which langue is more powerful or flexible....etc. You asked me why don't I learn the programming proper, I asked why don't you make things easier? Sure there is programming langue easier to learn than Ruby? Don't you agree? Or are you going to say that all programming langue have the same level of difficult to learn? I understand you are Ruby fan and you defended the language on other threads but hey am the beginner right here so I know best which language is easier to learn for someone not so much into programming.
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Being a programmer doesn't mean that you do it for a living or something... I think by "proper" it simply means like reading the available materials for Ruby (there are books available online for that)


Personally, I tried VB.NET,C#,C++,Phyton,Ruby,wc3's vJASS... and I'd say that I find .net and C# the easiest (but it seems they are not good for scripting, especially C# coz it was a compiled language), C++ was nosebleed for me, as well as phyton...


Anyway, it's just a matter of familiarizing yourself with it... We all have our preferred languages (mine being .NET and C#), but it shouldn't really keep you from learning others... :)


And this just my preference but, I like it better to be able to do things in multiple ways because it gives me more freedom...


Again, reading a reference material can help a lot...


and I guess one reason that might be keeping it harder for you is because you're always thinking that RM is "just a toy"... If you keep thinking like that, then you'll really get frustrated when you cannot figure something out because on the back of your mind you'll be thinking like "I'm an adult, why can't I figure out this toy???"

@list.push ? seem like append something in the list?
It's on the Array part of the help file, array.push(object) injects the object into the end of an array


So all in all, read the help file and read some online Ruby materials... :) \

def add_command(name, symbol, enabled = true, ext = nil)


@list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext})


end
ext is like a custom data holder in case you wanna have custom data associated with a command... I personally used it to save the skill ID on a custom command interface that I made...


and if you don't really want to learn RGSS or ruby, then simply stay away from the scripts... You don't really need them anyway if you just wanna "toy" with the maker and create simple games... there are lots that can be done even without scripts anyway...
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
@list.push is appending something to a list. To find out that it's an array, you need to go elsewhere in the script to see @list = []. So you don't necessary need to look at just one line to be able to understand something.


Just because you find Python easier to learn than Ruby, doesn't mean every other beginner programmer will feel the same way. Finding something easy or hard depends on your strengths and your weaknesses, and no two people will be the same. No point arguing about which is easiest, because there IS no "right" answer. There's just a right answer for you, but for someone else, the right answer will be different.


Anyway, I think this thread has well and truly served its purpose, so I'm going to go ahead and close it now :)


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Last edited by a moderator:
Status
Not open for further replies.

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,078
Members
137,580
Latest member
Snavi
Top