In response to Spunky_Girl
starting to get really annoyed by this not making sense to me but ill keep trying, this is what i got now

mob
var
race
selected
M
owner
icon = 'player.dmi'
Login()
..()
world << "[src] has just entered '[world.name]'!"
verb
Start_New()
switch(input("Pick your race","Race Selection") in list("Human","Undead"))
if("Human")
new/mob/human (loc)
human.owner = client.key

human
icon = 'human.dmi'
name = "Human"
DblClick()
var
mob/human/human = M
if (human.owner==client.key)
if (selected==0)
selected = 1
usr << "Human has been selected"
else
selected = 0
usr << "Human has been deselected"


Mob.dm:16:error:human.owner:undefined var

only one error of undefined variable now
In response to Netmanx
Very sorry about that last post, I thought you had a different line of code in there, and i'll explain why I was wrong...
mob
var
race
owner
selected
M
icon = 'player.dmi'
Login()
..()
world << "[src] has just entered '[world.name]'!"
verb
Start_New()
switch(input("Pick your race","Race Selection") in list("Human","Undead"))
if("Human")
var/mob/human=new (loc)
human.owner = key
if("Undead")
var/mob/skeleton=new (loc)
skeleton.owner = key


When you used new before /mob/human it only made one in that location, and you did not define it. To define something use var, now var/mob/human=new(loc) makes a new human at the loc, and defines it as human. With this later in the code you can change its values and such with its defined name. Your problem wasn't type casting, it was just defining the mob in the first place
In response to Bakasensei
thanks for the correction, no runtime error now but things still arent working perfectly.

mob
var
race
selected
M
owner
icon = 'player.dmi'
Login()
..()
world << "[src] has just entered '[world.name]'!"
verb
Start_New()
switch(input("Pick your race","Race Selection") in list("Human","Undead"))
if("Human")
var/mob/human=new (loc)
human.owner = key

human
icon = 'human.dmi'
name = "Human"
DblClick()
var
mob/human/human = M
if (human.owner==client.key)
if (selected==0)
selected = 1
usr << "Human has been selected"
else
selected = 0
usr << "Human has been deselected"


so first of all when i select human as my race it creates a mob which is good but it doesnt create the human mob i want, it creates the default mob of the player, also selecting it doesnt work, idk if thats because its a totally diff mob or maybe its just a different image or maybe the selection code doesnt work at all
In response to Netmanx
See if you can guess the difference between
var/mob/human

(which creates a var called "human" that holds any /mob)
var/mob/human/human

(which creates a var called "human" that holds any /mob/human)
The part after the last slash is the var's name.
The rest, not including "var" is the type of thing it holds.
In response to Immibis
oh, okay i get it now, but i changed it to var/mob/human and it didnt make any difference, i still get the default mob
In response to Netmanx
As I said, var/mob/human means "A var called human that holds any mob".
var/mob/human/human means "A var called human that holds any /mob/human"
And "new" makes a new object of whatever the var holds.
For example:
var/obj/O = new

makes an /obj,
var/obj/thingywhatsit/O = new

makes an /obj/thingywhatsit.
In response to Immibis
haha you threw me for a loop there, i thought i understood what you were saying during the first half but then the second half completely threw me off,

that being said i get what your talking about and have made those corrections and the correct mob is being created

however i receive a runtime error when i try to go and select a unit

runtime error: Cannot read null.owner
proc name: DblClick (/mob/human/DblClick)
source file: Mob.dm,145
usr: Netmanxxx (/mob)
src: Human (/mob/human)
call stack:
Human (/mob/human): DblClick(Grass (1,1,1) (/turf/grass), "mapwindow.map", "icon-x=12;icon-y=14;left=1;scr...")

now, seeing as ive already created the unit i dont think theres a problem in the first part of my code, it should probably be in the mob part itself, the runtime error however i cant read too well and im not sure what its telling me is wrong
In response to Netmanx
If you changed DblClick() since your first post, then please post the new code because there isn't anything in there that should cause that error.
In response to Immibis
        DblClick()
var
mob/human = M
if (human.owner==client.key)
if (selected==0)
selected = 1
usr << "Human has been selected"
else
selected = 0
usr << "Human has been deselected"

In response to Netmanx
That's because M isn't set to anything. What do you want to do, anyway?
In response to Immibis
I assume that what he wants is kind of like this (ironically I'm aware that assumptions are one of the unforgivable, main sins in programming) :

mob
var
race
selected
owner
icon = 'player.dmi'
icon_state = "player"
Login()
..()
world << "[src] has just entered '[world.name]'!"
verb
Start_New()
switch(input("Pick your race","Race Selection") in list("Human","Undead"))
if("Human")
var/mob/human/h = new /mob/human(loc)
h.owner = client.key
if("Undead")
var/mob/undead/u = new /mob/undead(loc)
u.owner = client.key

human
icon = 'human.dmi'
name = "Human"
DblClick()
if(owner == usr.key)
if(selected == 0)
selected = 1
usr << "Human has been selected"
else
selected = 0
usr << "Human has been deselected"

undead
icon = 'undead.dmi'
name = "Undead"
DblClick()
if(owner == usr.key)
if(selected == 0)
selected = 1
usr << "Undead has been selected"
else
selected = 0
usr << "Undead has been deselected"


Please note that the code is not optimized, but works (tested and run).
Personally, I wouldn't define the player at a root level, for example.
In response to Schnitzelnagler
thanks for helping me, ive got it working perfectly now, thanks for everyones help
Page: 1 2