mob/Login()
var/mob/player/p = new()
p.loc = locate(3,3)
p.client = src.client
mob/player
proc
classchange()
mob/player
var/role/playerrole = /role/hunter
verb/roletest()
playerrole.getrolename()
role/hunter
id="hunter"
name="Hunter"
role
var
id
name
skillset
proc/getrolename()
src << name
Problem description:
Sup guys, just me spamming the developer help like the typical newbie. I've been reading around the whole forum for infos on datums and now tried to use them aswell, but I seem to just not understand it.
Currently, I am trying to access a proc so it returns the var inside the datum I want to get at. While compilation works flawlessly, I get a runtime error, which is bothersome.
And here is the error:
runtime error: Cannot execute /role/hunter (/role/hunter).getrolename().
proc name: roletest (/mob/player/verb/roletest)
source file: datumhandling.dm,13
usr: (src)
src: the player (/mob/player)
src.loc: null
call stack:
the player (/mob/player): roletest()
However, the value of the variable does not, because the procs defined under a type are only accessible to instances of that type, not to the type itself.
It's strange that you would know how to instantiate the player in Login() in order to access its variables, but you didn't think to instantiate the role.
Also, since you claim compilation works flawlessly, I assume the first bit of the snippet isn't actually in your code, otherwise you'd not only have a compiler error on locate(3,3) (locate() takes 1 or 3 arguments), or you'd have an infinite loop caused by the recursion of mob/Login() (since /mob/player inherits /mob/Login(), and Login() is called whenever a client "logs into" a mob).