(Solved) How would i draw items in inventory?

baily18

  • Posts: 84
If i had an inventory table (like a 5x5 square) how would i draw the items in the inventory after getting them from the inventory list? Using Luyren's inventory behavior.

« Last Edit: January 29, 2012, 03:03:47 pm by baily18 »

coleislazy

  • *
  • Posts: 2607
The standard way would be to create an actor for each item. If it stores the actual actor in the list, you could use the "type of Actor" block to spawn a new one. If it just has the name as text, you can set an Actor Type attribute by using:
Code: [Select]
_MyActorType = getActorTypeByName("Some Name");
If you want to be really cool, you can just fetch the actor type, then draw its image directly to the screen buffer. In "when drawing":
Code: [Select]
g.drawImage(getImageForActorType(getActorTypeByName("Some Name")),_X,_Y,_Width,_Height,true);
Of course, then its just an image and you can't interact with it.

baily18

  • Posts: 84
This confuses me. Right now all i have is this and it doesn't create the items in the inventory.

« Last Edit: January 29, 2012, 01:38:14 pm by baily18 »

coleislazy

  • *
  • Posts: 2607
First, _MyActorType would be an Actor Type attribute you create. Then you can drop it into a normal "create actor" block.

Second, in the first code block, "Some Name" should be replaced with the name of the item you are going to spawn. I'm not familiar with this behavior, but the list "Inventory" probably just holds a list of names. If that's the case, you would change the code like to look like this:
Code: [Select]
_MyActorType = getActorTypeByName(item);
Again, _MyActorType is actually an Actor Type attribute you created. You can name it anything you want, just make sure to use its internal name in the code block (spaces and special characters removed, underscore prefixed).

Also, "item" is the same as the "current item" block in the "for each item in list" block.

baily18

  • Posts: 84
It works. Thanks!