ID:140284
 
Code:
UpdateSkillList(obj/o)
var/ycount=1
if(o) SkillList+=o
for(var/A in SkillList)
if(!A||!SkillList) return 0
var/obj/SkillList/B=new A(src)
src<<output(B,"GridSkills:1,[ycount]")
src<<output("[B.desc]","GridSkills:2,[ycount]")
ycount++


Problem description: The object B gets a tag in New() to counter garbage collection, but that's not the problem. The problem is that it plainly doesn't appear in the grid at all. Which makes no sense, cause it works in my other projects just fine. I can output B to world just fine, and I'll see everything the way I want it, it just won't go in the grid. :<

If you output a temporary obj to the grid, it won't stay there. The obj has to exist beyond just the output() call. Store the objs you'll be using in a list, and only create or delete them on an as-needed basis.

Lummox JR
In response to Lummox JR
Negative. It's not being collected by garbage collection. It has a tag, AND it's in a list.
In response to Emasym
Emasym wrote:
Negative. It's not being collected by garbage collection. It has a tag, AND it's in a list.

The code you posted shows object B being created and it's object B that's output. B has no tag.

As for whether it's in a list, I see it being created with src as the argument. If src is an atom, then B is being added to src.contents. If not, then that argument will be ignored unless your New() proc for the skill type is doing something with it.

As far as I can see from the code you posted, B does appear to be garbage collected. However, that's not to say this is the only possible way it won't appear in a list. If you didn't set up the number of cells in your grid, then cell 1,1 doesn't exist.

Lummox JR
In response to Lummox JR
I found out the problem. Apparently, the GRID was messing around with certain cells. I had to change it to;

var/obj/SkillList/B = new A
B.CustomNew(src) // No garbage.
src<<output(B,"GridSkills:1,[ycount]")
src<<output("[B.desc]","GridSkills:1,[ycount+1]") // ycount+1
ycount+=2 // +2 in total


In my head, this is making no sense at all. X being horizontal, Y vertical, why do I need to change Y to get it next to 1,1? Gotta change it to 2,1 instead of 1,2. Argh. Well, it's working, but whaaaaat.

EDIT: And just for clarification, yes, I did add everything in the object's New().
If you're using tags to protect those objects from garbage collection, then you've just created a memory leak. That's bad.

Just stick to storing them in a list.
In response to Emasym
Based on both the problem and the solution, I suspect you set up the grid as a list instead of a true grid.

Lummox JR
In response to Lummox JR
Wasn't aware there was such a thing. With the solution, it works fine, and everything gets display as I want it to, that is:
<code>Object | Description Object | Description</code>

Image of the Grid settings:
http://i161.photobucket.com/albums/t217/Mysame/IsAGrid.jpg

(Just to avoid further confusion I'd very much wish to find the actual problem x.x)


Oh, do you mean this behaviour is caused by "Flexible list of entries"? >.>;
If so, it's pretty darn nice of it to get it exactly right at the moment (2 columns, flexible rows), because I wouldn't know where I've defined that.
In response to Emasym
Emasym wrote:
Oh, do you mean this behaviour is caused by "Flexible list of entries"? >.>;

Yes. As documented, this causes the grid to behave as a 1-dimensional list, so it chooses how many columns and rows it will need to display the data neatly.

Lummox JR
In response to Lummox JR
Cheers Lummox. Muchos babies.