Check out the Pastebin Gadgets Shop. We have thousands of fun, geeky & affordable gadgets on sale :-)Want more features on Pastebin? Sign Up, it's FREE!
tweet

# Teleglitch items.csv generator

By: a guest on Oct 19th, 2013  |  syntax: Python  |  size: 1.89 KB  |  views: 111  |  expires: Never
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
1. import random
2.
3.
4. THINGS = []
5. LEVELS = 19
6.
7. class thing:
8.
9.     def __init__(self,name,prob,amount=[1,1],requireByLevel=LEVELS):
10.         self.name       = name
11.         self.prob       = prob
12.         self.amount     = amount
13.         self.requireByLevel = requireByLevel
14.         self.appeared   = False
15.         THINGS.append(self)
16.
17.     def get(self,level):
18.         #force generate
19.         if level >= self.requireByLevel and not self.appeared:
20.             self.appeared = True
21.             return '1'
22.         #generate nothing
23.         if random.randint(1,100) > self.prob: return ''
24.         #generate an amount
25.         self.appeared = True
26.         total = 0
27.         for i in xrange(self.amount[0]):
28.             total += random.randint(1,self.amount[1])
29.         return str(total)
30.
31.     def getline(self):
32.         txt = self.name
33.         for i in xrange(LEVELS):
34.             txt += ','+self.get(i)
35.         return txt+'\n'
36.
37.
38. thing('pystol',10)
39. thing('pump',5,[1,1],0)
40. thing('agl',5,[1,1],0)
41. thing('revolver',10,[1,1],1)
42. thing('automaat',10,[1,1],2)
43. thing('riflehv',10,[1,1],5)
44. thing('rifle',10,[1,1],8)
45. thing('lasgun',10,[1,1],10)
46. thing('taser',5,[1,1],18)
47. thing('pyammo',100,[2,3])
48. thing('ppammo',80,[1,2])
49. thing('revolverammo',75,[1,2])
50. thing('auammo',90,[1,2])
51. thing('hvammo',60,[1,3])
52. thing('riammo',90)
53. thing('pexpammo',100)
54. thing('battery',75,[1,3])
55. thing('smtimebomb',100,[2,3])
56. thing('timebomb',60)
57. thing('cmeat',100,[1,2])
58. thing('medkit',75,[1,1],True)
59. thing('smmedkit',95,[1,3])
60. thing('tube',80)
61. thing('fattube',15)
62. thing('emptycan',75)
63. thing('hardware',75)
64. thing('mchip',75,[1,2])
65. thing('metalplate',75,[1,3])
66. thing('motor',5)
67. thing('magnet',5)
68. thing('nailbox',95,[1,2])
69. thing('minigun',1,[1,1],18)
70.
71.
72. items = open('items.csv','w')
73. items.write('A level items:,1,2,3,4,5,6,7,8,9,10,2b,3b,4b,6b,8b\n')
74.
75. for i in THINGS:
76.     items.write(i.getline())
77.
78. items.close()
clone this paste RAW Paste Data
Top