ID:1233199
 
(See the best response by Ter13.)
Code:
mob
Login()
if (fexists("./savefiles/[ckey].sav"))
return
else
alert(src, "Welcome to The Wizarding World.", "Welcome","O.K.")
var/NAME = input(src, "Choose a name for your character.", "Choose a name")
var/GENDER = input(src, "What is your gender?", "Choose your gender") in list("Male","Female")
var/Player/M = new/Player()
M = src
M.NAME = NAME
M.GENDER = GENDER
M << "[M.NAME],[M.GENDER]" //World works, src and M doesn't?
..()


Problem description:
For some reason, when I try to output my debug message to M or src, it doesn't work but when I output it to the world, it does.
Do you get any errors? Because when I done it and it seemed to work for me, can you show me where the Player type is defined too?
Player
var
NAME
GENDER


I don't get any errors either, it's just that it doesn't output anything to M or src.
Best response
You can't assign M to src because M has a type of Player (which looks like a datum), and src is a type of /mob.

datum/Player
datum/atom/movable/mob

^These two classes are incompatible.

What you are doing is simply an illegal operation.

M << "" //this won't output anything, because datum/Player doesn't know how to handle text outputs.


Define a variable for the player datum to hold the mob it refers to:

Player
var
mob/mob


Now, you can do this:

var/Player/M = new/Player()
M.mob = src
M.mob << "derp"
@Ter13

Your right.

Just a question though, wouldn't be easier to just use src? Why would you define a player? For the game that I have been working on lately I never defined a separate type for the players and the NPCs.
Largely, it's an unnecessary use of a datum.

When it comes to atoms, atoms are used only to display appearances. Appearances really only communicate visual and locational data anyway, so utilizing a Player datum doesn't really use them for their primary purpose, which is to provide behavior separation between logical objects and physical objects.

In this case, I'd say create player as a subclass of /mob, and just use that.
Thanks, that clears it up :D
In response to Nailez
Just as an addition, you can still use your /Player datum if you wish, but you need to include a parent_type assignment:
Player
parent_type = /mob