Topic: Wicked Lag (Read 91 times)

  • Avatar of drenrin2120
  • Contemporary Composer
  • Group: Member
  • Joined: Sep 3, 2006
  • Posts: 13
So, I'm making a cbs in rm2k/3. Everything was going well until I got to the magic HUD. There are 60 possible skills. The HUD is composed of two columns, each column displays 10 skills vertically at a time(FF style). Scrolling through the list is okay, it's a little buggy and a little laggy, but not too bad. The problem is when autoscroll comes into play. The lag is abominable!

I'd post the whole event but it's too damn long. Which I know is the problem (being too long). Here's basically how it works.

There are five different events that take part in displaying the Magic HUD. The most important event takes into consideration what keys the player is pushing. We'll call this event, KEY INPUT This event just changes a few variables around. It is a parallel process.

The second event is called by KEY INPUT when it is need, it determines what HUD to display based on the variables the first event is giving it. We'll call this event HUD DISPLAY. It is inactive (not parallel).

The third event is also called by KEY INPUT when it is need. Except, this event determines where to place the Arrow display based on variables it's been given. We'll call this event, ARROW DISPLAY. This event is inactive.

The fourth event is the AUTO SCROLL event. It has two pages. The second page is a parallel process, it is activated by a switch when either the Item or Magic Menu is opened. Very simply, it acts independently of KEY INPUT. It merely waits until the player has held a key down for about a second, then auto scroll takes over, zipping through the list at an item every .0664 of a second. (I think, that is if 0.0 wait is equal to .0166)

Now, the fifth event causing all the lag, we'll call it LIST DISPLAY, is inactive. It is roughly 580 conditional branches long and changes 20 pictures at a time. This is due to the way I have the system set up. In the Magic HUD, there are a maximum of 20 items that can be displayed at any given time depending on what skills the character has learned. The pictures themselves don't move when the player pushed up/down. Instead, the pictures change their appearance to give the affect of a scrolling list.

LIST DISPLAY is called every time the player pushes the up/down arrow. That means, when AUTO SCROLL is doing its thing, LIST DISPLAY is being called every .0664 seconds (in theory). Obviously, even when I was scripting all this, I had some concerns about lag. But I didn't think it would be this bad.

I was hoping the problem was in the amount of conditional branches the system was running through in a short amount of time. I was wrong. I tested this theory by breaking LIST DISPLAY up into 4 pages. Each page was only capable of displaying a range of items and each page was called accordingly, thus cutting down the amount of conditional branches the system had to work through from about 580 to 150 (at a time).

But this didn't reduce lag.

I'm thinking it has to do with the 20 different "show picture" commands happening x amount of times a second. But I just can't figure out how best to implement a list system.

*TLDR

My list display is too slow and I think the way I set it up is inefficient. What can I do to reduce lag? Or, is there a tut out there that describes a better way of creating a list in rm2k3?

BTW, hi! I made an account here years ago and didn't post much.

Any help or suggestions would be god sent. Thanks for reading the whole thing if you did and I hope that's enough information.
Last Edit: November 18, 2010, 06:09:59 pm by drenrin2120
  • It's coming along nicely...
  • PipPipPip
  • Group: Premium Member
  • Joined: Nov 30, 2005
  • Posts: 384
A wait 0.0sec could accompany just about every picture command. It will reduce script lag, but might increase the time for scrolling more than you want.

Typically lag is directly related with pictures. At least this is what happens in my own experience. Any move picture command I put in my game is either followed by a wait 0.0sec or is checked for Wait Until Done (or whatever it says in the move command).
Sweet online game in alpha.
http://trisphere-rpg.com/index.php?refer=bucchus