ID:150149
 
I have some code that I want to run when the user trashes an object. I have the code (below) but when I preform the action, the Whats_Sound() proc causes a runtime error. Do you have any suggestions?

obj/objects
proc
Trash()
if(src.loc == src.norm_loc)
src.loc = usr.loc
src.icon_state = "trashed"
usr.score += 1
usr.cash += 2
var/mob/mom/M
M.Whats_Sound()


runtime error: Cannot execute null.Whats Sound().
proc name: Trash (/obj/objects/proc/Trash)
source file: objects.dm,37
usr: Start Game (/mob/player)
src: the cds (/obj/objects/cds)
call stack:
the cds (/obj/objects/cds): Trash()
Evilkevkev (/client): Center()
If its a proc then you dont need.

M.What_Sound()

just use What_Sound()
Evilkevkev wrote:
I have some code that I want to run when the user trashes an object. I have the code (below) but when I preform the action, the Whats_Sound() proc causes a runtime error. Do you have any suggestions?

> obj/objects
> proc
> Trash()
> if(src.loc == src.norm_loc)
> src.loc = usr.loc
> src.icon_state = "trashed"
> usr.score += 1
> usr.cash += 2
> var/mob/mom/M
> M.Whats_Sound()

runtime error: Cannot execute null.Whats Sound().
proc name: Trash (/obj/objects/proc/Trash)
source file: objects.dm,37
usr: Start Game (/mob/player)
src: the cds (/obj/objects/cds)
call stack:
the cds (/obj/objects/cds): Trash()
Evilkevkev (/client): Center()

Usually when you get this sort of error, it means that you've got an object variable that you didn't assign to anything, which is precisely the case here with M--it's like you wrote out a little sticky-note label to identify something, but didn't stick it on anything. If you want to create a new mob/mom, you'd just assign M to new() (you've already declared M's type), or if you wanted to assign it to an existing mob, you'd simply assign it to an existing reference.
In response to Darke Rage
It's located in mob/mom though. The Trash proc is located in obj/objects.
In response to Leftley
Ah! Thanks!
In response to Evilkevkev
thanks to who?
In response to Darke Rage
Leftly, for fixing my proble, that's why I replied to him. But thanks, to you, for trying. :)