ID:161641
 
I shouldnt be having a problem here but i have the variable
mob
var
hp=500
But when i put
for(var/mob/M in oview())
M.hp -= 100

i get that M.hp is undefined.. Can you explain why?
this is part of a code to a bomb omb by the way. so i need it to hurt every mob in oview but anyhow i got to go for today bye. also is there a guide that will teach me about flick? cuz if there is i need to know about it because i dont know how to use it... unless you'd rather explain it gone
I'm guessing it's an indentation error. You want M.hp to be subtracted for every mob, right? So you'll indent it under for to put it inside the loop like this.

for(var/mob/M in oview())
M.hp-=100


You get an undefined error because M is only defined inside that loop. Also, if this is for a bobomb you'll want to use a reference to him as the center in oview, the default is usr (which I don't have a clue what it would be at this point).
In response to YMIHere
Uhhhh so in the () beside oview.... err do what?? If I do as you say i just get errors. But if i do it my way then i don't lose hp. Confused.
obj
Bombomb
icon = 'item.dmi'
icon_state = "bombomb"
density = 0
layer = 1000000000000000000000000000000000000000000000000000000000000000
Click()
switch(rand(1,4))
if(1)
for(var/mob/M in oview())
src.density = 1
src.loc = locate(x,y-1,z)
sleep(2)
src.loc = locate(x,y-1,z)
sleep(2)
src.loc = locate(x,y-1,z)
sleep(2)
src.loc = locate(x,y-1,z)
sleep(2)
src.icon = 'item.dmi'
src.icon_state = "bombomb1"
density = 1
layer = 100000000000000000000000000000000000000000000000000000000000000000000
sleep(30)
M.hp -= 100
del src
if(2)
for(var/mob/M in oview())
src.density = 1
src.loc = locate(x,y+1,z)
sleep(2)
src.loc = locate(x,y+1,z)
sleep(2)
src.loc = locate(x,y+1,z)
sleep(2)
src.loc = locate(x,y+1,z)
sleep(2)
src.icon = 'item.dmi'
src.icon_state = "bombomb1"
density = 1
layer = 100000000000000000000000000000000000000000000000000000000000000000000
sleep(30)
M.hp -= 100
del src
if(3)
for(var/mob/M in oview())
src.density = 1
src.loc = locate(x+1,y,z)
sleep(2)
src.loc = locate(x+1,y,z)
sleep(2)
src.loc = locate(x+1,y,z)
sleep(2)
src.loc = locate(x+1,y,z)
sleep(2)
src.icon = 'item.dmi'
src.icon_state = "bombomb1"
density = 1
layer = 100000000000000000000000000000000000000000000000000000000000000000000
sleep(30)
M.hp -= 100
del src
if(4)
for(var/mob/M in oview())
src.density = 1
src.loc = locate(x-1,y,z)
sleep(2)
src.loc = locate(x-1,y,z)
sleep(2)
src.loc = locate(x-1,y,z)
sleep(2)
src.loc = locate(x-1,y,z)
sleep(2)
src.icon = 'item.dmi'
src.icon_state = "bombomb1"
density = 1
layer = 100000000000000000000000000000000000000000000000000000000000000000000
sleep(30)
M.hp -= 100
del src
In response to SadoSoldier
First, fix the layers!

Second, this is a simple indentation error. If you don't know how to use loops properly, look them up in the reference.

Here's the example...

usr << "Mobs:"
for(var/mob/M in view())
usr << M.name

What's difference between that example, YMI's example, and your own code?


Third, the following isn't a good way to do it.

                    src.loc = locate(x,y-1,z)
sleep(2)
src.loc = locate(x,y-1,z)
sleep(2)
src.loc = locate(x,y-1,z)
sleep(2)
src.loc = locate(x,y-1,z)
sleep(2)


Look up walk_to() and walk_towards()
In response to Nickr5
For the last part, I'm guessing he would be subtracting 1 from y each time, making him move. Or something.
In response to DisturbedSixx
Yeah, realized that afterwards. But it's a really terrible way of doing it when A) he doesn't use move(), so they could go right through a wall or something, and B) DM already has procs to do that.
In response to SadoSoldier
I'm gonna start ignoring your topics until you fix your layering.