Gw Temp

Menu

Tutorial - 'Menu Cursor Movement' by slackerboy

An item about RPGMaker 2000 posted on

Blurb

It’s slackerboy again with another tutorial. This one will help anyone making a CMS and/or CBS

Body

INTRO
It’s slackerboy again with another tutorial. This one will help anyone making a CMS and/or CBS. When you make a CMS or a CBS, you need some way to select commands. A common way to do this is by having a cursor, like an arrow, move up and down along the side pointing at the different choices. That is what I will explain here. It’s a simple bit of coding that you’ll need to master and become very familiar with, as it is a necessity with CMS’s and CBS’s. I’ll go more in depth in this tutorial, since it’s aimed more towards noobs or intermediate rm2kers.


THE PROCESS
The coding.... *sigh*.... the hard part.... Basically, you need to make it so it waits for you to press a key, then it runs through the appropriate code, then it repeats, unless you press enter or cancel (spacebar or esc). Firstly, make a cycle.

<>CYCLE
<>
<>END CYCLE

Inside the cycle, you need an enter password command with EVERY box checked. This makes it wait until you press any key before moving on. Don’t forget to choose a variable in the enter command dialogue window. Lets call that variable var[0001]CM for now. After the enter password command, you need 6 forks. The first one should be IF var[0001]CM = 1. The second one should be IF var[0001]CM = 4. The third one should be IF var[0001]CM = 5. And the last one should be IF var[0001]CM = 6.

<>CYCLE
<>Enter Password - var[0001]CM
<>FORK - var[0001]CM = 1
<>
<>END FORK
<>FORK - var[0001]CM = 4
<>
<>END FORK
<>FORK - var[0001]CM = 5
<>
<>END FORK
<>FORK - var[0001]CM = 6
<>
<>END FORK
<>
<>END CYCLE

This simply checks what button the player pressed. 1=down, 2=left, 3=right, 4=up, 5=enter (spacebar), and 6=cancel (esc). However, we don’t need left or right since the cursor is only moving up and down. Now, let me explain something about coordinates. In rm2k, coordinates are mapped from the topleft corner. What this means is that to move the cursor DOWN you add to it’s Y coordinate and to move it UP you subtract from the Y coordinate. Whenever you are in the event editor mode of rm2k, it shows the coordinates of the square you’re currently on. At this point, you’ll need to decide if you’re using a charset or a pic as the cursor. Charsets are easier to use as cursors than pics, just to let you know. If you’re using a charset, then the following applies to you. First, make 2 more variables: var[0002]handX and var[0003]handY. If you’re using pics, skip the next bit down to where it says “PICS”. Lets say that the different choices on this CMS are 1 square apart, going up and down. You’ll need to add 1 if DOWN is pressed and subtract 1 if UP is pressed:

<>CYCLE
<>Enter Password - var[0001]CM
<>FORK - var[0001]CM = 1
<>change var[0003]handY + 1
<>
<>END FORK
<>FORK - var[0001]CM = 4
<>change var[0003]handY - 1
<>
<>END FORK
<>FORK - var[0001]CM = 5
<>
<>END FORK
<>FORK - var[0001]CM = 6
<>
<>END FORK
<>
<>END CYCLE

Also, you may notice something is missing. The cursor doesn’t move at all! This is remedied easily. At the very top of the cycle, have a Set Even Place command that teleports the cursor event to coordinates var[0002]handX, var[0003]handY.

<>CYCLE
<>Set Event Place - cursor - var[0002]handX, var[0003]handY
<>Enter Password - var[0001]CM
<>FORK - var[0001]CM = 1
<>change var[0003]handY + 1
<>
<>END FORK
<>FORK - var[0001]CM = 4
<>change var[0003]handY - 1
<>
<>END FORK
<>FORK - var[0001]CM = 5
<>
<>END FORK
<>FORK - var[0001]CM = 6
<>
<>END FORK
<>
<>END CYCLE

You’ll also notice that the cursor can go up and down however far you want it to. You need to create boundaries. What you can do is make it so if the cursor is at the bottom and you press down, it goes to the top of the menu. Lets say we have 5 options. At the top of the list, the cursor is at coords 1, 4. var[0002]handX = 1 and var[0003]handY = 4. Make sure you NEVER change the X coordinate unless you want the cursor to move side to side. Also, the last option would be at var[0003]handY = 8. So, we need a fork to check IF var[0003]handY > (bigger than) 8 THEN var[0003]handY set 4. Very simple. Also, you can do the same in the fork for pressing UP: IF var[0003]handY < (smaller than) 4 THEN var[0003]handY set 8.

<>CYCLE
<>Set Event Place - cursor - var[0002]handX, var[0003]handY
<>Enter Password - var[0001]CM
<>FORK - var[0001]CM = 1
<>change var[0003]handY + 1
<>FORK - var[0003]handY > 8
<>change var[0003]handY set 4
<>
<>END FORK
<>
<>END FORK
<>FORK - var[0001]CM = 4
<>change var[0003]handY - 1
<>FORK - var[0003]handY < 4
<>change var[0003]handY set 8
<>
<>END FORK
<>
<>END FORK
<>FORK - var[0001]CM = 5
<>
<>END FORK
<>FORK - var[0001]CM = 6
<>
<>END FORK
<>
<>END CYCLE

PICS
For pics, do what s mentioned above, just you need to change some things. The Set Event Place command should instead be a Move Picture command with pixel-based coordinates, rather than square-based, if you know what I mean. Also, you’ll need to figure out the pixel distances between the choices on the list.

Isn’t that all so simple? Sometime before that cycle you’ll have to set what var[0002]handX and var[0003]handY start as. In the forks for var[0001]CM = 5 and var[0001]CM = 6, you’ll need to decide what happens when you press enter and cancel, respectively. Inside the var[0001]CM = 5 fork you’ll need to have forks that check what var[0003]handY is to see what choice the cursor is on. Also, in the var[0001]CM = 6 fork, you’ll need a break cycle command that leaves the cursor movement screen. On a CMS, it would exit the menu.


CLOSURE:
That’s pretty much it... I hope I didn’t forget anything... If I did, and/or if you have a question, just ask me. It’s a very useful bit of code that you’ll use over and over again making a CBS and/or CMS, especially a full CMS like I did =D. This is just one step towards making a great CBS and/or CMS, so code away and hopefully we’ll have more good CBS’s and CMS’s in the community!