var/tmp/People = 0
for(var/mob/M in oview(,src))
People ++
continue
thats the whole code its just of the current verb
but my question is will the var/People increase for each person within view()?
i want it so that for every person you can see People increases by 1 till ig counts all of them.
Will it do that?
or how cna i go about it.
ID:273387
Mar 15 2010, 2:06 pm
|
|
Mar 15 2010, 2:18 pm
|
|
Isn't this a mob variable? It should be mob/var/tmp/whatever. Unless you are leaving out that this is defined under a mob. Also, then People should be src.People. Test it after that and try playing around with it.
|
In response to Darkjohn66
|
|
yes its defined in a mob/verb/Name()
i need to take the var out of their so it will just be a var/tmp rather then a mob var. |
Yes, after the for() loop is finished, People will be equal to the number of mobs in oview(src).
Three small notes: First, continue is not needed here, as that is what happens by default at the end of a for() (or while()) block. Similarly, return is not needed at the end of every proc as that happens anyway. The use for continue is when you want to skip an iteration for some reason. For example, you might have "if(M.is_not_a_person) continue" at the start of your for() block, which would cause it to skip anybody who wasn't a person. Second, you do not need to declare the People variable as tmp. The tmp modifier is only useful when declaring variables belonging to objects (as in: mobs, objs, turfs, etc.) It causes a variable to be ignored when the object is sent to a savefile. Third, you don't need the extra comma in oview(). While it is valid syntax, you can also simply provide oview() a single argument (so, oview(src)) which will be equivalent. It's smart enough to take arguments in either order: oview(src,5) works as well as oview(5,src). |
In response to Garthor
|
|
Alright thanks, you've answered all of my questions, and you really, really know your stuff. I appreciate it.
|