I got this...
client+=new('Guns.dmi',"Colt 45",14,2)
and
client-=del('Guns.dmi',"Colt 45",14,2)
It doesn't work and I don't blame it, I made it up. Is there any easy way like so to add objects to my hud?
ID:164947
![]() Mar 22 2007, 2:58 pm
|
|
I still can't figure out an easy way to add objects to my hud. I want it to only show up once equipped. And of course to disappear once un-equipped. I've got a random code of like I thought up but of course it doesn't work.
I got this... client+=new('Guns.dmi',"Colt 45",14,2) and client-=del('Guns.dmi',"Colt 45",14,2) It doesn't work and I don't blame it, I made it up. Is there any easy way like so to add objects to my hud? |
You need to use client.screen instead of just client. Also, the objects truly are objects, so you'd have to do something like client.screen+=new/obj/hud/something.
|
Yeah, though you'd better have global screen objects (at least for your common always-on HUD) rather than creating an object for every single player. That way you don't only save objects, but you don't even need to call locate() to remove those screen objects later.
<small>Also, your code example isn't the simplest, you don't need to state the path twice in the locate() line and you don't even need the temp var to hold the reference first</small> |
Kaioken wrote:
Yeah, though you'd better have global screen objects (at least for your common always-on HUD) rather than creating an object for every single player. That way you don't only save objects, but you don't even need to call locate() to remove those screen objects later. You do still need to call locate(), I'm pretty sure. Also, your code example isn't the simplest, you don't need to state the path twice in the locate() line and you don't even need the temp var to hold the reference first I believe it makes it more efficient to place it in between the parentheses in locate() so it knows exactly what to check for. However, I'm not sure about that. The temporary variable is just so he knows what it's doing. Besides, he may want to do more with the object than just remove it. |
CaptFalcon33035 wrote:
Kaioken wrote: Eh, of course not. Did you think about it before being sure? example- obj/HUD I believe it makes it more efficient to place it in between the parentheses in locate() so it knows exactly what to check for. I believe it does just that ("places it between the parenthesis") when you compile. I think typecast statuses aren't compiled, I don't think there's any reason for them to be, anyway. |
obj |
In short, again, that method is flawed because you'll be creating a screen object for each player that uses that HUD, while you can just create a single object and re-use it for all players.
|
That's the simplest way I could think of to do this.