ID:1055832
 
(See the best response by Super Saiyan X.)
Code:
var/tmp/def = 75 //Default CPU Usage, this is when the CPU reaches a certain maxpowerlevel, and goes into affect.
var/tmp/lagset = 0 //Custom Variable, if it is 0, default will be in affect, if 1 you will need to set the clag variable.
var/tmp/clag = 0 //Custom CPU Usage, this is when you select during you game play at what maxpowerlevel you want to put the Lag Guard into affect.
var/tmp/tick_mem = world.tick_lag //Your default tick lag

world
proc
Lag_Guard()
spawn while(1)
if(lagset == 0)
if(world.cpu >= def)
world.tick_lag += 0
world.tick_lag = round(world.tick_lag)
if(world.cpu < def)
if(world.tick_lag == tick_mem)
..()
else
world.tick_lag -= 0
world.tick_lag = round(world.tick_lag)
else
if(world.cpu >= clag)
world.tick_lag += 0
world.tick_lag = round(world.tick_lag)
if(world.cpu < clag)
if(world.tick_lag == tick_mem)
..()
else
world.tick_lag -= 0
world.tick_lag = round(world.tick_lag)
sleep(50) //Checks every 3 seconds



world
New()
..()
Lag_Guard()


Problem description:So the game I've been trying to run suddenly developed this weird tick tock lag. Server efficiency seems to be running perfectly fine, there is no "lag", so I am assuming it is a programming issue. I had not had this problem before, it just kind of showed up. Whenever you move, the movement seems ticky, like a robot that needs oil. I wouldn't know how else to explain this.

Best response
I believe the fix for this issue would just to be...taking this entire portion of code out. It's pointless.

This kind of 'lag guard', and potentially all 'lag guards' are ineffective, and could actually screw up the game. The cause of lag could be a network thing on the side of the server, or the client. There's no real way for the programmer to properly diagnose that. Other than that, it could be an issue somewhere in the program. Check the Profiler to see what's taking up a lot of memory, or taking an extra long time to do.

CPU is not a good determinant for this kind of thing, and tick_lag is an essential part of the engine, changing it can effect loops, movement, and so on. This 'lag guard' also adds an extra process to the world, which could also cause lag.
That didn't really solve the problem either. I run the game through Virpus, but we haven't had a problem with it in months. Anything else I could potentially do?
In response to Super Saiyan X
Super Saiyan X wrote:
I believe the fix for this issue would just to be...taking this entire portion of code out. It's pointless.

This

Super Saiyan X wrote:
Check the Profiler to see what's taking up a lot of memory, or taking an extra long time to do.

Do those steps Virpus are known for terrible servers perhaps someone is abusing the network.. wouldn't surprise me I used torrent programs for months and they didn't even care.
Alright,

One more thing, could it be possible for the tick lag to appear by doing something with the map?

My friend pointed out that his started doing it too (in his computer) after editing the map and not the codes.
What kind of map editing did he do? Are you looping through any kind of atom constantly?
Simply edited the map through the same byond engine ".dmp". and if you want specifics, just added and removed shit from the map.

I just set the loop check to 1 to help me out there, but other than that, no.

*note, I am a beginner programmer who finished reading the DM guide and has been reading other tutorials and experimenting on my own.
Nothing in the profiler goes about 0.1 "self CPU", "Total CPU", and "Real Time"

Although the calls do steadily rise, but its something its always done, and has never given me a problem before.
If you disable your current map, and use a map with only a basic tile on it, does the issue still occur?
surprisingly, it does not.
So it turned out that nudging around stuff causes issues to the whole game. I don't know why, but it just did in our case. Wasn't a server or coding issue.
In response to Chiwy8
Chiwy8 wrote:
So it turned out that nudging around stuff causes issues to the whole game. I don't know why, but it just did in our case. Wasn't a server or coding issue.

Nudging an object sets its step_x/y variables, which in turn enables pixel movement for the entire game. Assuming you were using tile-based movement before, that might explain what you were seeing.