RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
How do you even learn how to do anything?

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 83
I've been learning Ruby, and thank god I used to program in the past or I would be completely lost... the concepts of it are easy enough, and I think it is like a combination of C and Perl (maybe). But even so, doing something in Ruby is one thing... when I go into RPG Maker VX and try to examine the scripts in there and figure out what is going on, I have to say... I don't have a clue. Not much of one. It also seems to me that there are classes that you cannot see, that use variables that are nowhere to be found. That could just be me, but am I right?

Anyway, how did any of you figure out how to do much of anything in RGGS2? I see some pretty amazing scripts in here, in my opinion... but I have yet to see a RGGS2 tutorial. Anywhere. And I wish I could figure out things from the Help file in RPG Maker VX, but it's not working out for me. With the combined know-how in here, I'm surprised no one has written more how to make scripts... I just gotta know... how did you? How can I? Am I hopeless? Probably...

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Nah, nobody's hopeless :)

There are some hidden classes, but the Help file will list all of the useful public methods and variables that are accessible from those classes. So for something like the Bitmap class, all you need to do is open up the Help File to see what you can do with it.

As for starting, I first started by rearranging things in default scenes. Easy enough, all it required was changing some numbers. The first script I wrote was one that gave monster troops levels and restricted random encounters to only bring troops whose level was in the vicinity of the party. This was a poorly written script, but I eventually fixed it :)

Anyway, I wrote a couple more bad scripts before another scripter found me and taught me, for which I am eternally grateful :P You might not have the luck to get a teacher like I did, but the first place to start is to just look through the default scripts, mess around with things and see what changes when you change things, and frequently consult the help file. It is tedious, but once you get a good idea of what things do, then you will quickly get the hang of it.

One thing that might be an idea is to look at the Game_Interpreter class. This is the class that runs events (that's not wholly accurate, but it's good enough for now), and each of the event commands has a corresponding entry in this class. Thus, if you know what event commands do, then looking at the corresponding command in Game_Interpreter will teach you how to do those things in a script.

Once you get a basic understandng of scripts, then it's just practice, practice, practice :)

**
Rep: +0/-0Level 83
What led me here was looking around to see if it were possible to have a charset bigger than 3x4... all I wanted to know was if it were possible to do this, and apparently you had already written a script for this. The problem for me was not being able to figure out how the original script was drawing the character animations... there seemed to be variables with values carried over through arguments, but there was apparently no way to find the original value... I can only guess that the script loads the character file, chops it up into equal rectangles and places these in a sequence. Damned if I can figure it out. I must have been on the right track though because in your script you have re-written the methods I was tampering with. I wasn't very successful :p I couldn't even figure out what this did...

       sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
        sy = @tile_id % 256 / 8 % 16 * 32;

From the original def update_bitmap in Sprite_Character.. couldn't figure out where @tile_id was coming from, what it was, or what this math formula was doing. My guess is dividing up the .PNG file and finding the x,y coordinates for the next rectangle (frame of the sprite). I'm probably completely wrong.

I will definitely check out the Game_Interpreter class, thank you. Here's hoping one day I can take a look at these scripts and completely understand how they work.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, one useful skill that you can learn is how to trace the definition of a variable back to its source. So, to use your example:

@tile_id is set on line 80 of Sprite_Character:

Code: [Select]
      @tile_id = @character.tile_id

@character is set on line 24 of Sprite_Character:

Code: [Select]
    @character = character

The local variable character is an argument passed when initializing a new instance of the Sprite_Character class (line 22):

Code: [Select]
def initialize(viewport, character = nil)

The character = nil means it will default to nil if no argument for character is passed. When it is passed, however, we see from line 20 that it is a Game_Character object

Code: [Select]
  #     character : character (Game_Character)

Going in to Game_Character, you find several instances of the line:

Code: [Select]
    @tile_id = 0

Now, it looks like a dead end, since obviously if tile_id were always only 0, it wouldn't be a variable. So the first thing to check is if @tile_id is writable from without the class. Going to line 17, we see:

Code: [Select]
  attr_reader   :tile_id                  # tile ID (invalid if 0)

This means that you cannot alter @tile_id from without the class.

Spoiler for Side Note:
(Aside: having attr_reader is essentially equivalent to including a method in the class like this:

Code: [Select]
def tile_id
  return @tile_id
end

attr_writer is essentially:

Code: [Select]
def tile_id= (value)
  @tile_id = value
end

attr_accessor is both)

Ok, so this seems like a dead end, but it isn't. Game_Character is a superclass after all. Game_Event, Game_Vehicle, and Game_Player are all subclasses of Game_Character, which in its simplest reduction means that each of the subclasses includes all the methods of the superclass. This means that if @tile_id is altered in any of those, then that is what is passed from that instance of the class. So @tile_id is not mentioned in either Game_Player or Game_Vehicle, but it is in Game_Event. At line 90, we see this again:

Code: [Select]
      @tile_id = 0

But at line 99 we see:

Code: [Select]
      @tile_id = @page.graphic.tile_id

So what is @page. As we see on line 143:

Code: [Select]
    if new_page != @page            # Event page changed?

@page is an event page object. Here we turn to the help file. We search event page, and it comes up with RPG::Event::Page. There we look up graphic:

Code: [Select]
graphic
The event graphic (RPG::Event::Page::Graphic).

We then go to RPG::Event::Page::Graphic

Finally we come to:

Code: [Select]
tile_id
The tile ID. If the specified graphic is not a tile, this value is 0.

Thus, if the graphic of an event is from the tileset, the tile_id refers to which tile it is.

 Note: This is actually a much longer trace than would normally occur. In truth, the first step you should take when you come across something foreign is to search in the Help File, and trace only if that doesn't answer your question. Tracing is useful for things that aren't in the help file though.

So now that we know that, we can return to the primary problem.

Code: [Select]
        sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
        sy = @tile_id % 256 / 8 % 16 * 32;
        self.bitmap = tileset_bitmap(@tile_id)
        self.src_rect.set(sx, sy, 32, 32)

If you count the number of tiles in any of the TileB and up tiles, you will find there are exactly 256 tiles in each. They don't take much care to separate order of operation in these lines, so the order for the sx calculation is basically:

Code: [Select]
a = @tile_id / 128
b = a % 2
c = b * 8
d = @tile_id % 8
e = c + d
f = e*32

for sy:

Code: [Select]
g = @tile_id % 256
h = g / 8
i = h % 16
j = i * 32

So let's say we take a @tile_id of 2, which we know should be the sign of a sword and shield on TileB.

for sx:

Code: [Select]
a = 2 / 128 = 0
b = 0 % 2 = 0
c = 0 * 8 = 0
d = 2 % 8 = 2
e = 0 + 2 = 2
f = 2*32 = 64

for sy:

Code: [Select]
g = 2 % 256 = 2
h = 2 / 8 = 0
i = 0 % 16 = 0
j = 0 * 32 = 0

So sx = 64, and sy = 0. Thus, these are the x & y coordinates of the tile with that ID. You can try this with others if you like, but the point is that the two lines in question retrieve the x & y coordinates of the tile with that ID.

Then:

Code: [Select]
        self.bitmap = tileset_bitmap(@tile_id)
        self.src_rect.set(sx, sy, 32, 32)

That retrieves the bitmap of TileB from the cache (you can look at the method tileset_bitmap in Sprite_Character to see how) and the second line takes only the tile as identified by @tile_id.

So there, that's what those lines do. It seems like it takes a long time typing it out like this, but in reality it takes a couple minutes max.

I hope that helps. So yeah, that's what those lines do, and they have no relevance to what you want to do, but hopefully that will help you in the future.



**
Rep: +0/-0Level 83
Holy..... crap... I think my understanding of this went from 2% to at least 70%, give or take... just from your explanation... I didn't know you could look up variables in the Help file, either... don't know how the hell I missed that. so character index [0, 1, 2, 3, 4, 5, 6, 7] means which character in the character file (unless it starts with a $, I suppose). 8 characters can fit into one of those, and seeing as how they're 96 pixels wide...

so pattern [0, 1, 2] would be... which position from left to right?

I'll have to wrap my brain around this some more, but this is a pretty good start if you ask me.. thank you, so much!