ID:155370
 
I would like it so that my character does not move when performing a certain action...


Say for example. I am fishing...and i dont want to fish and walk at the same time?

How would i make it so the player is not allowed to move their character while performing this action?

ALSO

Alternatively...cancel out said action if player tries to move?
You'd want to modify the move proc to return (not 1). I have seen it done like this quite often.

mob
Move() // Move proc
if(src.Frozen) // If they're frozen
return // Since it doesn't return 1, it won't move
else // If they're not frozen
..() // Will do stuff normally.
In response to Lugia319
so simply speaking...just like that? really?
In response to Lugia319
and what if i just want to cancel what their doing, and allow them to move?
In response to Komuroto
Modify the frozen variable. It only works if the frozen variable isn't 0
In response to Lugia319
no i mean, for example i'm cutting away at a tree, but then suddenly i hit the arrow key to walk away from it. I dont want the cut verb to be carried out, as it will obviously still be going at this moment.

How do i make it so that when the player moves away from the tree, it would stop the called verb instantly?
In response to Komuroto
That requires a bit more thought. I imagine it'd work a bit like this.

mob
Move() // Move proc
if(src.Action) // Action is a new variable I've introduced. It will be whatever trade you are doing
src << "You stop [src.action]" // Output Message
src.Action = null // Stop doing the action
..() // Since there is no way that you will be unable to move in this example, ..() is aligned with the if statement.

obj
Tree
verb
Cut() // Tree cut proc
set src in oview(usr,1) // You gotta be next to the tree
if(src in get_step(usr,usr.dir)) // If the tree is in front of the person
usr.Action = "tree chopping" // Modify usr.Action var
while(usr.Action == "tree chopping") // While the person is still cutting the tree
sleep(30) // Sleep 3 seconds
var/obj/wood/W = new /obj/wood // Define W to be a new piece of wood
usr.contents += W // Add the wood to their inventory
return
One thing to think about is how to keep track of what your mob is doing. The examples posted here are good and well, but if things start getting more complicated, you will get confused without a more systematic method of organizing actions. I would create a datum that keeps track of the player's current actions, and have a move function that is passed to the datum. The datum then decides what actions should be cancelled upon moving.
In response to Pepper2000
Could you show me your example, so i know what i'm dealing with?
In response to Komuroto
My example is a bit of a mess right now (some good illustrations there of what not to do), but basically I have a datum called interface, and in it I have the following vars:

MasterState: keeps track of the player's overall state (map, battle, main menu, etc.)
BattleState: keeps track of the player's state within the battle system.
MenuState: keeps track of the player's state within the main menu system.
(more likely to come in the future)

In addition to that, these state values are only assigned constant values, so when I review my code later, it will be clear what is meant by "MasterState = BATTLE".

The client passes all input into the interface. For instance, there is a proc in the interface called Action(), which is your basic action key. Right now it is called by Center() in the client, but that is also likely to change.