ok so i found my basic movment code so now shud i add your code?
Reread my previous comment, they're examples.

Experiment with the codes, and edit them as you see fit.

Instead of mob/M in view, you could use viewers(NPC) as well to reduce CPU cost on the process, all be it that requires alot of extra coding
cant i just change my wander() code to make it like that or somthing? just scrol up a bit from ur code comment nad ull see it
No, because the lag is caused by an infite loop, which in this case is your wander code.
when i put the code in it keeps saying error inconsistent indentation I dont know what the problem is
The Code is:
client
North()
if(usr.controling)
for(var/mob/puppet/P in view(25))
if(!P.Frozen)
step(P,NORTH)
return
if(!usr.Moveing)
if(!usr.Frozen)
for(mob/M in view(6)&&M.NPC&&!M.NpcActive)
M.NpcActive = 1 //activate the mob
for(mob/M in view(6,8)&&M.NPC&&M.NpcActive)
It's obvious you're just copy/pasting code, as the #1 error for people who do that is inconsistent indentation.

What I've said in my previous posts should not be confusing, nor was it obfuscated or unclear. It was concise and to the point. I'm you're trying to optimize your game without actually knowing what your game does, or how to work with it, assuming it is even your game to begin with.

At this point however I guess I should tell you to go read some guides and resources if you're unwilling to read the DM Guide. The error in question will become clear once you understand the fundamental rule of BYOND's whitespacing (you cannot mix and match tabs and spaces).
Why is there a var usr.Moveing? Doesn't the usage of North() imply you're going to move already?

What line does it say is an inconsistent indentation?
it says that erros for the 3 lines of code u gave me, dn no i didnt copy paste i typed it exactly how it was and used tabs for spacing
That's what he means by copy/pasting. Not thinking of your own specific code but taking it from someone else in its entirity.

And you need to take the &&M.NPC&&M.NpcActive out of the for loop
Ok,so I solved the inconsistent indentationlook
The Code:
        if(!usr.Moveing)
if(!usr.Frozen)
for(mob/M in view(6))
if(M.NPC&&!M.NpcActive)
M.NpcActive = 1 //activate the mob
for(mob/M in view(6))
if(M.NPC&&M.NpcActive)
M.NpcActive = 0 //deactivate the mob
You're not defining a variable in your loops. It should be

for(var/mob/M in hearers(6))


And notice how I use hearers() instead of view(). That's because the hearers() proc was designed to process only mobs, which makes it inherently less intensive than, say, view() or range()
That's better, even though I'd completely change the way you create your vars, but you should read through the BYOND Guide and Reference for more on that
In response to Doohl
Doohl wrote:
You're not defining a variable in your loops. It should be

> for(var/mob/M in hearers(6))
>

And notice how I use hearers() instead of view(). That's because the hearers() proc was designed to process only mobs, which makes it inherently less intensive than, say, view() or range()

doesn't viewers() do the same? What's the difference between the two?
Ok thanks Doohl, I changed it anything else i should change??
Well as I've stated above, I don't know the difference between hearers() and viewers(). but with viewers you can specify src as a target, thus referencing to any mob/M that has the source of the code in their vision (thus using viewers(src) instead of hearers(6))
In response to Dm31st3r
The difference is the overall performance since hearers only counts for mobs itself making the cpu a lot less then view since it will count everything in sight.
Doesn't viewers() only take mobs as well, as it only takes things into account that have a client.view
In response to Dm31st3r
one way to find out really test run both type then see if there is any big difference.
In my test, hearers was using less CPU than viewers, by almost half. It's actually even less than half when called over 10,000 times haha.
Page: 1 2 3 4 5