ID:139284
 
Code:
obj
Tree
icon='tree.dmi'
icon_state="tree"
density=1
verb
Chop()
set src in oview(1)
for(var/obj/Tree in oview(1))
flick("chop",usr)
spawn(10)
icon='tree.dmi'
icon_state="chopped"
density=0


This is the code I made to chop down trees and turn them into stumps you can walk over. It works fine, however, if there are more than one tree in the players oview it seems to randomly select which tree to chop. I want it to chop the tree in the direction im facing. How would I go about doing that?:

obj
Tree
icon='tree.dmi'
icon_state="tree"
density=1
verb
Chop()
set src in oview(1)
for(var/obj/Tree/T in get_step(usr,dir))
flick("chop",usr)
sleep(10)
T.icon_state="chopped"
T.density=0

In response to Chowder
There is no need for istype(), the for() loop already filters out anything that does not match the given type.

Also, flick() should not be T.flick(), but I'll assume that was essentially just a typo on your part.
In response to Chowder
Thank you chowder *bows* much appreciated. And thank you Garthor for your help as well. My first project is well on its way now!
In response to Garthor
Yeah I got a little carried away with the "T." and didn't double check. The istype thing is just a habit of mine. I have edited it to correct the mistakes.