ID:142381
 
Code:
runtime error: Cannot read null.screen
proc name: updateHealth (/mob/proc/updateHealth)
usr: Agrey123 (/mob/Game)
src: Agrey123 (/mob/Game)
call stack:
Agrey123 (/mob/Game): updateHealth()
Agrey123 (/mob/Game): updateHealth()



mob
proc
updateHealth()
var/percent=round(src.Health/src.Mhealth*100,10)
if(percent>100) percent=100
if(percent<0) percent=0
for(var/obj/hudMeters/o in src.client.screen)
o.icon_state=num2text(percent)
spawn(10)
src.updateHealth()
verb
add()
src.Health+=rand(5,15)
src<<"[src.Health]/[src.Mhealth]"
sub()
src.Health-=rand(5,15)
src<<"[src.Health]/[src.Mhealth]"



Game/Login()
new/obj/hudMeters/health_01(src.client)
new/obj/hudMeters/health_02(src.client)
src.updateHealth()
usr.loc=locate(1,1,1)
var/mob/new_mob
new_mob = new/mob/character()
src.client.mob = new_mob
var/obj/Zampakto/R = new/obj/Zampakto
R.loc=usr


Problem description:

Any solutions :(


The null. bit gives it away: the game is trying to access a proc or variable, but the object in which it is trying to access doesn't exist.

In this case, you have a for loop which loops through src.client.screen. This is all fine and dandy -- except in your case there is no client.

You're also using a bad habit here: instead of calling the proc over and over, you might as well use a while loop.

-- Data
In response to Android Data
Well, you did not tell me how to fix it at all. I just need to know how to fix it and why its looping, what do i need to do with this code.
mob
proc
updateHealth()
var/percent=round(src.Health/src.Mhealth*100,10)
if(percent>100) percent=100
if(percent<0) percent=0
for(var/obj/hudMeters/o in src.client.screen)
o.icon_state=num2text(percent)
spawn(10)
src.updateHealth()


to make it stop doing the run time error
In response to Agrey123
You need to stop trying to modify the client of mobs that do not have clients.