ID:144012
 
Code:
mob/verb/Show_Equip()

src << browse_rsc('None.dmi',"Neck")
src << browse_rsc('None.dmi',"Helmet")
src << browse_rsc('None.dmi',"Back")
src << browse_rsc('None.dmi',"Weapon")
src << browse_rsc('None.dmi',"Armor")
src << browse_rsc('None.dmi',"Shield")
src << browse_rsc('None.dmi',"Legs")
src << browse_rsc('None.dmi',"Boots")

if(Neck)
src << browse_rsc(Neck:icon,"Neck")
if(Helmet)
src << browse_rsc(Helmet:icon,"Helmet")
if(Back)
src << browse_rsc(Back:icon,"Back")
if(Weapon)
src << browse_rsc(Weapon:icon,"Weapon")
if(Armor)
src << browse_rsc(Armor:icon,"Armor")
if(Shield)
src << browse_rsc(Shield:icon,"Shield")
if(Legs)
src << browse_rsc(Legs:icon,"Legs")
if(Boots)
src << browse_rsc(Boots:icon,"Boots")

src << browse({"
<html>
<body background="back.jpg" text="lime">
<table border=2 cellpadding=5>
<tr>
<td><img src='Neck'></td><td><img src='Helmet'></td><td><img src='Back'></td>
</tr>
<tr>
<td><img src='Weapon'></td><td><img src='Armor'></td><td><img src='Shield'></td>
</tr>
<tr>
<td></td><td><img src='Legs'></td><td></td>
</tr>
<tr>
<td></td><td><img src='Boots'></td><td></td>
</tr></table>
<a href='?src=\ref
[src];CloseWindow=Equip'>Close</a>
</body>
</html>"}
,"window=Equip;size=200x280;can_close=0;can_resize=0;titlebar=0")


mob/Topic(href,href_list[])
switch(href_list["CloseWindow"])
if("Equip")
usr << browse(null,"window=Equip")
else
return ..()


Problem description:
My player has several obj vars.
mob
var
obj/Equipment
Neck = null
Helmet = null
Back = null
Weapon = null
Armor = null
Shield = null
Legs = null
Boots = null

As you can see in the problem code...
  • At the beggining, I erase all icons.
  • THEN I give icons only for the objects that are actually equipped.

    Them problem is that: let's suppose you have one object per kind (a Neck, a Helmet, etc).
    All of the equipment is equipped.
    You unequip TWO of those objects.
    When you press Show_Equip, only one object has the 'None.dmi' as their icon. The other one has their actual icon, even tho it is NOT equipped.

    Why?
    How can it display an icon that isn't even.. you know, detected?
    (If this explanation was no good, please tell)

    Thanks.
I had a problem that sounds similar to yours a long time ago. I don't remember if I ever came up with a solution, but here's a link to the post.
Cache problem PROOF!
Just a little heads up.

Inside of the browse_rsc() reference:
Note that no data is transmitted if it already exists in the user's cache, so there is little overhead in calling this every time you are about to use browse().
In response to Keeth
Then how would I manually delete files on my cache?
Taht would fix the problem, right? Since the data would be transmitted then.
In response to Gooseheaded
You can't delete a file from the cache. So you can't update the same file, you have to use a different, unique filename each time.
In response to Kaioken
A good work-around is, rather than caching it as "Helmet", cache the name or type of the helmet.

obj
equipment
helmet
spiked_helmet
name = "Spiked Helmet"
icon = 'icon.dmi'

mob/var
obj/equipment
Helmet = new /obj/equipment/helmet/spiked_helmet

mob/verb/display_equipment()
// cache the equipped object icon files, possibly along with "none.png"
src << browse_rsc(src.Helmet.icon,"[src.Helmet.name].png")
// that will save the image as "Spiked Helmet.png".
var/html = {"
<img src='
[src.Helmet ? "[src.Helmet.name].png" : "none.png"]'>
"}

usr << browse(html)


In a sense, it's more efficient, but it will eventually take up a few more bytes than the previous version.
Just make sure people aren't going around renaming helmets and such.
It'll essentially just cause problems for the player, but just for efficiency reasons.

If the file you're trying to cache already exists, it should just skip right over it, so it won't weigh down the server every time you use the procedure.
In response to Keeth
Keeth wrote:
A good work-around is, rather than caching it as "Helmet", cache the name or type of the helmet.

It doesn't have any advantage, perhaps except that other games are more likely to use the same "Helmet" filename as well than they are to use the same type path.
At any case it depends on exactly what icon you're displaying.