ID:139131
 
Code:
             var/delay = 60
usr.firing = 1
step_towards(usr,src)
usr<<"Step2"
usr.moving = 0
step_towards(usr,src)
usr<<"Step2"
usr.moving = 0
step_towards(usr,src)
usr<<"Step2"
usr.moving = 0
step_towards(usr,src)
usr<<"Step2"
usr.moving = 0
step_towards(usr,src)
usr<<"Step2"
delay -= 10
delay -= 10
if(usr.flashuse >= 100)
step_towards(usr,src)
usr<<"Step3"
usr.moving = 0
new/obj/afterimage(usr.loc)
delay -= 10
if(usr.flashuse >= 200)
step_towards(usr,src)
usr<<"Step3.1"
usr.moving = 0
delay -= 10
new/obj/afterimage(usr.loc)
if(usr.flashuse >= 300)
step_towards(usr,src)
usr<<"Step3.2"
usr.moving = 0
delay -= 10
step_towards(usr,src)
usr<<"Step3.2"
usr.moving = 0
new/obj/afterimage(usr.loc)
delay -= 3
usr.flashuse += 1
if(usr.flashuse == 100)
usr << "<b>Your flash step ability increased!"
if(usr.flashuse == 200)
usr << "<b>Your flash step ability increased!"
if(usr.flashuse == 300)
world << "<b><font color = lime>Ability Info: [usr] has mastered his flash step!"
sleep(delay)
if(usr)
usr.firing = 0


Problem description: In my spare time I've been fiddling with the code of the two classic "Naruto" and "Bleach" rips that bounce around BYOND on a consistent basis, working on putting them together. I have most of the code and processes thinned out so that they work together, but I've come across and interesting issue. The code quoted above is for an ability in the bleach game known as "Shunpo" Essentially the effect it achieves is the appearance of your character teleporting to point where you click, however there is a limit on the range.

Now, when the code for the Bleach game is running by itself (separate from the Naruto game) the code works flawlessly, and gives the appearance of a smooth teleportation. When the code is put together however, the user only moves one block. I added the "step test" debug test to find out which piece of code was executing and how many times, and the result is I receive all the printed statements, just not the desired number of steps. I changed the code to run through a for loop, with no change. It wasn't until I added a sleep statement, that the code executed successfully, though not as smooth in appearance. sleep(1) is the lowest value that has any sort of consistent success, while sleep(0) occasionally gets more then one step off, but never more then 2 or 3.

The only reason for this I could think of, was that the mass of code in having the two games running simultaneously was too overwhelming for the client to successfully move the required number of spaces without the delay. If anyone has any other theories as to why this problem may be occurring please let me know.
How is this being used? Is this a verb, or a proc?
The Indentation is retarded, and I'm pretty sure DM is telling you the same thing.

Also, there's no need for that additional 9012349103249 lines of code.

And it looks like one step because step() does not have any built in delay. If you use
for(var/i=1 to 20)
step(NORTH,src)

you will teleport 20 tiles due north in 'one step'

If you add in a sleep(1), it will move quickly. Now, you could make it move twice in one iteration like so:
for(var/i=1 to 10)
sleep(1)
step(NORTH,src)
step(NORTH,src)


and get a fast, yet moderately fluid movement. The more times you move per iteration, the choppier.

There has to be a delay. It has nothing to do with the game's processing; a game having a lot of code does NOT cause additional overhead, but if you are USING a lot of code at one time, then it causes additional overhead.

My game is in about 40 project .dm files, and it runs smoothly online(even despite my crappy hosting skills).

However, the additional resources (if you put the icon files together as well) will make the game like 100 MB, which will take more than a couple minutes worth of downloading time.

In response to LordAndrew
It runs with the click() proc. I didn't write the code myself, I was just taking a look at how it was done. The main thing that confuses me is why that exact code worked perfectly before, but doesn't now.

Oh and on the topic of the indentation, yes it is retarded, but correct. Whoever wrote it used a mixture of tab and space, the number of indentations is correct, it just looks messed up.