/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-29 01:28:50 UTC
  • Revision ID: josh@9ix.org-20130429012850-7p3xcwad2er011wo
remove someone who isn't there

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
   items = {},
3
3
   had = {},
4
4
   visible = true,
 
5
   nitems = 0,
5
6
   add = function(self, item)
6
 
            item.invTile.y = 10
7
 
            item.invTile.x = 50 * #self.items
8
7
            self.items[item.name] = item
9
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
10
14
         end,
11
15
   remove = function(self, name)
12
16
               self.had[name] = self.items[name]
13
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
14
25
            end,
15
26
   draw = function(self)
16
27
             for _, item in pairs(self.items) do