ID:179606
 
1. How can i "lock" a player in a specified direction
(South) for a couple of seconds ?

2. Is there a way to also "lock" a Click() for some time ? It seems when I click on my shopkeeper more than once, i get multiple panels with the same input.
(Let's hope you can understand what I mean by that...)

THX.
Cravens wrote:
1. How can i "lock" a player in a specified direction
(South) for a couple of seconds ?

Yep. Depends on what exactly you want to do though. Do you want the player to be continuously moving south during this time, or just lock it so the player can only move south if he/she so desires? The former can be tricky, the latter is simple.

2. Is there a way to also "lock" a Click() for some time ? It seems when I click on my shopkeeper more than once, i get multiple panels with the same input.

Sure, I do this a lot in ShapeShifter. What I do is for each clickable item that I want to lock, I give it a list var called clickers. Any time someone clicks that thing, I add them to clickers. Then in the Click() proc, the very first thing I do is check to see if they are already in clickers. If so, return immediately from Click(). Otherwise do the normal stuff and at the very end of Click(), remove them from clickers.

Something like this:
obj
clickable
var
clickers[0]

Click()
if (src.clickers.Find(usr))
return // already clicked me
src.clickers += usr
//... now do whatever needs to be done
src.clickers -= usr
In response to Air Mapster
for #1 you just do this:
client (or whatever)
if(North)
if(nomove=1)
return 1 //can move
if(nomove=0)
return 0 //can't move

it's something similar to this, go figure it out

In response to Air Mapster
Air Mapster wrote:
Cravens wrote:
1. How can i "lock" a player in a specified direction
(South) for a couple of seconds ?

Yep. Depends on what exactly you want to do though. Do you want the player to be continuously moving south during this time, or just lock it so the player can only move south if he/she so desires? The former can be tricky, the latter is simple.

Ok, thx for the second Q.
Now for the first, I want the player to be facing a direction (let's say south for an example) without being able to move for a couple of seconds. I don't want him to turn around while he is "locked".
Hope that helps...

In response to Cravens
Cravens wrote:
Ok, thx for the second Q.
Now for the first, I want the player to be facing a direction (let's say south for an example) without being able to move for a couple of seconds. I don't want him to turn around while he is "locked".

Ah, this is the easy case then. You can set a mob's direction by setting the dir variable:
src.dir = SOUTH

For the rest of it, I'd add a mob variable called movelock or whatever. When true, he's locked, otherwise he can move. So when you want to lock him to south, set src.dir = SOUTH and src.movelock = TRUE. Then set movelock = FALSE when you're done. Now, in client, you have to override Move proc to do nothing if the mob's movelock is true. Something like this:
client
Move()
if (src.mob.movelock)
return
. = ..() // otherwise do the default action
In response to Air Mapster
For the rest of it, I'd add a mob variable called movelock or whatever. When true, he's locked, otherwise he can move. So when you want to lock him to south, set src.dir = SOUTH and src.movelock = TRUE. Then set movelock = FALSE when you're done. Now, in client, you have to override Move proc to do nothing if the mob's movelock is true. Something like this:
> client
> Move()
> if (src.mob.movelock)
> return
> . = ..() // otherwise do the default action
>


I had a similar code, but it wasn't in client.

mob/Move()
if(locked) //if they're locked ----> M.locked = 1
return 0 //prevent movement
else //otherwise,
. = ..() //allow them to move


What's the difference between them ?

Also, about the src.dir = SOUTH, it doesn't seem to work.
Is it possible that the "movelock" locks the player before
the code can make him face south ?