ID:1020779
 
(See the best response by Magicsofa.)
I'm currently trying to code in a verb that would allow me to make certain mob move as I pressed arrow keys. I know how to use client/Move() but I don't want to use client/North() etc etc for checking where I'm trying to move. The character controlling the "controlled character" is frozen, so I can't check the dir where I'm trying to move and I don't want to use client/dir() procs to check it. Any idea? Thank you so much
Presumably you could just assign the controlled mob's mob.client to the controlling mob's client? That way, you need no further code changes hopefully.

I dunno though, there's a lot of potentially unanswered question-marks here, that would affect the approach you want to take. Is the controlled mob another player, a spawned NPC? What does the UI need to display, the controlling stats or the controlled stats? For example.
In response to Stephen001
Stephen001 wrote:
Presumably you could just assign the controlled mob's mob.client to the controlling mob's client? That way, you need no further code changes hopefully.

I dunno though, there's a lot of potentially unanswered question-marks here, that would affect the approach you want to take. Is the controlled mob another player, a spawned NPC? What does the UI need to display, the controlling stats or the controlled stats? For example.

It's just a NPC, I just wanted to make it controllable by an Admin. I've done this in some games with client/North and such, but I waste a lot of lines that way, that's why I wondered if there was a way to make it through client/Movement() using a var or something. I checked this on reference: Move(loc,dir) and I thought there was a way to make it so I could make step(mob.Controlling, dir) or something like that through client/Move()
I think you'd probably much better just assign the NPC's client to be the admin, and then all the usual client/Move() and that's NPC's mob/Move() apply, no special extra code should be needed.
In response to Stephen001
Stephen001 wrote:
I think you'd probably much better just assign the NPC's client to be the admin, and then all the usual client/Move() and that's NPC's mob/Move() apply, no special extra code should be needed.

Something like this would lag?

client/Move(var/V1, var/V2)
if(mob.Controlling)
step(mob.Controlling, V2)
return


It's actually working, but I don't know if it will lag.
Best response
You could use a reference to the puppet mob like this:

client
var/mob/puppet = null
verb
set_puppet(mob/NPC/M as mob in world)
puppet = M
clear_puppet()
puppet = null

Move(location,direction)
if(puppet)
step(puppet,direction)
else
..()
mob
NPC
icon = 'bla.dmi'


I think that will work :D

EDIT: well you sorta beat me to it. And no, that shouldn't cause lag
It's not going to be terrible, but to include this for what I'm guessing is a corner case (you presumably have only a few admin, and hopefully many players!) seems pretty silly.

http://www.byond.com/docs/ref/info.html#/mob/var/client

mob.client was pretty much entirely designed for this. The only problem I can see with such an approach is from bad design, like your admin specific procedures and verbs were added to the mob, not the client (who is actually the admin, and should have admin procedures).
That's a good point, and doing it that way offers a lot more flexibility since you would also gain access to the verbs and stats of the NPC.
In response to Stephen001
Another issue with changing client's mob is how Login/Logout are usually designed improperly for that purpose.

Besides using client/Move to affect what object is controlled, Forum_account's Keyboard library gives the client a "focus" variable. When you hit a key or click something, client.focus gets its key_down/up or click proc called. This allows you to let each object you set client.focus to get affected by input in their own way.