What exactly are you trying to do with your lists? I've just been using them for my inventory system. I don't know if this will be relevant to what you're doing with them, but I can do my best to help if they are.
This is aimed at an inventory, but I suspect it's possible for you to adapt it for how you want to use your lists.
In addition for explanations of Grids and lists, this XNA tutorial from 3D Buzz goes into a certain amount of depth (though no code is shared in that tut) and in a way that's understandable for even a complete newbie - I think they cover it fairly early on in the tut too.
Linky
Anyway, first off, the UDT.
type Inventory
name as string
effect as string
modifier as integer
count as integer
equip as boolean
desc as string
endtype
The inventory itself is defined by a number of 'slots', those slots are actually the list.
Lets say:
dim Item(20) as Inventory
That's an inventory of 19 slots. I use 20 because 1 slot will be a dummy, so when it comes to the code where I'm selecting an empty slot, slot '20' won't cause for the last slot to be selected or an error saying, "Array doesn't exist" when the 'next x' starts at 20. There's other ways of dealing with it (and you'll see what I mean when you get to it), however, that's how I've done it.
Then I have an Update function (to be used in your loop) to check what 'item' is currently in each slot.
For example:
function UpDateInv()
`Check each slot
for x = 1 to 19
`Check is it's a stamina and give it stamina's properties
if Item(x).name = "Stamina"
Item(x).effect = "Health"
Item(x).modifier = 100
Item(x).desc = "Restores a little health"
endif
`Focus
if Item(x).name = "Focus"
Item(x).effect = "MP"
Item(x).modifier = 50
Item(x).desc = "Restores a little concentration"
endif
`Stamina Plus
if Item(x).name = "Stamina Plus"
Item(x).effect = "Health"
Item(x).modifier = 500
Item(x).desc = "Restores moderate health"
endif
`WEAPONS
`SWORDS
`Blade
if Item(x).name = "Blade"
Item(x).effect = "Sword"
Item(x).desc = "A Bladed Weapon"
Item(x).modifier = 20
endif
`GUNS
`Pistol
if Item(x).name = "Pistol"
Item(x).effect = "Gun"
Item(x).desc = "A basic firearm"
Item(x).modifier = 20
endif
next x
endfunction
So all the code needs to do is check the names of each slot and then apply stats to them. I also use 'effect' to decide what they actually do. 'Health' and 'MP' items can be used in the item menu, whilst 'Sword' and 'gun' can be equipped.
To add a new item to the list, obviously, you adjust it to your needs, mine has the player and scene item collide and the play hit enter to add it to the list. In fact, the scene itself has its own list, its list contains any items in the scene, so the code has to tell it to remove that item and add it to the player's list, hence the variable 'scene' is needed. I've not posted any scene code, so if you need explanations, I can provide.
function CheckPickUp(obj$, scene)
`If the object exists
if object exist(pick)
`If player touches item
if object collision( Pick, Cha(keats).object) = 1
`Show 'Pick Up' Text
d3d_starttext
Border_Text(1,10, 20, 0, "Pick Up " + obj$)
d3d_endtext
`If Player hits action
if returnkey() = 1
`Check slots
for x = 1 to 20
`Check if there's an empty slot and select it
if Item(x).count = 0 and x < 20 then slot = x : x = 19
`Check if player already has the item and use its slot
if Item(x).name = obj$ then slot = x : x=19
next x
`Add item to selected slot
Item(slot).name = obj$
`Pick Up Item
PickUp(slot, scene)
endif
endif
endif
endfunction
function PickUp(obj, scene)
`Dispaly 'pick up text'
text 10,20, "Pick Up " + Item(obj).name
`Resposition picked up object out of scene
position object Pick, -2000, -2000,-2000
`Add item to inventory
inc Item(obj).count, 1
`Tell scene you've picked it up
scene(scene).Inv.got = 1
`Tell the save system you've picked it up
sItem(scene) = 1
endfunction
I also add a 'default items' function too, which looks like this:
function DefaultInv()
`SET UP WITH SLOTS
Item(1).name = "Stamina"
Item(1).count = 10
Item(2).name = "Focus"
Item(2).count = 5
Item(3).name = "Blade"
Item(3).count = 1
Item(3).equip = 1
Item(4).name = "Pistol"
Item(4).count = 1
item(4).equip = 1
endfunction
Because of the 'Update' function earlier, you only really need to use the item's name and quantity to add it - the stats will follow or for the case of weapons, you may wish to tell the code it's equipped.
So as you add new items to your list they will stack. The only trouble is, if you remove an item that's not at the bottom, you've got an unused slot at the top. For this I wrote a 'stack' function:
`Stack the inventory
function Stack()
`Check each slot
for x = 1 to 19
`If slot is empty
if Item(x).count = 0
`Replace it with next item
Item(x).count = item(x+1).count
Item(x).name = item(x+1).name
`Make next slot empty
Item(x+1).count = 0
endif
next x
endfunction
Basically it checks if there's an empty slot, gets the item from that slot, adds it then clears that slot. All I'm left with to figure out is how to 'sort' my lists...if I work something out I could keep you posted, but so far, I've not even thought about it, but I suspect I'd need to write a parser for it.
Also, here's something that should demonstrate the functionality for the items on the list:
In a x = 0 to total for/next loop (which is, total number of slots filled)
if Item(x+1).effect = "Health"
if returnkey() =1 and release = 0 then inc cha(keats).hp, item(x+1).modifier : dec Item(x+1).count, 1 : release = 1 : inc pause, 1
endif
To break it down, if it reads that 'Health' is the 'effect' or should I say 'restore health' then you'll increase the player's health by what is defined by the modifier, in this case (if you look at the UpdateInv()), you're see it'll increase by 100. This way you can create multiple items with the same function, but differ in effectiveness.
To work out the total number of 'filled' slots you can do this:
for x = 1 to 19
if Item(x).count > 0 then total = x
next x
Then use that total to make a 'for x = 1 to total' loop and display all of names of the variables inside of your list:
Text 50, 60+h, Item(x).name : inc h, 30
Before the 'for x= 1 to total' loop include 'h = 0'.
If that sounds like what you want, I'm happy to go into more depth if there's anything that needs explaining.
You've got my email, you've got me on Skype and Facebook so there's more ways than one for me to chat.
If it's not what you're looking for, then best of luck and hope you find the solution you need.
[Edit]
It occurs to me that there's a number of typos in my comments...I don't proofread them.
[edit2] Demonstration of the above functionality (just with equipment added):
http://www.youtube.com/watch?v=m0Bx8AQ1P7U