/traderous

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

« back to all changes in this revision

Viewing changes to planet.lua

  • Committer: Josh C
  • Date: 2013-06-25 18:23:38 UTC
  • Revision ID: josh@9ix.org-20130625182338-gkx8evr4z93zh9x7
load/save (not working yet)

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
       low = 5000, med = 6000, high = 8000,
12
12
       chance = 0.1}
13
13
   },
14
 
   potentialNames = {
15
 
      'Planet A',
16
 
      'Planet B',
17
 
      'Planet C',
18
 
      'Planet D',
19
 
      'Planet E',
20
 
      'Planet F',
21
 
   },
22
14
   goods = {},
23
15
   onNew = function (self)
24
16
              self.indicator = Tile:new{ image = 'data/planet1ind.png' }
25
17
              the.indicators:add(self.indicator)
26
18
 
27
 
              while not self.name do
28
 
                 local name = self.potentialNames[math.random(#self.potentialNames)]
29
 
                 local inUse = false
30
 
                 for _, planet in ipairs(the.planets.sprites) do
31
 
                    if name == planet.name then inUse = true end
32
 
                 end
33
 
 
34
 
                 if not inUse then
35
 
                    self.name = name
36
 
                 end
37
 
              end
38
 
 
39
19
              while #self.goods == 0 do
40
20
                 for _, good in ipairs(self.potentialGoods) do
41
21
                    if math.random() < good.chance then
69
49
                                                  goods = the.player.goods,
70
50
                                                  cargoSpace = the.player.cargoSpace
71
51
                                               }
 
52
                       print('saving')
72
53
                       the.storage:save()
 
54
                       print('finished saving')
73
55
 
74
56
                       tradeView = TradeView:new{ planet = self }
75
57
                       tradeView:activate()