/ld26

To get this branch, use:
bzr branch http://9ix.org/bzr/ld26

« back to all changes in this revision

Viewing changes to inventory.lua

  • Committer: Josh C
  • Date: 2013-04-28 18:52:51 UTC
  • Revision ID: josh@9ix.org-20130428185251-a9cpmdjiooz89gu5
s/basecode/ld26/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
Inventory = Class:extend {
2
2
   items = {},
3
 
   had = {},
4
3
   visible = true,
5
 
   nitems = 0,
6
4
   add = function(self, item)
 
5
            item.invTile.y = 10
 
6
            item.invTile.x = 50 * #self.items
7
7
            self.items[item.name] = item
8
 
            the.app.view:flash({0,255,0})
9
 
 
10
 
            item.invTile.y = 10
11
 
            item.invTile.x = 50 * self.nitems
12
 
 
13
 
            self.nitems = self.nitems + 1
14
8
         end,
15
 
   remove = function(self, name)
16
 
               self.had[name] = self.items[name]
17
 
               self.items[name] = nil
18
 
               self.nitems = self.nitems - 1
19
 
 
20
 
               local newindex = 0
21
 
               for _, item in pairs(self.items) do
22
 
                  item.invTile.x = 50 * newindex
23
 
                  newindex = newindex + 1
24
 
               end
25
 
            end,
26
9
   draw = function(self)
27
10
             for _, item in pairs(self.items) do
28
11
                item.invTile:draw()