GPWiki.org
GPWiki.org
It is currently Sat May 18, 2013 9:54 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Sun Nov 28, 2010 7:00 am 
Hi,

It seems I can't remember how to add items to a listbox that stacks together. So, for each Herb I add to the listbox, it gets added together. It's for a game. Any help would be appreciated.

Thanks.


Top
  
 
 Post subject:
PostPosted: Sun Nov 28, 2010 11:51 am 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2216
Location: England
Listbox1.AddItem("Parsley")

_________________
I ain't pushing no moon buttons.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 28, 2010 1:23 pm 
That only adds an item to the listbox. It'll just keep putting it in the listbox and not stack it.

Like this:

Herb 3

Not like this:
Herb
Herb
Herb

Hope that explains my problem further. =)


Top
  
 
 Post subject:
PostPosted: Sun Nov 28, 2010 1:29 pm 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2216
Location: England
Is this like an RPG inventory?

If so I would recommend against using the listbox to store the inventory.

I would recommend using an structured array Inventory(), with two properties:

Inventory().ItemId
Inventory().Quantity

And if you really want a listbox as part of your GUI, then construct it from your inventory array:

Code:
Listbox1.Clear
For i = 1 to 16
  temp$ = Items(Inventory(i).ItemId).ItemName
  if Inventory(i).Quantity > 1 then temp$ = temp$ & " " & STR$(Inventory(i).Quantity)
  Listbox1.AddItem(temp$)
Next

_________________
I ain't pushing no moon buttons.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 28, 2010 11:32 pm 
Hi. =)

Using the listbox isn't recommended? Why's that? Is it limited on what it can do?

Yeah, I'm working on a RPG. Very very simple one.

I'm gonna try this out. Is there any other method though?


Thank you very much for your help! <3


Top
  
 
 Post subject:
PostPosted: Mon Nov 29, 2010 4:43 am 
Ankle Nibbler

Joined: Tue Jun 29, 2010 6:41 pm
Posts: 129
Hellos wrote:
Hi. =)

Using the listbox isn't recommended? Why's that? Is it limited on what it can do?

Yeah, I'm working on a RPG. Very very simple one.

I'm gonna try this out. Is there any other method though?


Thank you very much for your help! <3


The reason why it is not recommended is because of the way it is structured. Like you said, it is rather limited.

Like Jasmine said, a structured array, or even just a plain 2D array would do much better. People do not like using this because there is logic required when drawing. In the end, it looks hundreds of times better than a list box and you have full control over it.

A listbox in a game doesn't work that nice. Come to think about it... No Windows GUI looks nice in games :S

Textboxes, listboxes, checkboxes, menu's, etc. all of that looks hideous in a game.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 29, 2010 6:06 am 
Thanks for clearing that up Zappy.

Now if only the code could make sense to me. o.o


Thanks again!


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group