HOW CAN I ELIMINATE LAG FROM THIS

Posts

Pages: 1
Blobofgoo
Legs are a burden. Return to snek.
2751
This is my code:

Which then activates this:


Their is lag when the event is called. I've tried many different things, but they haven't worked. It keeps making the game freeze for a little bit and then it continues. It freezes every 1 second because of the wait command. Does anyone have any ideas or anything?

EDIT: The first is parallel process
If this is in 2k/3, try adding wait commands (0.0) at the end of the timer code. It should help, even if it seems like it would do very little.
Blobofgoo
Legs are a burden. Return to snek.
2751
I've heard about that. I heard it doesn't work though. Also, I have no idea what to put it after. I realize you mean the first part, but I've no idea where in it.
No, I mean after the second part, which I assume is its own event. Even after each part, so after Timer, FOOD, WATER and the Update part.

And yes, it does work in 2k/3. Not so in the other makers, though it does help a little in them. Just try it out and see. (Not the first part since it already has a wait event in it, which should cut down on lag in that part.)
Blobofgoo
Legs are a burden. Return to snek.
2751
Thank you. I just threw in a bunch of them in random places. It's not eliminated, but it definitely helped. Not really sure why, but who cares!
It's just something that tends to work in 2k3 for some reason.
Logic? Nope. 2k3.

Also, you could probably throw one in the first code snippet too, just before the call Label. And make sure one is at the end of the longer code.
The thing that makes Rm2k3 lag the most are commonly showed pictures.

You might consider show the bars not every 1 seconds.
Blobofgoo
Legs are a burden. Return to snek.
2751
Well, it needs to at least check if the bars need to be updated every second. All the bars run on second timers. The intervals are 3, 5, 7, and 8. Not really sure how to code for it to check if it needs to update. (Food is 5 and Water is 7 btw)
Disregard. I have no idea why that is lagging for you. It should work fine. Then again, you mentioned before that your computer couldn't run GraphicsGale or Gimp, so it may be time to upgrade your PC from 1997.
are you testing in fullscreen? my game lags in windowed but is fine in fullscreen. and it's cause my PC is really bad/old. so yeah, you need to upgrade or develop a taste for lag.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
author=Blobofgoo
Well, it needs to at least check if the bars need to be updated every second. Not really sure how to code for it to check if it needs to update.

You need two variables for each resource instead of just one. One variable stores what the resource is right now, the other stores what it was previously. Each second, you will set the "previous" variable equal to the "current" variable, and then set the "current" variable equal to the new x-coordinate of the bar. And if after you do that, the two variables are the same, then you don't need to show the picture, because it's already in the right spot. If the two variables are different, you do need to show the picture in the new spot.

As far as 0 second waits, just put one at the end of every parallel process.
author=LockeZ
author=Blobofgoo
Well, it needs to at least check if the bars need to be updated every second. Not really sure how to code for it to check if it needs to update.
You need two variables for each resource instead of just one. One variable stores what the resource is right now, the other stores what it was previously. Each second, you will set the "previous" variable equal to the "current" variable, and then set the "current" variable equal to the new x-coordinate of the bar. And if after you do that, the two variables are the same, then you don't need to show the picture, because it's already in the right spot. If the two variables are different, you do need to show the picture in the new spot.

As far as 0 second waits, just put one at the end of every parallel process.


There is no need for 0,0 Second Waits as every Parallel Process has a break of 0,0 Sec (equals to 1/60 of a second) before it's been called again (not like Auto Starts - they don't have any form of wait). This is a proven fact that can be found out pretty easily.

(I'm just saying this as the additional wait of 1/60 in this cycle will turn a minute to have 61 seconds and make the timer pretty unreliant).

But I give blobofgoo a strong advice: try out your script without any pictures at all. I'm pretty sure you won't notice any form of lag. And then follow LockeZ's advice and only change pictures when something new is going on like the state of the var before and after the change of values.
Well, the thing is, Itaju, that it actually does something that helps in some way to alleviate the lag - hence why it's been a valid work around for years. Maybe it has something to do with the version of 2k/3 used - I know there are a few out there. Maybe it just helps in some small way. All I know - and he said himself - is that it works. Maybe not incredibly well, but it helps a bit.
I find this myth of "add a 0.0 wait at end of parallel processes" somewhat amusing, like it's some kind of magic which decreases lag. To see advice like this in such a case is especially amusing since it's effect is obviously going to be neglible.

Adding a wait in an event decreases lag because it may decrease the load of what the maker has to do within a single frame, and since this tiny event script is only executed once every 1 second, its not really going to do anything, but slow down how often the event is executed.

So yeah, as some people have mentioned couple of times so far, the pictures are probably the problem. You could start by taking the two static pictures out of the update loop. Picture 1 and 6 doesn't ever change, and thus don't need to be updated along with the rest. Move it out of the event, and show them at some other point.

More or less the same with picture 2 and 3. You never change the picture, only the coordinates, so change this to "move picture" with a 0.0 wait and with the "wait until moved" unchecked. This is significantly more effective than using "show picture". Just make sure to show the pictures once first in a separate instance, preferably at the same time as with picture 1 and 6.
author=Liberty
Well, the thing is, Itaju, that it actually does something that helps in some way to alleviate the lag - hence why it's been a valid work around for years. Maybe it has something to do with the version of 2k/3 used - I know there are a few out there. Maybe it just helps in some small way. All I know - and he said himself - is that it works. Maybe not incredibly well, but it helps a bit.


Placebo!

:D

Well, of course it helps. It makes the lag occur about 1/60 of a second less per cycle. :)
author=Itaju
There is no need for 0,0 Second Waits as every Parallel Process has a break of 0,0 Sec (equals to 1/60 of a second) before it's been called again (not like Auto Starts - they don't have any form of wait). This is a proven fact that can be found out pretty easily.


it's even easier to prove that adding a 0.0 wait to something that is lagging, will reduce/eliminate it's lag in most cases.

there's an article here that explains why. wasn't that written by you, Kazesui? but yeah, like he said, if there is already a wait(of more than 0.1, in my experience), there is no need to add another wait.

anyways, this lag is most likely caused by a shitty computer. I'd be willing to bet anyone who tries to create the same code won't see lag. it's a frickin' show picture command every whole second!
Blobofgoo
Legs are a burden. Return to snek.
2751
I changed the show pictures to move pics and the lag was eliminated. I also took out all of the wait 0.0 secs commands. Now I have come to a new problem. When I use a teleport event, the pics disappear and don't come back (it's trying to move pictures that aren't there). How can I code it so it reshows pics when a teleport occurs?

Above the line is the parallel process. Below it is the called event.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
author=blobbagoo
How can I code it so it reshows pics when a teleport occurs?

Well.

Go to the place in your code where you have the teleport command.

And then put a show pic command after it.
author=LockeZ
author=blobbagoo
How can I code it so it reshows pics when a teleport occurs?
Well.

Go to the place in your code where you have the teleport command.

And then put a show pic command after it.

Better yet, make show pic a common event and then just call the common event after the teleport, so if for whatever reason you need to change the image itself, you only need to edit the common event. With the

Edit: This is more complex, but another thing you could try doing is utilizing a parallel process common event. If you have an existing one already in use, add code to that, otherwise make a new one. Create 3 variables to start with: one to store the Map ID (V0001), one to store the player's X coordinates (V0002), and one for Y coordinates (V0003). This has tons of uses, but our purposes you can create a Map ID check that switches on/off and shows your pics every time you arrive on a new map. Additionally, you could add map exceptions (world map, cutscenes,etc) this way. So basically what will happen is that those 3 variables will refresh constantly. This shouldn't create lag, but if it does, you can reduce this by adding a Wait:0.0 command after the 3 variables.

Next, in the same parallel process, you'll want a 4th variable that makes a copy of MapID every time you reach a new map (V0004). The logic would be:

Conditional branch: If V0004:MapIDcopy does not equal V0001:MapID
Call Common event: Show Pictures (this will be your show picture event)
Set Variable: V0004 = V0001
Else
Wait: 0.0
<>

I forget the exact numbers, but the purpose of the Wait:0.0 commands are important because they're technically waiting for 0.01 seconds (maybe 0.05?), and without them, the cpu would be going through instructions even faster, potentially creating lag if it has to run through a conditional branch 1000+ times a second. With a Wait:0.0 command, you're actually reducing it.

The end result of this should make your show pictures completely automated. You won't have to worry about adding anything in teleport events.
Pages: 1