ID:261275
 
mob
verb
pull_grass()
var/turf/grass/g
if(istype(usr.loc,/turf/grass))
for(g in usr.loc)
if(g.grassleft>=1)
usr.grass_pieces+=1
g.grassleft-=1
usr<<"You picked some grass"
if(g.grassleft<=0)
g.icon_state="grass2"
return 0

it doesn't work, but if you put in world where the red part is it works, but not how I want it to. How do i get it to work for the grass in the users loc?
Since you're standing on one turf, and you're checking to see if it's the right type anyway, instead of using a for() loop, try this:
g=usr.loc

That ought to work.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Since you're standing on one turf, and you're checking to see if it's the right type anyway, instead of using a for() loop, try this:
g=usr.loc

That ought to work.

Lummox JR

So I do:

mob
verb
pull_grass()
var/turf/grass/g
g=usr.loc
if(istype(usr.loc,/turf/grass))
for(g in usr.loc)
if(g.grassleft>=1)
usr.grass_pieces+=1
g.grassleft-=1
usr<<"You picked some grass"
if(g.grassleft<=0)
g.icon_state="grass2"
return 0


?????????????????????????
Not quite sure what you mean.
In response to Air _King
Air _King wrote:
Lummox JR wrote:
Since you're standing on one turf, and you're checking to see if it's the right type anyway, instead of using a for() loop, try this:
g=usr.loc

That ought to work.

Lummox JR

So I do:

mob
verb
pull_grass()
var/turf/grass/g
if(istype(usr.loc,/turf/grass))
for(g=usr.loc) // like this
if(g.grassleft>=1)
usr.grass_pieces+=1
g.grassleft-=1
usr<<"You picked some grass"
if(g.grassleft<=0)
g.icon_state="grass2"
return 0


?????????????????????????
Not quite sure what you mean.
In response to Evilkevkev
Evilkevkev wrote:
Air _King wrote:
Lummox JR wrote:
Since you're standing on one turf, and you're checking to see if it's the right type anyway, instead of using a for() loop, try this:
g=usr.loc

That ought to work.

Lummox JR

So I do:

mob
verb
pull_grass()
var/turf/grass/g
if(istype(usr.loc,/turf/grass))
for(g=usr.loc) // like this
if(g.grassleft>=1)
usr.grass_pieces+=1
g.grassleft-=1
usr<<"You picked some grass"
if(g.grassleft<=0)
g.icon_state="grass2"
return 0


?????????????????????????
Not quite sure what you mean.

Ok so like this:
mob
verb
pull_grass()
var/turf/grass/g
g=usr.loc
if(istype(usr.loc,/turf/grass))
for(g in world)
if(g.grassleft>=1)
usr.grass_pieces+=1
g.grassleft-=1
usr<<"You picked some grass"
if(g.grassleft<=0)
g.icon_state="grass2"
return 0

In response to Air _King
Air _King wrote:
Lummox JR wrote:
So I do:

mob
verb
pull_grass()
var/turf/grass/g
g=usr.loc
if(istype(usr.loc,/turf/grass))
for(g in usr.loc)
if(g.grassleft>=1)

Gads no. My point was to replace your for loop with the assignment, like this:
mob/verb/pull_grass()
var/turf/grass/g
if(istype(usr.loc,/turf/grass))
g=usr.loc
if(g.grassleft>=1)
...

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Air _King wrote:
Lummox JR wrote:
So I do:

mob
verb
pull_grass()
var/turf/grass/g
g=usr.loc
if(istype(usr.loc,/turf/grass))
for(g in usr.loc)
if(g.grassleft>=1)

Gads no. My point was to replace your for loop with the assignment, like this:
mob/verb/pull_grass()
> var/turf/grass/g
> if(istype(usr.loc,/turf/grass))
> g=usr.loc
> if(g.grassleft>=1)
> ...

Lummox JR

Oh, thanks!!!