ID:1805377
 
(See the best response by Nadrew.)
Code:
mob
proc
Choose_Test()
//if(src.character=="good"||src.character=="bad")
var/Test = input("Where we you like to hit up?")in list("Level 1","Way Of The One","Turtles Throwback","Door Testing","Open World")
if(Test == "Way Of The One"&&testchosen==0)
src.client.view="13x9"
if(src.character=="Blue")
for(var/obj/Portal/Stage_3/GO in world)
src.loc=GO.loc
var/mob/player/Good/Blue/dude = new/mob/player/Good/Blue
dude.loc=GO.loc
src = dude
src.CreateName()
spawn(12) knockback(src, 6)//(10) knockback(src, 6)
src << sound('give credit to dpggioli cave ambience.wav', TRUE)
src.camera.px=235//64
src.camera.py=192//96
//spawn(1) src.client.perspective=EYE_PERSPECTIVE
src.camera.mode=3
//src.camera.lag=-1000
src.fixedpx=235//80//128//160//192//64
src.fixedpy=192//96//128//96
//src = new/mob/player/Good/Blue
//var/mob/player/Good/Blue/G = new/mob/player/Good/Blue()


Problem description:
I've hit a standstill. I implemented a character select screen, something I expected to take an hour but has been taking me all day. I wanted it to be like Mega Man, in the way that it jumps from location to location, high-lighting the character square icon you fall on. Therefor it had to override my gravity and keyboard libraries, so (k=="left") now jumps the player to a specific location on the character screen instead of moving them. I handled this by making players whom login a specific mob which doesn't acknowledge the usual procs that govern the world.

Now, that character select screen works like a charm, but, whenever you press space to create the character and bring up my "Choose_Test()" proc which brings up a list of places to teleport you to. Previously, this worked fine, since players were randomly given a character to be on login:
world
New()
var/character=rand(1,2)
if(character==1)
mob = new /mob/player/Good/Blue()
if(character==2)
mob = new /mob/player/Good/Cyan()
if(character==3)
mob = new /mob/player/Bad/Benjamin()


But now, I made it so depending on where your square is on the title screen, you will be given a character variable of the name of the character. That variable in turn is suppose to create a character in the coordinates the "Choose_Test()" usually would take you to. It doesn't. I've been tampering at this forever, sometimes I can make the mob and not teleport to the proper location, sometimes I can teleport to the location but not create the mob. So what's the best way to handle creating a mob, teleporting it to a location and having a player become it w/o manually changing icons, icon_states, variables?(The actual mob/player/... handles a lot and therefor the player cannot manually be made).

Note: The code provided in the code section is the result of trial and error. It's poorly written, but, does create the mob and does bring the player to the location. It just won't make the player become the mob.
You're not setting the client's mob is the issue. To assign a mob to a client simply do:
dude.key = src.client.key

to assign the client to that mob. It should be noted that this will also trigger Login() for that mob.

As a side note, that variable declaration for "dude" could be simplified to:
var/mob/player/Good/Blue/dude = new(GO.loc)
Hmmm, i might have one or two suggestions for how to in general go about doing what you are trying to do (read: may not be in the way of an answer to what you specifically mentioned in your question but...), however i'd like to ask you if maybe you could post a gif or link to a video or something, so as to demonstrate exactly (or just in example) how it is you're trying to make your character selection screen work?

____________
Edit: You see i'm just thinking that some of what you've done is possibly unnecessary for what i could guess you were trying to do? nevertheless, reformist's suggestion should be apt for the situation...
In response to Turboskill
Agreed, it seems a bit over-complicated. For the character portion I'd simply save a reference to the character type and load in from that.
var/mob/new_mob = new(locate(x,y,z))
var/mob/old_mob = src
src.client.mob = new_mob // Transfer to the new mob.
spawn(300)
src.client.mob = old_mob // Transfer back.


Of course, there's more to it than this, but changing mobs is as simple as that, you'll need to handle the extra calls to mob/Login() and whatnot, but this should get you started.
As I may have stated, the code is rather flimsy due to me troubleshooting for so long. I would have originally tried things like:
var/mob/player/Good/Blue/dude = new(GO.loc)

But with little results decided to expand the code as long as I could in case a runtime error was specific to a particular line.

Also,
dude.key = src.client.key
is a great suggestion, although, it is not fixing my issue. With that line implemented, the player(and I'm not talking about the dude, here) goes back to the title screen and remains a square.

Here is a gif of how the title screen works; The squares were suppose to use pixel_x and pixel_y to offset the character's square although I encountered some issues with those variables and navigating the screen and so I need to readjust how the key determine where you are to implement them again.

http://makeagif.com/i/tH6X-t
Nadrew, your answer alike Reformist seems like what I was looking for but unfortunately is giving me the same results as Reformist's suggestion. I implemented it as such:
                        var/mob/player/Good/Blue/dude = new(GO.loc)
src.client.mob = dude


I'm going to continue playing around with it, it's bringing me to the location and than teleporting me back as well as not turning me into a player.
Best response
Sounds like you need to go over your code and weed out any generic Login() calls and the sort, that could be the cause of the mob being reset without you asking it to. Remember, any time you change your mob the world will call mob/Login(), plus mob/whatever/type/you/use/Login(), so any calls to Login() in your code should all be under a type that you can control it, and rarely is putting it under mob/Login() directly a great idea, especially in cases where you intend to do mob swapping.

Changing a mob's key isn't quite the same thing because you're essentially forcing the client.mob to update without giving yourself any control over the process.
Updated look on how I was implementing the suggestions:

mob
proc
Choose_Test()
//if(src.character=="good"||src.character=="bad")
var/Test = input("Where we you like to hit up?")in list("Level 1","Way Of The One","Turtles Throwback","Door Testing","Open World")
if(Test == "Way Of The One"&&testchosen==0)
testchosen=1
src.client.view="13x9"
if(src.character=="Blue")
for(var/obj/Portal/Stage_3/GO in world)
//src.loc=GO.loc
//var/mob/player/Good/Blue/dude = new/mob/player/Good/Blue
//dude.loc=GO.loc
var/mob/player/Good/Blue/dude = new(GO.loc)
src.client.mob = dude
//spawn(1)
//src.client.mob = dude
//src.loc=GO.loc
spawn(2)
src.CreateName()
spawn(12) knockback(src, 6)//(10) knockback(src, 6)
src << sound(null)
src << sound('give credit to dpggioli cave ambience.wav', TRUE)
src.client.perspective=EYE_PERSPECTIVE
src.camera.mode=3
src.camera.px=235;src.camera.py=192
src.fixedpx=235;src.fixedpy=192
src.client.perspective=EYE_PERSPECTIVE
In response to Nadrew
Nadrew wrote:
Remember, any time you change your mob the world will call mob/Login()

I now know what was my biggest problem. I was unaware Login() is recalled after a mob is changed, thanks you everyone for the support.


In response to Flame Guardian
Reformist wrote:
<snip>
... It should be noted that this will also trigger Login() for that mob.

I mentioned that in my reply. :|
Not only do you have to watch out for Login() when changing mobs, but Logout().