ID:178350
 
I still can't figure this out. I'm trying to make a proc that will make a plant mutliply basically. If there are more plants nearby, the chance is reduced. Anyway, this is the code I have.
        proc
Grow()
if(Grow == 2)
var/N = pick(0,0,0,0,1,2,3,4)
var/X as num
for(var/obj/Z in oview(1))
if(Z == /obj/Herb) X += 1
N -= X
Again
if(N > 0)
var/obj/Herb/H = new(get_step(src,pick(NORTH,SOUTH,EAST,WEST,NORTHWEST,SOUTHWEST,NORTHEAST,SOUTHEAST)))
--N
H.Grow = -1
goto Again
else
return 0
src.Grow = 0
else
++src.Grow
The part that is supposed to limit cluster growth is...
                    var/X as num
for(var/obj/Z in oview(1))
if(Z == /obj/Herb) X += 1
N -= X
but it doesn't do anything. Can someone help me please?
var/X as num
is that realy needed if there is no usr editing of the var? That might or might not be the problem.
In response to Scoobert
nope, not the problem =P
var/X as num
for(var/obj/O in oview())
if(istype(O,/obj/weed))
X += 1
N -= X
In response to Thief Jack
Thief jack wrote:
var/X as num
for(var/obj/O in oview())
if(istype(O,/obj/weed))
X += 1
N -= X

Even better,
for(var/obj/weed/O in oview(src,1))
X += 1

It use the for() command to filters all obj weeds, so you need no extra filtering code. oview(src,1) is a list of evertything within 1 space of the src (the turf this proc belongs to, if you defined it as a turf proc). oview(1) is a list of things within one space of usr, which could be any player mob in the game but is definately not a turf and probably not near the turf in question.
In response to Shadowdarke
THANK YOU! Now it works!