ID:1636048
 
(See the best response by GhostAnime.)
I am having a problem figuring out how to have items overlay implemented from different dmi files. Things work fine when I just copy the way its on in the framework, however having too many icons in one dmi file becomes a problem(crashing dream maker).

I am using Forum Account's framework to build the game and I can't seem to get this work .
This is the coding for items
item
icon = 'items.dmi'
overlay_icon = 'overlays.dmi'
map_icon = 'items.dmi'

iron_bar
name = "Iron Bar"
icon_state = "iron-bar"
map_state = "iron-bar-map"

stack_size = 20
count = 5
description = "Used for crafting\nThis\nis\na long\ndescription"

sword
name = "Sword"
icon_state = "sword"
description = "+5 Power"
overlay_state = "sword"
overlay_layer = 2
map_state = "sword-map"

slot = MAIN_HAND

equipped(mob/m)
m.overlay(src)
m.power += 5

unequipped(mob/m)
m.remove(src)
m.power -= 5

This where the overlay_icon is defined
item
parent_type = /obj

pwidth = 16
pheight = 16
pixel_x = -8
pixel_y = -8

var
slot = ""
in_slot = ""
stack_size = 0
count = 1
description = ""
cost = 0

overlay_icon = null
overlay_state = ""
overlay_layer = 1


And this is what I am trying to have
item/Armors
icon = 'items.dmi'
map_icon = 'items.dmi'
blackchestlvlone
--> overlay_icon = 'blackchest.dmi'
name = "Black Armor"
icon_state = "blackchest"
description = "+200 Defense"
overlay_state = "blackchest"
map_state = "blackchest-map"

slot = BODY
cost = 8

// make the armor actually give you +4 defense
equipped(mob/m)
m.overlay(src)
m.defense += 200

unequipped(mob/m)
m.remove(src)
m.defense -= 200

blackblackchestlvltwo
--> overlay_icon = 'blackchest2.dmi'
name = "Helmet"
icon_state = "blackhelmet"
description = "+110 Defense<br>-150 Rin"
overlay_state = "blackhelmet"
map_state = "blackhelmet-map"

slot = HEAD
cost = 5

equipped(mob/m)
m.overlay(src)

unequipped(mob/m)
m.remove(src)

blackchestlvlthree
overlay_icon = 'blackchest3.dmi'
name = "Black Armor"
icon_state = "blackchest"
description = "+320 Strength<br>+100 Defense"
overlay_state = "blackchest"
map_state = "blackchest-map"

slot = BODY
cost = 8

equipped(mob/m)
m.overlay(src)

unequipped(mob/m)
m.remove(src)


The main issue is that when I try switching between items, its like only one overlay_icon dmi file is being read.

Any help will be great. This is essential to continuing of the game.
Best response
How is your overlay() defined?
And do you remove the previous item (if equipped)?
yes, the items unequip. What happens is if I log in and equip an armor for the chest slot, this one will show. Then if I switch to another armor for the same slot, this one will not show until I re-log with it still equipped, or if I switch back to the first one, which will show again.

Here is how the overlay is defined
Overlay
var
base_state = ""
move_state = ""

mob
var
tmp/move_state = ""
tmp/list/equipment_overlays
tmp/__state = ""
tmp/__state_duration = 0

proc
state(i, d = 8)
__state = i
__state_duration = world.time + world.tick_lag * d

proc
remove(item/item)
if(!equipment_overlays)
equipment_overlays = list()

var/Overlay/overlay = equipment_overlays[item.slot]

if(overlay)
overlay.Hide()

overlay(item/item)

if(!istype(item))
return ..()

if(!equipment_overlays)
equipment_overlays = list()

var/Overlay/overlay

if(equipment_overlays[item.slot])
overlay = equipment_overlays[item.slot]
else
overlay = ..(item.overlay_icon, "")
equipment_overlays[item.slot] = overlay

overlay.base_state = item.overlay_state
overlay.Layer(layer + item.overlay_layer)
overlay.Show()

return overlay

set_state()

if(dead)
move_state = "dead"
else if(world.time <= __state_duration)
move_state = __state
else if(!moved)
move_state = STANDING
if(!on_ground)
move_state = JUMPING
if(dashing)
move_state = DASHING
if(sitting)
move_state = SITTING
if(laying)
move_state = LAYING
if(leaning)
move_state = LEANING
if(stanceone)
move_state = STANCEONE
if(stancetwo)
move_state = STANCETWO
else if(dashing)
move_state = DASHING
else if(!on_ground)
move_state = JUMPING
else
if(moved)
if(run == 1)
move_state = RUNNING
else
move_state = MOVING
else
move_state = MOVING

for(var/slot in equipment_overlays)
var/Overlay/o = equipment_overlays[slot]
if(!o) continue

if(o.move_state != move_state)
o.IconState("[o.base_state]-[move_state]")
o.move_state = move_state

icon_state = "[base_state]-[move_state]"