I am using the grid to show the user his/her available spells, which can then be cast by clicking. Here is the code that updates the list of spells:
UpdateSpells()
var/count=1
var/tmp/list/allspells=new()
usr.spells=null
allspells+=new/obj/magic/windbreeze
allspells+=new/obj/magic/windgust
allspells+=new/obj/magic/windblast
allspells+=new/obj/magic/windstorm
allspells+=new/obj/magic/tornado
allspells+=new/obj/magic/cook1
allspells+=new/obj/magic/lightlogs
allspells+=new/obj/magic/fireball
allspells+=new/obj/magic/cook2
allspells+=new/obj/magic/fireblast
allspells+=new/obj/magic/cook3
allspells+=new/obj/magic/firestorm
allspells+=new/obj/magic/breathefire
allspells+=new/obj/magic/waterball
allspells+=new/obj/magic/telekaishi
allspells+=new/obj/magic/telekminor
allspells+=new/obj/magic/heal1
allspells+=new/obj/magic/waterblast
allspells+=new/obj/magic/telesd
allspells+=new/obj/magic/heal2
allspells+=new/obj/magic/telekmajor
allspells+=new/obj/magic/waterstorm
allspells+=new/obj/magic/heal3
allspells+=new/obj/magic/whirlpool
allspells+=new/obj/magic/alchemize1
allspells+=new/obj/magic/deposititem
allspells+=new/obj/magic/alchemize2
allspells+=new/obj/magic/withdrawitem
allspells+=new/obj/magic/alchemize3
for(var/obj/magic/O in allspells)
if(O.levelreq<=usr.magic)
usr<<output(O,"spellswindow.spellsgrid:[count++]")
and here is a picture of what happens:
The strange thing is that everything works perfectly and all of the spells show up properly, but after a few seconds, a few of them change to objs. Each time this happens, it's different spells that transform. Really stumped on this.