Advertisement
demon012

ThaumComp

Aug 12th, 2013
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.67 KB | None | 0 0
  1. ThaumComp = {--{{{
  2. wirelessModem = rednet.open("top"),
  3. aeCompID = 27,
  4. page = 1,
  5. recipesPerPage = 18,
  6. recipes = {
  7. ['Arcane Transmutator: Dull Shard'] = {['praecantatio'] = 8, ['vitreus'] = 8},
  8. ['Gold Transmutation'] = {['metallum'] = 2, ['carus'] = 1,},
  9. ['Nitor'] = {['ignis'] = 4, ['lux'] = 6, ['potentia'] = 4,},
  10. ['Thaumium'] = {['metallum'] = 8, ['praecantatio'] = 4,},
  11. ['Spellbinding Cloth'] = {['permutatio'] = 8, ['praecantatio'] = 6, ['pannus'] = 4,},
  12. ['Gaseous Tenebrae'] = {['tenebris'] = 2, ['aura'] = 6,},
  13. ['Alumentum'] = {['fractus'] = 3, ['ignis'] = 6, ['potentia'] = 6,},
  14. ['Gunpowder'] = {['fractus'] = 6, ['ignis'] = 6,},
  15. ['Iron Transmutation'] = {['metallum'] = 2,},
  16. ['Transvector Interface'] = {['machina'] = 6, ['permutatio'] = 6,},
  17. ['Interface Binder'] = {['potentia'] = 6, ['machina'] = 6,},
  18. ['Metabolic Frame'] = {['lignum'] = 6, ['permutatio'] = 8, ['praecantatio'] = 2, ['victus'] = 4,},
  19. ['Necrotic Frame'] = {['lignum'] = 6, ['permutatio'] = 12, ['praecantatio'] = 2, ['mortuus'] = 6,},
  20. ['Resilient Frame'] = {['lignum'] = 12, ['permutatio'] = 8, ['praecantatio'] = 2,},
  21. ['Magic Frame'] = {['lignum'] = 4, ['praecantatio'] = 2,},
  22. ['Gentle Frame'] = {['lignum'] = 4, ['praecantatio'] = 2, ['victus'] = 8,},
  23. ['Concentrated Compound'] = {['messis'] = 12,},
  24. ['Wand of the Adept'] = {['praecantatio'] = 16,},
  25. ['Gaseous Glowstone'] = {['aura'] = 8,},
  26. ['Wand of the Tinkerer'] = {['praecantatio'] = 16, ['vacuous'] = 12,},
  27. ['Magic Tallow'] = {['corpus'] = 4,},
  28. ["Thaumaturge's Backpack"] = {['praecantatio'] = 10, ['permutatio'] = 12, ['vacuos'] = 16, },
  29. ["Thaumium Chest"] = {['metallum'] = 64, ['praecantatio'] = 16, ['vacuos'] = 20, },
  30. ['Wand of Fire'] = {['ignis'] = 16, ['telum'] = 4,},
  31. ['Pickaxe of the Core'] = {['instrumentum'] = 16, ['metallum'] = 8, ['ignis'] = 16, ['visum'] = 8,},
  32. ['Goggles of Revealing'] = {['mutatio'] = 8, ['praecantatio'] = 8, ['visum'] = 8,},
  33. ['Shovel of the Earthmover'] = {['fabrico'] = 8, ['instrumentum'] = 16, ['fractus'] = 8, ['solum'] = 16,},
  34. ['Wand of Excavation'] = {['instrumentum'] = 4, ['metallum'] = 16,},
  35. ['Wand of Frost'] = {['telum'] = 4, ['gelum'] = 16,},
  36. ['Axe of the Stream'] = {['instrumentum'] = 16, ['lignum'] = 8, ['motus'] = 8, ['aqua'] = 16,},
  37. ['Ender Mirror'] = {['instrumentum'] = 8, ['visum'] = 6, ['alienis'] = 12,},
  38. ['Hoe of Growth'] = {['instrumentum'] = 16, ['herba'] = 16, ['messis'] = 8, ['victus'] = 8,},
  39. ['Wand of Equal Trade'] = {['instrumentum'] = 4, ['permutatio'] = 16,},
  40. ['Wand of Lightning'] = {['potentia'] = 16, ['telum'] = 4,},
  41. ['Sword of the Zephyr'] = {['motus'] = 8, ['fractus'] = 8, ['telum'] = 16, ['aura'] = 16,},
  42. ['Wand of Dislocation'] = {['permutatio'] = 14, ['vinculum'] = 12,},
  43. ['Wand of Uprising'] = {['aura'] = 6, ['volito'] = 12,},
  44. ['Magical Hand Mirror'] = {['instrumentum'] = 16,},
  45. ['Arcane Bellows'] = {['motus'] = 16, ['aura'] = 24,},
  46. ['Hungry Chest'] = {['motus'] = 8, ['vacuos'] = 8, ['animus'] = 4,},
  47. ['Portable Hole'] = {['permutatio'] = 16, ['vacuos'] = 24, ['alienis'] = 24,},
  48. ['Mirrored Glass'] = {['vitreus'] = 4, ['visum'] = 4,},
  49. ['Magic Mirror'] = {['motus'] = 16,},
  50. ['Infernal Bracelet'] = {['metallum'] = 12, ['ignis'] = 8, ['saxum'] = 6,},
  51. ['Void Capsule'] = {['permutatio'] = 8, ['vacuos'] = 16, ['alienis'] = 2,},
  52. ['Arcane Levitator'] = {['machina'] = 8, ['motus'] = 8, ['solum'] = 8, ['volito'] = 8,},
  53. ['Boots of the Traveller'] = {['motus'] = 24, ['aqua'] = 8, ['tutamen'] = 8, ['solum'] = 8, ['volito'] = 16,},
  54. ["Traveller's Paving Stone"] = {['motus'] = 16, ['solum'] = 8, ['saxum'] = 8, ['volito'] = 8,},
  55. ['Warded Chest'] = {['praecantatio'] = 16, ['vacuos'] = 12,},
  56. ['Rune Thanatos'] = {['potentia'] = 12, ['praecantatio'] = 20, ['mortuus'] = 16,},
  57. ['Arcane Ear'] = {['machina'] = 8, ['sonus'] = 16, ['aura'] = 8,},
  58. ['Arcane Door'] = {['imperito'] = 4, ['cognito'] = 4, ['machina'] = 8,},
  59. ['Arcane Pressure Plate'] = {['imperito'] = 4, ['cognito'] = 4, ['machina'] = 4,},
  60. ['Talisman of Withhold'] = {['cognito'] = 12, ['vinculum'] = 18, ['malum'] = 6,},
  61. ['Brain in a Jar'] = {['cognito'] = 8, ['malum'] = 8, ['animus'] = 8,},
  62. ['Advanced Stone Golem Worker'] = {['cognito'] = 16, ['animus'] = 8, ['victus'] = 8,},
  63. ['Advanced Clay Golem Worker'] = {['cognito'] = 16, ['animus'] = 8, ['victus'] = 8,},
  64. ["Goliath's Leggings"] = {['tutamen'] = 16, ['bestia'] = 16,},
  65. ['Stone Golem Worker'] = {['animus'] = 8, ['victus'] = 8,},
  66. ['Clay Golem Worker'] = {['animus'] = 8, ['victus'] = 8,},
  67. ['Tallow Golem Worker'] = {['animus'] = 8, ['victus'] = 8,},
  68. ['Decanting Golem'] = {['cognito'] = 16, ['animus'] = 8, ['victus'] = 8,},
  69. ['Golemancy'] = {['imperito'] = 8, ['animus'] = 8,},
  70. ['Wood Golem Worker'] = {['animus'] = 8, ['victus'] = 8,},
  71. ['Straw Golem Worker'] = {['animus'] = 8, ['victus'] = 8,},
  72. ['Crystal Clusters'] = {['vitreus'] = 8, ['praecantatio'] = 8, ['permutatio'] = 8,},
  73. ['Flux Filter'] = {['permutatio'] = 8, ['purus'] = 8,},
  74. ['Arcane Alembic'] = {['vitreus'] = 8, ['aqua'] = 8, ['aura'] = 8,},
  75. ['Talisman of Remedium'] = {['instrumentum'] = 12, ['sano'] = 16, ['cognito'] = 18, ['praecantatio'] = 10,},
  76. ['Golem Animation Core: Perception'] = {['Visum'] = 12,},
  77. ['Golem Animation Core: Speed'] = {['motus'] = 12,},
  78. ['Cryogenic Globe'] = {['tempus'] = 6, ['victus'] = 6, ['gelum'] = 12,},
  79. ['Aphrodisiac Concoction'] = {['imperito'] = 5, ['solum'] = 6, ['victus'] = 12,},
  80. ['Golem Animation Core: Strength'] = {['potentia'] = 12,},
  81. ['Golem Animation Core: Intelligence'] = {['cognito'] = 12,},
  82. ['Wand of the Thaumaturge'] = {['praecantatio'] = 32,},
  83. ['Crystal Capacitor'] = {['vitreus'] = 16, ['praecantatio'] = 16, ['permutatio'] = 16,},
  84. ['Crystal Core'] = {['mutatio'] = 8, ['praecantatio'] = 8, ['vacuos'] = 8, ['alienis'] = 8,},
  85. ['Arcane Transmutator'] = {['mutatio'] = 24, ['permutatio'] = 48,},
  86. ['Stopwatch of the Timetwister'] = {['machina'] = 20, ['tempus'] = 12,},
  87. ['Iron Golem Guardian'] = {['tutamen'] = 12, ['telum'] = 12, ['animus'] = 12, ['victus'] = 12,},
  88. ['Tool Dynamism Tablet'] = {['imperito'] = 16, ['machina'] = 16, ['motus'] = 8, ['praecantatio'] = 12,},
  89. ['Arcane Bore'] = {['potentia'] = 32, ['machina'] = 12, ['motus'] = 16, ['metallum'] = 64, ['vacuos'] = 24,},
  90. ['Sigil of Memories'] = {['machina'] = 12, ['motus'] = 16, ['alienis'] = 4,},
  91. ['Rod of the Nine Hells'] = {['ignis'] = 32, ['malum'] = 32, ['bestia'] = 32,},
  92. ['Advanced Thaumostatic Magnetizer'] = {['potentia'] = 12, ['machina'] = 6, ['motus'] = 16, ['corpus'] = 4,},
  93. ['Thaumostatic Magnetizer'] = {['imperito'] = 6, ['potentia'] = 12, ['metallum'] = 16,},
  94. ['Thaumostatic Harness'] = {['potentia'] = 24, ['machina'] = 32, ['tutamen'] = 16, ['aura'] = 24, ['volito'] = 64,},
  95. ['Hyperenergetic Nitor'] = {['potentia'] = 20, ['lux'] = 32, ['ignis'] = 16,},
  96. ["Reaper's Scythe"] = {['malum'] = 6, ['animus'] = 30, ['mortuus'] = 24, ['victus'] = 12,},
  97. ["Crystal of Sunlight"] = {['vitreus'] = 10, ['aer'] = 6, ['ignis'] = 12,},
  98. ["Crystal of Rainfall"] = {['vitreus'] = 10, ['aqua'] = 12, ['aer'] = 6,},
  99. ["Tiny Spectacles"] = {['visum'] = 8},
  100. ["Fortunate Maul"] = {["instrumentum"] = 25, ['carus'] = 25, ['praecantatio'] = 12, ['tenebris'] = 4},
  101. }
  102. }--}}}
  103. function ThaumComp:readNumber()--{{{
  104. local key = nil
  105. local amount = ""
  106. while key ~= 28 do
  107. event, key = os.pullEvent("key")
  108. if key > 1 and key < 12 then
  109. if key == 11 then
  110. key = 0
  111. else
  112. key = key - 1
  113. end
  114. io.write(tostring(key))
  115. amount = amount .. tostring(key)
  116. elseif key == 14 then
  117. local termX, termY = term.getCursorPos()
  118. termX = termX - 1
  119. term.setCursorPos(termX, termY)
  120. io.write(' ')
  121. term.setCursorPos(termX, termY)
  122. amount = amount:sub(0, amount:len() - 1)
  123. end
  124. end
  125. print("")
  126.  
  127. return tonumber(amount)
  128. end--}}}
  129. function ThaumComp:readYesNo()--{{{
  130. local key = nil
  131. local amount = ""
  132. while key ~= 28 do
  133. event, key = os.pullEvent("key")
  134. if key == 21 or key == 49 then
  135. if key == 21 then
  136. return true
  137. else
  138. return false
  139. end
  140. end
  141. end
  142. return false
  143. end--}}}
  144. function ThaumComp:resetTerm()--{{{
  145. term.clear()
  146. term.setCursorPos(1,1)
  147. end--}}}
  148. function ThaumComp:powerOnMenu()--{{{
  149. self:resetTerm()
  150. print('How many minutes do you want to turn AE on for?')
  151. minutes = self:readNumber()
  152. seconds = minutes * 60
  153. rednet.send(self.aeCompID, 'powerOnFor ' .. tostring(seconds))
  154. self:resetTerm()
  155. end--}}}
  156. function ThaumComp:requestMenu(recipe)--{{{
  157. self:resetTerm()
  158. print('How many of ' .. recipe .. ' do you want.')
  159. amount = self:readNumber()
  160. self:resetTerm()
  161. return amount
  162. end--}}}
  163. function ThaumComp:getRecipeAspects(recipe)--{{{
  164. local recipeAmount = self:requestMenu(recipe)
  165. local getAspects = true
  166.  
  167. if recipeAmount ~= nil then
  168. if recipeAmount == 1 then
  169. getAspects = self.recipes[recipe]
  170. elseif recipeAmount > 1 then
  171. aspects = self.recipes[recipe]
  172. getAspects = {}
  173. for aspect, aspectAmount in pairs(aspects) do
  174. getAspects[aspect] = aspectAmount * recipeAmount
  175. end
  176. elseif recipeAmount < 1 then
  177. getAspects = false
  178. end
  179.  
  180. print(textutils.serialize(getAspects))
  181. if getAspects then
  182. print("Requesting aspects for " .. recipeAmount .. " * ".. recipe .. ".")
  183. rednet.send(tc.aeCompID, 'getAspects ' .. textutils.serialize(getAspects))
  184. end
  185. end
  186. end--}}}
  187. function ThaumComp:initRecipeList()--{{{
  188. self.numRecipes = 0
  189. self.recipeList = {}
  190. for recipe, value in pairs(self.recipes) do
  191. self.numRecipes = self.numRecipes + 1
  192. self.recipeList[self.numRecipes] = recipe
  193. end
  194. table.sort(self.recipeList)
  195. end--}}}
  196. function ThaumComp:displayRecipes()--{{{
  197. if self.page == nil or self.page == 1 then
  198. startRecipe = 1
  199. else
  200. startRecipe = (self.page - 1) * self.recipesPerPage - 1
  201. end
  202. endRecipe = startRecipe + (self.recipesPerPage - 1)
  203. if endRecipe > self.numRecipes then
  204. endRecipe = self.numRecipes
  205. end
  206.  
  207. self:resetTerm()
  208.  
  209. for recipeNum = startRecipe, endRecipe do
  210. print(tostring(recipeNum) .. '. ' .. self.recipeList[recipeNum])
  211. end
  212. end--}}}
  213. function ThaumComp:nextRecipePage()--{{{
  214. self.page = self.page + 1
  215. end--}}}
  216. function ThaumComp:prevRecipePage()--{{{
  217. if self.page > 1 then
  218. self.page = self.page - 1
  219. end
  220. end--}}}
  221. function ThaumComp:selectRecipe()--{{{
  222. self:resetTerm()
  223. print('What number recipe do you want to create?')
  224. local recipeNum = self:readNumber()
  225. if recipeNum then
  226. print('Are you sure you want to create ' .. self.recipeList[recipeNum] .. '?')
  227. if self:readYesNo() then
  228. self:getRecipeAspects(self.recipeList[recipeNum])
  229. else
  230. self:resetTerm()
  231. self:displayRecipes()
  232. end
  233. else
  234. tc:resetTerm()
  235. tc:displayRecipes()
  236. end
  237. end--}}}
  238. function ThaumComp:craftObsidian()--{{{
  239. self:resetTerm()
  240. print('How many Obsidian do you want?')
  241. local amount = self:readNumber()
  242. if amount then
  243. print('Are you sure you want to create ' .. tostring(amount) .. ' of Obsidian?')
  244. if self:readYesNo() then
  245. rednet.send(tc.aeCompID, 'obsidian ' .. tostring(amount))
  246. end
  247. end
  248. tc:resetTerm()
  249. tc:displayRecipes()
  250. end--}}}
  251.  
  252. tc = ThaumComp
  253. tc:resetTerm()
  254. tc:initRecipeList()
  255. tc:displayRecipes()
  256.  
  257. while true do
  258. event, param1, param2, param3 = os.pullEvent()
  259. if event == 'key' then -- param1 == scancode
  260. if param1 == 27 then -- ]
  261. print("Sending Reboot command")
  262. rednet.send(tc.aeCompID, 'reboot')
  263. elseif param1 == 24 then -- o
  264. tc:craftObsidian()
  265. elseif param1 == 26 then -- [
  266. tc:powerOnMenu()
  267. elseif param1 == 34 then -- g
  268. recipe = 'Gold Transmutation'
  269. tc:getRecipeAspects(recipe)
  270. elseif param1 == 38 then -- l
  271. tc:displayRecipes()
  272. elseif param1 == 19 then -- r
  273. recipe = "Reaper's Scythe"
  274. tc:getRecipeAspects(recipe)
  275. elseif param1 == 46 then -- c
  276. tc:selectRecipe()
  277. elseif param1 == 205 then -- right cursor
  278. tc:nextRecipePage()
  279. tc:displayRecipes()
  280. elseif param1 == 203 then -- left cursor
  281. tc:prevRecipePage()
  282. tc:displayRecipes()
  283. elseif param1 == 29 then -- CTRL
  284. tc:resetTerm()
  285. event, param1 = os.pullEvent('key')
  286. print(param1)
  287. end
  288. elseif event == 'rednet_message' then -- number senderid, string message, number distance
  289. if param1 == tc.aeCompID then
  290. if param2:find('error ') then
  291. print(param2:sub(6))
  292. end
  293. end
  294. end
  295. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement