ID:264880
 
Code:
Questlog()
var/items = 0
if(!winexists(src,"Questlog"))
winclone(src,"questlog","Questlog")
winshow(src, "Questlog",1)
winset(src, "Questlog.questgrid","cells=null")
for(var/obj/Questholder/H in src.contents)
del H
for(var/obj/Questholder/X in src.Questlog)
var/obj/Questholder/Q = new X.type
Q.completed = X.completed
src.contents += Q
for(var/obj/Questholder/G in src.contents)
winset(src, "Questlog.questgrid","current-cell=1,[++items]")
src << output(G, "Questlog.questgrid")
if(usr.Questlog.len == 0)
usr.Fill_Quest_Window("Clear")
return
for(var/obj/Questholder/F in src.contents)
usr.view_quest = F
usr.Fill_Quest_Window(F)
break
winset(src,"Questlog.questgrid","cells=1x[items]")


Problem description:

Currently I'm working on revamping the quest system for my game. For some strange reason, whenever this proc is called the first time, if there's only one quest in the log, it won't display anything in the grid, yet it'll still load up the information is display it (via Fill_Quest_Window). That means that there most certainly is a quest in the contents. Why will the grid not fill properly? It does should there be more than one quest in the log, but not for a single.

And, on occasion, even when there is more than one, it doesn't fill properly. It makes the cells for the quests that are there, since the lines show up, but there is nothing put into those cells.

Your last winset is cutting things off, more than likely. Is your grid set to a flexible list? If so, then it probably is.

Also, try replacing
winset(src, "Questlog.questgrid","current-cell=1,[++items]")
src << output(G, "Questlog.questgrid")

with this
src<<output(G,"Questlog.questgrid:1,[++items]")



Also might I just mention you've got a lot of redundant loops and checks there? No point checking all for() loops if the len is 0 in the first place, and a lot of those loops can be combined.

for(var/obj/Questholder/X in src.Questlog)
var/obj/Questholder/Q = new X.type
Q.completed = X.completed
src.contents += Q
src<<output(Q,"Questlog.questgrid:1,[++items]")


For example.


Also, if none of the above have any effect, you'll probably have to show yuor Fill_Quest_Window proc.
If this is a proc and not a verb, then usr is inappropriate there. You should change that to src instead, and also remember to bail out if src.client is null.

Lummox JR
In response to Lummox JR (#2)
Thanks for the advice. I'm still learning when it comes to this stuff. It worked emasym, thanks.

And good catch on those usr's Lummox, I missed those ones. Thanks.