ID:1404965
 
(See the best response by Nadrew.)
Code:
obj/tree_bottom/verb/cut()
set src in view(1)
world << "[usr] is now cutting down the tree!"
if(???):
world << "[usr] has chopped down the tree"
else:
world << "[usr] has stopped chopping the tree"


Problem description:
I am trying to figure out what to type for the if statement if the player moves out of his current position since I want it so if you move in the process of cutting the tree then it stops.. How would I do this?

Best response
There's a few ways you could do this, the best one would probably be a generic action handler that handles all actions a player can have going on. But if you're just looking for handling if the player moved you can do something as simple as:

obj/tree_bottom/verb/cut()
set src in view(usr,1)
view() << "[usr.name] is now cutting down the tree!"
var/turf/init_location = usr.loc
spawn(50) // Wait 5 ticks or so.
if(usr.loc == init_location)
view() << "[usr.name] has chopped down the tree!"
else
view() << "[usr.name] moved!"


This, of course isn't going to trigger as soon as the player moves, but it will handle the movement happening (of course, they can move and move back to where they started and still succeed).

A more ideal solution is handling things inside of movement itself, or even prevent movement while they're doing something.

mob/var/current_action

obj/tree_bottom/verb/cut()
set src in view(usr,1)
if(usr.current_action)
usr << "You're already doing something!"
return
usr.current_action = "chopping a tree down"
// This could be more robust, but this is just an example...
spawn(50)
if(usr.current_action == "chopping a tree down")
usr << "You have chopped the tree down!"
usr.current_action = null


mob/Move()
..()
if(current_action)
src << "You have stopped [current_action]!"
current_action = null


Do with it what you will, there's a lot you can expand on with it :)