ID:1269946
 
(See the best response by Neimo.)
It's been a long time since I've been on BYOND, and I'm really really rusty with DM. Is there an easier method for storing and loading variables?


Code:
        CommanderStart()
for(var/mob/playable/Commander in /mob/playable)
usr.oldhp = usr.hp
usr.oldmaxhp = usr.maxhp
usr.oldsp = usr.sp
usr.oldmaxsp = usr.maxsp
usr.maxhp = Commander.maxhp
usr.maxsp = Commander.maxsp
usr.iscommander = Commander.iscommander
usr.icon = Commander.icon
usr.jumpdistance = Commander.jumpdistance


Problem description:
I made a test verb to change the player's variables into a mob's variables (instead of creating a new client). However, I can't help but feel that everything I'm doing here is wrong. The proc doesn't carry through.
Sorry, I don't get your purpose. Are you trying to create a new mob and set it's variables to initial?
Originally (or maybe I'll just do it), I was planning for the player to "switch" their character by changing them into a newly created mob.

Instead, I chose to store variables for recall later on.

In other words, I want the player to become someone else.
Without doing the block of code for every variable, I know there's a way to save the whole usr and then let him become the mob.
You can set the user's mob as the new mob. There's also the option to loop through all variables and setting them accordingly.

MegamanVirus wrote:
In other words, I want the player to become someone else.
Without doing the block of code for every variable, I know there's a way to save the whole usr and then let him become the mob.

You can store the old mob somewhere and set it to the newer mob.
In response to MegamanVirus
Right - as Neimo was saying, create a variable that has is client/var/mob/playable/commander
client/var/mob/playable/regular

then switch them by setting client.mob to whichever you wish to be:

client.mob = client.commander
client.mob = client.regular


if you wanted to go the route you were going, you could just copy the mob.vars rather than setting each one individually.
In response to Pirion
Best response
It'd be redundant to create two variables when there's already a mob variable, you would only need an original_mob variable.

client
var/mob/original_mob

src.original_mob = src.mob
src.mob = new/mob/character/dantom
Well that is all on the intent. If the op would would like to be able to switch back and forth, it would be better stored separately - but it was stated newly created mob, which it seems I missed that.
Thank you guys for everything!