ID:175322
 
how can u get a var to equal the amount of a certain mob.
e.g. var/numofmob = (number of mobs on map)
is there a way?
it would probably involve a for loop.
This could be done by looking in the world.contents for whatever you need.
In response to Maz
I am a really really stupid newb, could anyone explain this in IDIOT language for me?
In response to Gokuss4neo
var/mobcount
for(var/mob/M in world)
mobcount++

mob count is the number of mobs in the world, this includes npcs.
In response to Maz
THANK YOu!
In response to Gokuss4neo
Erm...I get LOTS of errors when i use this code!

skills.dm:640:error:M:duplicate definition
skills.dm:640:error:world:duplicate definition
skills.dm:640:error:in :instruction not allowed here
skills.dm:640:error::empty type name (indentation error?)
skills.dm:641:error:mobcount:value not allowed here
skills.dm:641:error::empty type name (indentation error?)

!!!

Would it help if I said what i wanted it for?

I want it so that I can make a verb, that fires a projectile at EVERY mobe of a certain type (e.g mob/monster/poo)
In response to Gokuss4neo
First of all, the way hazman wrote it wasn't total tab lengths so it will be totally messed up. Maybe that's wahy you got the 2 indentation errors :) Also, I think Haz just gave you part of the coding, not all of it. When i was making a walk() for a ship in my game, it had the duplicate definition. I think this means you have to make it a new () and not in the first one but im not sure :(

~Starwaspower~
In response to Starwarspower
skills.dm:640:error:M:duplicate definition
-means that you have a variable named M already. You'll need to find another name for the M variable in the snipplet Maz gave you.

Too explain the rest Im going to have too see the entire proc. It sounds like youve messed up somewhere else and confused the compiler.
In response to DarkView
OK, thank you for your help...
In response to DarkView
You have probably placed that snippet of code somewhere not allowed, or you wouldn't get those errors. Show the surrounding say, 10 lines each way. The code snippet will have to be inside a procedure(such as a verb or proc)
In response to Alathon
turf
Tree3
icon = 'turfs.dmi'
icon_state = "tree3"
density = 1
Tree4
icon = 'turfs.dmi'
icon_state = "tree4"
density = 1
flag
icon = 'turfs.dmi'
icon_state = "flag"
density = 1
verb
Salute()
set category = "Fighting"
view(6) << "<font color = red>[usr]<font color = white> salutes</font color = blue> to<font color = red> the <font color = white>American<font color = blue> flag<font color = white>."

pole
icon = 'turfs.dmi'
icon_state = "pole"
density = 1
verb
Salute()
set category = "Fighting"
view(6) << "<font color = red>[usr]<font color = white> salutes</font color = blue> to<font color = red> the <font color = white>American<font color = blue> flag<font color = white>."

grass
icon = 'turfs.dmi'
icon_state = "grass"
density = 0
mob
explosion/New()
spawn()
while(src)
icon = 'mobs.dmi'
icon_state = "explosion"
var/Y
var/X
sleep(25)
X = rand(4,13)
Y = rand(73,82)
loc = locate(X,Y,2)
sleep(25)
turf
buildingtop
icon = 'turfs.dmi'
icon_state = "buildingtop"
density = 1
buildingside
icon = 'turfs.dmi'
icon_state = "buildingside"
density = 1

saibamachine
icon = 'turfs.dmi'
icon_state = "saibameen"
density = 1
In response to Gokuss4neo
and its supposed to fit in where?
In response to Maz
under:

mob
explosion