ID:147803
 
//I am trying to make an overlay that displays the client's
//name. When I use this coding I get the following
//runtime error:
// "runtime error: Cannot modify null.icon_state."

//I commented all of this out so you can simply copy and
//paste.

obj/nameslot
var/value as text
one
pixel_x=1
two
pixel_x=4
three
pixel_x=8
four
pixel_x=12
five
pixel_x=16
six
pixel_x=20
seven
pixel_x=24
eight
pixel_x=28
nine
pixel_x=32
ten
pixel_x=36
icon_state=""
icon='Player/text.dmi'
layer=MOB_LAYER+98
mob/var
var/obj/nameslot/one/one
var/obj/nameslot/two/two
var/obj/nameslot/three/three
var/obj/nameslot/four/four
var/obj/nameslot/five/five
var/obj/nameslot/six/six
var/obj/nameslot/seven/seven
var/obj/nameslot/eight/eight
var/obj/nameslot/nine/nine
var/obj/nameslot/ten/ten
mob/proc/nameupdate()
if(!src.name)return..()
var/text as text
src.overlays-=src.one
src.overlays-=src.two
src.overlays-=src.three
src.overlays-=src.four
src.overlays-=src.five
src.overlays-=src.six
src.overlays-=src.seven
src.overlays-=src.eight
src.overlays-=src.nine
src.overlays-=src.ten
text=src.name
if(lentext(text)==1)
src.one.icon_state=text
if(lentext(text)==2)
src.one.icon_state=copytext(text,1,2)
src.two.icon_state=copytext(text,2,3)
if(lentext(text)==3)
src.one.icon_state=copytext(text,1,2)
src.two.icon_state=copytext(text,2,3)
if(lentext(text)==4)
src.one.icon_state=copytext(text,1,2)
src.two.icon_state=copytext(text,2,3)
if(lentext(text)==5)
src.one.icon_state=copytext(text,1,2)
src.two.icon_state=copytext(text,2,3)
if(lentext(text)==6)
src.one.icon_state=copytext(text,1,2)
src.two.icon_state=copytext(text,2,3)
if(lentext(text)==7)
src.one.icon_state=copytext(text,1,2)
src.two.icon_state=copytext(text,2,3)
if(lentext(text)==8)
src.one.icon_state=copytext(text,1,2)
src.two.icon_state=copytext(text,2,3)
if(lentext(text)==9)
src.one.icon_state=copytext(text,1,2)
src.two.icon_state=copytext(text,2,3)
if(lentext(text)>=10)
src.one.icon_state=copytext(text,1,2)
src.two.icon_state=copytext(text,2,3)
src.overlays+=src.one
src.overlays+=src.two
src.overlays+=src.three
src.overlays+=src.four
src.overlays+=src.five
src.overlays+=src.six
src.overlays+=src.seven
src.overlays+=src.eight
src.overlays+=src.nine
src.overlays+=src.ten
mob/Stat()
..()
src.nameupdate()
mob/Login()
..()
var/obj/nameslot/one/a=new
var/obj/nameslot/two/b=new
var/obj/nameslot/three/c=new
var/obj/nameslot/four/d=new
var/obj/nameslot/five/e=new
var/obj/nameslot/six/f=new
var/obj/nameslot/seven/g=new
var/obj/nameslot/eight/h=new
var/obj/nameslot/nine/i=new
var/obj/nameslot/ten/j=new
src.one=a
src.two=b
src.three=c
src.four=d
src.five=e
src.six=f
src.seven=g
src.eight=h
src.nine=i
src.ten=j
src.overlays+=src.one
src.overlays+=src.two
src.overlays+=src.three
src.overlays+=src.four
src.overlays+=src.five
src.overlays+=src.six
src.overlays+=src.seven
src.overlays+=src.eight
src.overlays+=src.nine
src.overlays+=src.ten
As you can tell, I am only testing this for the first two character spaces.
You get the error because you never created an obj to be src.one, or src.two, etc.

But why you're using this convoluted system at all confuses me. There are 3 very adequate text systems out: sd_Text, Raekwon's MapText, and DmiFonts.

Lummox JR
In response to Lummox JR
Are you saying dont make your own code use others? I say even if theres libs that do it better make it yourself and update your code when you get better.
In response to Hendrix
Are you saying dont make your own code use others? I say even if theres libs that do it better make it yourself and update your code when you get better.

No point reinventing the wheel unless you're doing it for educational reasons. You don't have to use BYOND either and could write up entire games in a hex editor typing in machine code. That way you wouldn't need to use any other libraries or other people's source code.

That and libraries written by decent to good programmers tend to be well done, optimized, and tested. If you write it yourself you'll need to spend a lot of time debugging it and you'll still probably end up with more bugs and it won't be as effecient unless you spend a lot of time on this. That time could be spent better else where improving things that will matter to the players that will play your game.
In response to Theodis
Thanks for the replies, but I am doing this to LEARN.
I prefer not to use vet codings, I am trying to improve myself, and the only way to do that is trail and error
In response to Theodis
Why else would you code? I mean you can get a lib for almost anything should you just take them all since the person making the lib is a better coder than you might be? If you want to get better than you should code your self.
In response to Hendrix
Hendrix wrote:
Are you saying dont make your own code use others?

If one's own code is convoluted, sucky, and buggy, then yes.

However none of the text libs are so foolproof that it's not a learning exercise to use them.

I say even if theres libs that do it better make it yourself and update your code when you get better.

That's usually not desirable, but if you do like to go that way, it helps to study what's out there and how it does things.

Lummox JR