ID:141507
 
ok so I have been looking at this code for over a day now and am hoping that someone will give be able to figure out whats wrong.
Code:
obj/Medical
layer = MOB_LAYER + 1
icon = 'buttons.dmi'
icon_state = "heal"
New(client/C)
screen_loc = "3,1"
C.screen += src
Update(C)

Click()
alert("I'm sorry, but Im still working on this!", "Combat")

proc/Update(client/C)
var/mob/M
for (M in world)
if (!isnull(C) && !isnull(M))
if (M.key == C.key)
if (M.BattleNumber && M.menu==1)
if (M.Jtype.Find("Healing"))
icon_state = "heal"
else
icon_state = null
else
icon_state = null
spawn (5) Update(C)
client/New()
new/obj/Medical(src)
..()


Problem description: The problem is that the button does not appear on the screen at all. I have no clue if its the basic function of it or if its the Update proc. IF you can help I would be greatful. Either way thanks for having a look.

Try commenting out the update() call. And report back.

It's possible Update() is turning the icon_state null.
In response to Andre-g1
Ive tried commenting out Update() and same result. while tinkering around I did get an error message that is reporting "C.screen += src" is the line that is causing the problem. I dont get why that would be the problem since its just asigning the obj to the client's screen.
In response to Sleinth
I've tested and there's no reason it shouldn't work.

Only reason I see is the Update() as testing without the Update() worked just fine.(it's exactly how you have it without the Update())

EDIT- Maybe you're calling client/New() somewhere else and not calling the parent proc (..()).
In response to Andre-g1
ok so as far as I can tell fom all this, since its still not working from all this the problem lies else where in the code.
I went through all my code and it apparently is being turned off during my login process. :/
I would post it but its long. Do you want me to post it? Im going to look through it a bit more myself because I cant think of why this would happen.
only thing I can think of it when it reassigns the cleint to a new mob.
In response to Andre-g1
Ok so I looked through all my code and discovered it was my choice of saving programs. Deadron's Character HAndling was to blame. Thank for your help.
That for() loop is pretty ridiculous; look up the client's mob var. You're scanning for a mob you already have a reference to.
In response to Kaioken
the update proc works and it does cause any lag. it works just like the Built in stat(), only this updates the HUD instead. it is almost lagless due to spawn(). like I said below the problem occurred in Deadrons character handling library. Which is now fixed.
In response to Sleinth
Um, that has nothing to do with the fact your for() loop is entirely superfluous and silly to have. Maybe you didn't understand what I've said? You're looping through all the mobs in the world to check their keys to find a specific mob, but you already have direct access to that mob in the first place without needing to do anything.
Besides that, I'd also recommend instead of updating any sort of 'display' periodically, try and update it only when an update is actually needed; when the value or thing it displays is altered. Not only is the display then more up-to-date but it takes much less resources as it doesn't update itself uselessly all the time to display the same value again to multiple players.
May I ask you what the benefit is to put these two lines.... on two lines o.O?

        var/mob/M
for (M in world)

For starters, that loops through EVERYTHING in the world, as opposed to just mobs. Remove the "in world" bit.

And lastly, that could just be turned into...
for(var/mob/M)
In response to Spunky_Girl
Spunky_Girl wrote:
May I ask you what the benefit is to put these two lines.... on two lines o.O?

There is often no benefit. It works identically, the difference is that since the var is declared outside of the loop, it can be used there; after the loop its value will be of the last item looped through (as it keeps being overwritten with the value of the item being looped through).

For starters, that loops through EVERYTHING in the world, as opposed to just mobs. Remove the "in world" bit.

Um, it loops through all the mobs in the world (in world.contents). It's no different from putting it all on 1 line:
var/mob/M
for(M in Container)

for(var/mob/M in Container)
//both loop through all the mobs in Container.

//just like the following 2 methods do the same.
var/list/L
L = new()

var/list/L = new()

The statement just works by reading the defined/typecasted value of the var, then Dream Maker compiles that type in for use in the resulting statements.
The difference between putting "in world" or omitting it is also negligible when dealing with atoms (with non-atoms, you can't use world.contents to loop through them in the first place).