ID:149813
 
Im trying to make objects appear all along the top of the screen, exept the very far left and right ones. This is my current code:
mob
New()
new/obj/my_obj
obj
my_obj
layer=MOB_LAYER+1
New(client/C)
var/loc1 = usr.y + 5
var/loc2 = usr.x + 4
var/loc3 = usr.y + 5
var/loc4 = usr.x - 4
screen_loc="[loc1],[loc2] to [loc3],[loc4]"
C.screen+=src


But that gives me these errors:
runtime error: Cannot read null.screen.
proc name: New (/obj/my_obj/New)
usr: the mob (/mob)
src: the my obj (/obj/my_obj)
call stack:
the my obj (/obj/my_obj): New(null)
the mob (/mob): New(the grass (3,14,1) (/turf/grass))


Can anyone tell me how to fix this?

thank you in advance

-Rcet

You are calling my_obj.New() with the client (C) null in mob.New(). When my_obj.New() is being called without a client, you are still trying to access the client's screen var. You can put a check into my_obj.New() to check if the the client is null.

[edit]
You may want to develop a method of putting my_obj in a client's screen outside of my_obj.New() though.