ID:262777
 
Code:
mob
Click(mob/M)
if(M in src.targetlist)
src<<"You already have [M] targeted!"
return
else
for(M in src.targetlist)
M--
M.overlays-=/obj/Target/Norm
src.targetlist+=src
M.overlays+=/obj/Target/Norm
if(!client)
M<<"[src] looks at you."
else
src<<"You look at youself."


Problem description:

Cannot modify null.overlays

> mob
> Click(mob/M)
...
> M--


You are defining M as a type mob/M and then trying to subtract from it. Thats not what you're trying to do I don't think.

What you want to do is something like this:

Mytargetlist = src.targelist
for (var/I = 1; I <= Mytargetlist.len; I++)
I--


But that doesn't really make any sense either, because then it would be trying to access element 0 and a list starts with element 1. So I'm not entirely clear on what it is you're trying to do with that counter.

This line:
src.targetlist+=src

Adds the source as a target in its own list. I don't think that's what you want either.

It would help if I knew what your code was supposed to do.
In response to Dragyn
Im usin it to target other mobs and later objs for attacking, looking, picking up, etc., but you can only target 1 thing at a time.
In response to Dead_Demon
If you can only target one thing at a time you don't want to use a list of targets (targetlist) you would only want to have a single target.
In response to Dragyn
Oh...Well then How would I do this to get rid of the old target?

mob
var
Target = 0
Click(M)
if(src.Target)
M.overlays-=/obj/Target //to get rid of the old target
M.overlays+=/obj/Target
In response to Dead_Demon
Dead_Demon wrote:
Oh...Well then How would I do this to get rid of the old target?
mob
var
Target
Click(mob/M)
if(src.Target != M)
M.overlays -= M.overlays // Get rid of all overlays over a mob
var/obj/Target/T = new // Create a new target object
M.overlays += T // Put the new target object in the mob's overlay
src.Target = M


Something like that should work although its possible it could be done better. Since you are adding the target to overlays it will be visible to all players. Normally you would add a targetting cursor to a player's client.screen instead of a mob's overlay so that it will only show for the player doing the targetting. But thats a judgement call.

You seem to be going about trying to write your code totally wrong, using the wrong commands in the wrong places, etc. I highly advise checking out tutorials and demos to try to learn what you're doing.
In response to Dragyn
If I made it on the HUD, then it woukld not follow the player, and I wouild have a Target on my followin me on my screen.
In response to Dead_Demon
If you made it on the HUD you wouldn't want it to follow the player. You would want it to follow the Mob that the player is targetting.

Sorry but I think you need to figure out what you're doing and learn a bit more about how the language works before you're going to have much luck getting what you want :)