ID:154678
 
This is not the actual code in the game. This is an example.

obj/bullets
var/damage
bullet1
icon='bag.dmi'
damage=5
bullet2
icon='bag.dmi'
damage=10
Bump(mob/Target)
if(istype(Target, /obj/bullets))
if(src.damage>Target.damage) //This is where the error occurs. Apparently, 'Target.damage' is not definined.
src.damage+=Target.damage //And here. (obviously)
del Target
if(Target.damage>src.damage) //And here.
Target.damage+=src.damage // Here....
del src
if(Target.damage==src.damage) //.....and here.
del Target
del src


This code may not be perfect, as it is just a quick example, similar to what my game's actual code is, but the error would be the same.

Can somebody tell me why Target.damage is not defined, even though Target(which should be recognized as /obj/bullets/), should have a variable named 'damage'.

src.Damage is being perfectly fine, and not causing errors.
I also tried defining damage under all /obj, not /obj/bullets.
I also used Bump(obj/Target) and not (mob/Target)
The same error occurs.

Here is the exact error:
"Objects.dm: 3244:error: Target.damage: undefined var"

Help would be appreciated,
--JaiZo
Because you're defining 'damage' under /obj and not /mob, but 'Target' is referenced as a mob.
In response to Nadrew
Thanks for the reply, Nadrew.


So if I changed
    Bump(mob/Target)
if(istype(Target, /obj/bullets))
if(src.damage>Target.damage)
src.damage+=Target.damage
del Target
if(Target.damage>src.damage)
Target.damage+=src.damage
del src
if(Target.damage==src.damage)
del Target
del src


to

    Bump(obj/Target)
if(istype(Target, /obj/bullets))
if(src.damage>Target.damage)
src.damage+=Target.damage
del Target
if(Target.damage>src.damage)
Target.damage+=src.damage
del src
if(Target.damage==src.damage)
del Target
del src


it should work? I tried that, and I'm getting the same error. I think I know what you mean, but I can't seem to get it working.
What should I fix/replace in my code? Or possibly give me something to try?

EDIT:
Also, I just realized my topic may be in the wrong BYOND Developer Forum section. My apologies.