ID:150156
 
This post is stemmed off of this: [link]

Now when I try to compile I get errors.
datum
proc
Trash(object)
if(object.loc == object.norm_loc)
object.loc = usr.loc
object.icon_state = "trashed"
usr.score += 1
usr.cash += 2
else
usr << "Object is already trashed."
return 0

main.dm:49:error:object.loc:bad var
main.dm:49:error:object.norm_loc:bad var
main.dm:50:error:object.loc:bad var
main.dm:51:error:object.icon_state:bad var
I think you need to define object as atom/movable/object, since you set its loc value.

If you'd prefer to be able to call it as O.Trash() instead of Trash(O), I'd put it under atom/movable instead of datum. You can call O.Trash(O) now of course, but unless you're using src for anything, there's no point making Trash() a datum proc instead of global. If you put it under atom/movable and change all object references to src, it'll probably be closer to what you're looking for.

Lummox JR
In response to Lummox JR
How do i work custom vars in? I have an obj var called "norm_loc" and the proc is saying that it doesn't exist, which it doesn't in atom/movable. Should i move that to atom/movable?
In response to Lummox JR
Let me add to this and the cryptic edit to my response in Newbie central. There are two ways you can declare your proc: either as a proc owned by atom/movable, or as a global proc. Your choice depends largely on whether you want to change and customize this proc for different types of objects. If you want it to do slightly different things for different types, then make it a proc of atom/movable:
    atom/movable
proc
Trash()
if(src.loc == src.norm_loc)

And so on. Then, say you have a new object type that can't be trashed for whatever reason. Then you can override atom/movable/Trash() for that type and have it do nothing:
    obj/untrashable
Trash()
return

However, if you want it to do the same thing for every object, then you probably just want to make it a global proc. In that case, you would do something like this:
    proc/Trash(atom/movable/object)
if (object.loc == object.norm_loc)

And so on. These two methods would be called differently. The first would be something like
    var/obj/o = something
o.Trash()

while the second would look like:
    var/obj/o = something
Trash(o)

Ultimately it's up to you.

Finally, where do you declare norm_loc? [I see your reply now, it is in obj] If it's only a variable of /obj, then you don't need to make Trash() for atom/movable, just make it for obj. It sounded from your original question that you wanted it for everything possible, but now it sounds like maybe not quite everything.

Hopefully that made a little bit of sense!
In response to Air Mapster
Well I plan on calling it from other places than object such as from Center(). I didn't think that if i put it in /obj/objects (my trashable objects) that Center() would be able to use it, thus the need for the global proc.
In response to Evilkevkev
Evilkevkev wrote:
How do i work custom vars in? I have an obj var called "norm_loc" and the proc is saying that it doesn't exist, which it doesn't in atom/movable. Should i move that to atom/movable?

Yep! You can add vars to the basic types like that pretty easily.

Lummox JR
In response to Evilkevkev
Evilkevkev wrote:
Well I plan on calling it from other places than object such as from Center(). I didn't think that if i put it in /obj/objects (my trashable objects) that Center() would be able to use it, thus the need for the global proc.

You can still call things from Center(), depending on what you're trying to do. You can call object.Trash(), or if you want to trash the mob, mob.Trash().

Lummox JR