ID:139835
 
Code:
        for(var/HK/H in client.screen)//Checking the hotkeys on the clients screen. This goes through.
usr<<"[T], [H.skill]"//Checking to see if I made a mistake or not. This is outputting "Skill1=Skill1" so I know that it's going through correctly
if(T==H.skill)//Even though they match up, it won't delete the player or do anything below this line. This won't allow any other codes to get through.
del(src)//delete the player but it isn't going through for some reason.
H.AddTemporaryOverlay(/obj/Locked/, T.Cooldown)//Original intention, this code seems to be working 100% fine.. If only I can get this to get through the code. For now ignore this.


Problem description: For some strange reason, nothing below the line "if(T==H.skill)" is going through. I ran tests on my project to check if the variables 'T' & 'H.skill' match or not and they do. I can't see why it's not getting through. Any ideas?

I think the answer lies outside of the context of this small snippet. Posting the whole proc may be a better idea.

Also rememebr that del(src) is going to prevent that AddTemporaryOverlay() line from executing, because you'll be killing the proc along with the object.

Lummox JR
In response to Lummox JR (#1)
Lummox JR wrote:
I think the answer lies outside of the context of this small snippet. Posting the whole proc may be a better idea.

Also rememebr that del(src) is going to prevent that AddTemporaryOverlay() line from executing, because you'll be killing the proc along with the object.

Lummox JR

I know that, I just recently added the "del(src)" to see if it was a problem with my "AddTemporaryOverlay()' proc, but it isn't and heres the whole proc.

mob/var
_Cooldowns[0]

mob/proc/Cooldown(Name,Cooldown,obj/T=null,message=1)
if(!_Cooldowns)
_Cooldowns=new
if(T)
//if(T.Cooldown>=1)
//if(!(usr.Cooldown("Kunai",10*5,,0)))
for(var/HK/H in client.screen)//this seems redundant at this point, so I voided it
usr<<"[T], [H.skill]"
if(T==H.skill)
del(src)
//if(!(usr.Cooldown(H.skill,H.skill.Cooldown*10,H.skill,0)))
H.AddTemporaryOverlay(/obj/Locked/, T.Cooldown)
/*if(T)
for(var/HK/H in client.screen)
if(H.skill==T)
T.overlays+=new/obj/Locked*/

/*spawn(T.Cooldown*10)
T.overlays-=T.overlays
if(client)
for(var/HK/H in client.screen)
if(H.skill==T)
H.overlays-=/obj/Locked
H.overlays-=/obj/Locked
H.overlays-=/obj/Locked
H.overlays-=/obj/Locked*/

if(_Cooldowns[Name]&&_Cooldowns[Name]>world.timeofday)
if(_Cooldowns[Name]>world.timeofday+(Cooldown*3)) _Cooldowns[Name]=world.timeofday+Cooldown
if(message)
usr<<"You cannot use this ability yet. ([(_Cooldowns[Name]-world.timeofday)/10] Seconds Left)"
return 1
else
return 1



_Cooldowns[Name]=world.timeofday+Cooldown
return 0
Ripper man5 wrote:
before del(src) use spawn()H.AddTemporaryOverlay(/obj/Locked/, T.Cooldown) That is what I think may do it.

I know that, in the comment(//) I said to ignore that line for now but thanks anyways : ).
In response to AbdelJN (#2)
I see in your code that you're expecting T to be an obj. Presumably it is one, although the proc won't enforce that. T and the item in client.screen may display the same value when you convert them to text, expecially if they're the same type, but if they're not the exact same object then the comparison will fail.

For instance, if you're comparing a generic /obj/skill/climbing object you created to an /obj/skill/climbing object that was made separately for adding to an item in a player's client.screen, then you're comparing two different objects.

What you might want to do instead is not pass T as an object, but pass it as a type path instead. Then you can say if(istype(HK.skill, T)) or if(HK.skill && HK.skill.type == T) instead.

Lummox JR
Ripper man5 wrote:
before del(src) use spawn()H.AddTemporaryOverlay(/obj/Locked/, T.Cooldown) That is what I think may do it.

The comparison is failing. While del(src) is being done a line too early, neither of those lines will run when the comparison fails. Hence that won't solve this specific problem, even though it's a good idea regardless.

Lummox JR
In response to Lummox JR (#4)
Lummox JR wrote:
I see in your code that you're expecting T to be an obj. Presumably it is one, although the proc won't enforce that. T and the item in client.screen may display the same value when you convert them to text, expecially if they're the same type, but if they're not the exact same object then the comparison will fail.

For instance, if you're comparing a generic /obj/skill/climbing object you created to an /obj/skill/climbing object that was made separately for adding to an item in a player's client.screen, then you're comparing two different objects.

What you might want to do instead is not pass T as an object, but pass it as a type path instead. Then you can say if(istype(HK.skill, T)) or if(HK.skill && HK.skill.type == T) instead.

Lummox JR

Ahh I see, Thank you so much :D
In response to Lummox JR (#5)
spawn()
X
del(src)


will not run X. src is deleted which ends the proc. If you wanted to do this, you would need to instead use spawn(-1). Though, most likely spawn() isn't needed at all.