ID:274048
 
ok, I was doing my skills, when I started doing Clones...

I'm almost finishing it, but now I'd like to let the clones use player skills, I did it, but to find the loc of the Clone I did this :

for(var/mob/M in oviewers())  // Here I find the clone
if(M.name == usr.name) // Clones always have the same name of the player
Ativar(M,M.loc,M.dir) // Proc to use skills


My question is, is this 'for' going to cause lag ?

Edit: I forgot the topic =0
That's a bit of a difficult question just on principle. Who is hosting your game? Nasa? If so, probably not. The whole concept of programming in my mind's eye is to make everything as efficient as possible, which is what I presume is your question's direction:

'Is there a more efficient way of doing X'.

In your case, probably. For all you know, there might be hundreds of non-clone-or-player characters on screen, to handle this, I'd place all of the players and clones into a list, and just check through that such as:

for(var/mob/M in players_and_clones)
if(M in oview(src))
Do stuff

In response to El Wookie
'Is there a more efficient way of doing X'.

This was my question xD

The 'for ideia' wasn't mine, a friend said, my first question was : "is this 'for' going to cause lag ?"

But, sorry, I started programming 3 years ago, but no in Byond =x and not in a games language...

Well, thanks xD, I'm going to do what u said.
In response to El Wookie
But, if I do a list, and check this list, wont it cause the same lag ?
In response to Feferson Uchiha
Instead of a global list, maybe you can try making a mob list which will contain references to the clones a mob has.
In response to Hashir
hmmm, I undertood.
In response to El Wookie
Even better:
var oview[] = oview(src)
for(var/mob/M in players_and_clones)
if(M in oview)
Do stuff

Calling oview() once is much more efficient than calling it 'players_and_clones.len' times.