Advertisement
RCAProduction

RCA's HUD Version XIII Update 2

Nov 24th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.60 KB | None | 0 0
  1.  
  2.  
  3. --RCA's HUD
  4. --Please use cracker64's script manager
  5. --VER 13 UPDATE {Not Available At Current Time}
  6.  
  7. --Version 13
  8.  
  9. print("RCA's HUD")
  10. print("Version XIII")
  11. print("Have Fun!")
  12.  
  13. --Windows
  14. local window1 = Window:new(-1, -1, 611, 383)
  15. local creditw = Window:new(-1, -1, 611, 383)
  16. local infow = Window:new(-1, -1, 611, 383)
  17. local colourw = Window:new(-1, -1, 611, 383)
  18. local messagew = Window:new(-1, -1, 611, 383)
  19.  
  20. --Texts
  21. local creditsttl = Label:new(270, 1, 50, 15, "CREDITS")
  22. local creditstxt = Label:new(1, 20, 611, 15, "Jacob1, Cracker 64, and the knowledge gained from all Lua programmers in TPT.")
  23. local infotxt = Label:new(1, 20, 611, 15, "How to use RCA's HUD (XII):")
  24. local instructions = Label:new(1, 40, 611, 15, "To turn the HUD on or off, use the < and > keys on your keyboard.")
  25. local instructions2 = Label:new(1, 60, 611, 15, "To turn on or off the extra level of the HUD (TMP2, VX, VY) use the + and - keys.")
  26. local instructions3 = Label:new(1, 80, 611, 15, "Pressing the M key will engage Realistic Mode. Every five frames WTRV is turned into DSTW")
  27. local instructions4 = Label:new(1, 90, 611, 15, "and all pixels are reset to normal temp. Restart TPT to reset.")
  28. local rca = Label:new(500, 5, 100, 15, "RCA Production (2014)")
  29. local rtext = Label:new(275, 10, 50, 15)
  30. rtext:text("0")
  31. local gtext = Label:new(275, 40, 50, 15)
  32. gtext:text("255")
  33. local btext = Label:new(275, 70, 50, 15)
  34. btext:text("165")
  35. local redl = Label:new(325, 10, 50, 15, "Red")
  36. local greenl = Label:new(325, 40, 50, 15, "Green")
  37. local bluel = Label:new(325, 70, 50, 15, "Blue")
  38. local messageText = Label:new(5, 5, 611, 15, "Hallo Sam. Jeg elsker deg... Du er veldig vakker... Jeg er forelsket.")
  39.  
  40. --Red Slider
  41. local rSlider = Slider:new(10, 10, 255, 15, 255)
  42. rSlider:value(0)
  43. --Green Slider
  44. local gSlider = Slider:new(10, 40, 255, 15, 255)
  45. gSlider:value(255)
  46. --Blue Slider
  47. local bSlider = Slider:new(10, 70, 255, 15, 255)
  48. bSlider:value(165)
  49.  
  50. --Checkbox Default
  51. local defaultc = Checkbox:new(10, 100, 10, 10, "Default")
  52. defaultc:checked(false)
  53. --Checkbox Purple
  54. local purplec = Checkbox:new(10, 120, 10, 10, "Purple")
  55. purplec:checked(false)
  56. --Checkbox Turquoise
  57. local turquoisec = Checkbox:new(10, 140, 10, 10, "Turquoise")
  58. turquoisec:checked(false)
  59.  
  60. --Credits Button
  61. local credits = Button:new(5, 5, 50, 15, "Credits")
  62. credits:action(function() ui.showWindow(creditw) end)
  63. --Close Credits Button
  64. local close2 = Button:new(508, 365, 100, 15, "Close Credits")
  65. close2:action(function() ui.closeWindow(creditw) end)
  66. --Info Button
  67. local info = Button:new(5, 25, 50, 15, "Info")
  68. info:action(function() ui.showWindow(infow) end)
  69. --Close Info Button
  70. local close3 = Button:new(508, 365, 100, 15, "Close Info")
  71. close3:action(function() ui.closeWindow(infow) end)
  72. --Colour Button
  73. local colourButton = Button:new(5, 45, 50, 15, "Colours")
  74. colourButton:action(function() ui.showWindow(colourw) end)
  75. --Close Colour Window
  76. local closeColour = Button:new(508, 365, 100, 15, "Close Colours")
  77. closeColour:action(function() ui.closeWindow(colourw) end)
  78. --Message
  79. local message = Button:new(5, 65, 50, 15, "Message")
  80. message:action(function() ui.showWindow(messagew) end)
  81. --Close Message
  82. local messagec = Button:new(508, 365, 100, 15, "Close Message")
  83. messagec:action(function() ui.closeWindow(messagew) end)
  84.  
  85. --I Button
  86. local infoButton = Button:new(597, 1, 15, 15, "I", "Info about RCA's HUD - Extras")
  87. infoButton:visible(false)
  88. infoButton:action(function() ui.showWindow(window1) end)
  89. --Exit Button
  90. local enterButton = Button:new(558, 365, 50, 15, "Exit")
  91. enterButton:action(function() ui.closeWindow(window1) end)
  92. --C Button
  93. local closeButton = Button:new(597, 97, 15, 15, "C", "Close")
  94. closeButton:visible(false)
  95. closeButton:action(function() infoButton:visible(false) closeButton:visible(false) end)
  96.  
  97. --E Button
  98. local extraButton = Button:new(613, 97, 15, 15, "E", "Extra Menu - Elements - Info")
  99. extraButton:action(function() infoButton:visible(true) closeButton:visible(true) end)
  100.  
  101. window1:addComponent(rca)
  102. window1:addComponent(enterButton)
  103. window1:addComponent(credits)
  104. window1:addComponent(info)
  105. window1:addComponent(colourButton)
  106. window1:addComponent(message)
  107.  
  108. creditw:addComponent(close2)
  109. creditw:addComponent(creditsttl)
  110. creditw:addComponent(creditstxt)
  111.  
  112. infow:addComponent(infotxt)
  113. infow:addComponent(close3)
  114. infow:addComponent(instructions)
  115. infow:addComponent(instructions2)
  116. infow:addComponent(instructions3)
  117. infow:addComponent(instructions4)
  118.  
  119. colourw:addComponent(rSlider)
  120. colourw:addComponent(rtext)
  121. colourw:addComponent(closeColour)
  122. colourw:addComponent(gSlider)
  123. colourw:addComponent(bSlider)
  124. colourw:addComponent(gtext)
  125. colourw:addComponent(btext)
  126. colourw:addComponent(redl)
  127. colourw:addComponent(greenl)
  128. colourw:addComponent(bluel)
  129. colourw:addComponent(purplec)
  130. colourw:addComponent(defaultc)
  131. colourw:addComponent(turquoisec)
  132.  
  133. messagew:addComponent(messagec)
  134. messagew:addComponent(messageText)
  135.  
  136. ui.closeWindow(window1)
  137. ui.closeWindow(creditw)
  138. ui.addComponent(extraButton)
  139. ui.addComponent(infoButton)
  140. ui.addComponent(closeButton)
  141.  
  142. hudon = true
  143. hudon2 = false
  144.  
  145. function keyclicky(key, nkey, modifier, event)
  146. if (key == "h" and event == 1) then
  147. hudon = not hudon
  148. hudon2 = false
  149. end
  150. if (key == "d" and event == 1) and hudon == true then
  151. hudon2 = not hudon2
  152. end
  153. end
  154.  
  155. tpt.register_keypress(keyclicky)
  156.  
  157. function DrawHUD()
  158.  
  159. if hudon == true then
  160. vis1 = 200
  161. else
  162. vis1 = 0
  163. end
  164. if hudon2 == true then
  165. vis2 = 200
  166. else
  167. vis2 = 0
  168. end
  169. if tpt.mousex >= 611 then
  170. x2 = 611
  171. else
  172. x2 = tpt.mousex
  173. end
  174.  
  175. if tpt.mousey >= 383 then
  176. y2 = 383
  177. else
  178. y2 = tpt.mousey
  179. end
  180.  
  181. local x, y = sim.adjustCoords(x2, y2)
  182.  
  183. if tpt.get_property("type", x, y) >= 1 then
  184. ptype = tpt.element(tpt.get_property("type", x, y))
  185. else
  186. ptype = "Empty,"
  187. end
  188.  
  189. if tpt.get_property("type", x, y) == 6 and tpt.get_property("ctype", x, y) >= 1 then
  190. ptype = "Molten"
  191. end
  192.  
  193. if tpt.get_property("type", x, y) >= 1 then
  194. var1 = tpt.get_property("temp", x, y)-273.15
  195. else
  196. var1 = 293.15
  197. end
  198.  
  199. local var2 = var1*100
  200. local var3 = math.floor(var2)/100
  201.  
  202. if tpt.get_property("type", x, y) >= 1 then
  203. temp = var3
  204. else
  205. temp = "()"
  206. end
  207.  
  208. if tpt.get_property("type", x, y) >= 1 then
  209. tempb = var3
  210. else
  211. tempb = 21.99
  212. end
  213.  
  214. if tpt.get_property("type", x, y) >= 1 then
  215. temp2 = math.floor(tpt.get_property("temp", x, y)*10)/10
  216. else
  217. temp2 = "()"
  218. end
  219.  
  220. if tpt.get_property("type", x, y) >= 1 then
  221. var12312389 = tpt.get_property("ctype", x, y)
  222. end
  223.  
  224. if tpt.get_property("type", x, y) >= 1 and var12312389 >= 0 and var12312389 < sim.PT_NUM then
  225. ctype = tpt.element(tpt.get_property("ctype", x, y))
  226. end
  227.  
  228. if tpt.get_property("type", x, y) == 0 or tpt.get_property("ctype", x, y) < 1 then
  229. ctype = "()"
  230. end
  231.  
  232. if x >= 609 then
  233. x1 = 609/4
  234. else
  235. x1 = x/4
  236. end
  237.  
  238. if y >= 381 then
  239. y1 = 381/4
  240. else
  241. y1 = y/4
  242. end
  243.  
  244. local var4 = sim.pressure(x1, y1)*100
  245. local var14 = math.floor(var4)/100
  246.  
  247. if var14 == "nan" then
  248. pressure = "Infinite"
  249. else
  250. pressure = var14
  251. end
  252.  
  253. local parts = tpt.get_numOfParts()
  254. if tpt.get_property("type", x, y) >= 1 then
  255. tmp = tpt.get_property("tmp", x, y)
  256. else
  257. tmp = "0"
  258. end
  259.  
  260. if tpt.get_property("type", x, y) >= 1 then
  261. life = tpt.get_property("life", x, y)
  262. else
  263. life = "0"
  264. end
  265.  
  266. if tpt.get_property("type", x, y) >= 1 then
  267. tmp2 = tpt.get_property("tmp2", x, y)
  268. else
  269. tmp2 = "0"
  270. end
  271.  
  272. if tpt.get_property("type", x, y) >= 1 then
  273. var11 = tpt.get_property("vy", x, y)*1000
  274. else
  275. var11 = 0
  276. end
  277. if var11 <= 9999 or var11 <= -9999 then
  278. vy = math.floor(var11)/1000
  279. else
  280. vy = "Err(2)"
  281. end
  282.  
  283. if tpt.get_property("type", x, y) >= 1 then
  284. var12 = tpt.get_property("vx", x, y)*1000
  285. else
  286. var12 = 0
  287. end
  288. if var12 <= 9999 or var12 <= -9999 then
  289. vx = math.floor(var12)/1000
  290. else
  291. vx = "Err(1)"
  292. end
  293.  
  294. local rclr, gclr, bclr = rSlider:value(), gSlider:value(), bSlider:value()
  295. rSlider:onValueChanged(function() rclr = rSlider:value() rtext:text(rclr) end)
  296. gSlider:onValueChanged(function() gclr = gSlider:value() gtext:text(gclr) end)
  297. bSlider:onValueChanged(function() bclr = bSlider:value() btext:text(bclr) end)
  298.  
  299. if purplec:checked() == true then
  300. rclr, gclr, bclr = 164, 95, 255
  301. end
  302.  
  303. if defaultc:checked() == true then
  304. rclr, gclr, bclr = 0, 255, 165
  305. end
  306.  
  307. if turquoisec:checked() == true then
  308. rclr, gclr, bclr = 0, 255, 255
  309. end
  310.  
  311. colourw:onDraw(function() graphics.fillRect(300, 150, 90, 90, rclr, gclr, bclr) end)
  312.  
  313. local draw = graphics.drawText
  314. local rect = graphics.fillRect
  315.  
  316. rect(398, 13, 187, 12, 55, 55, 55, vis1)
  317. rect(398, 27, 200, 12, 55, 55, 55, vis1)
  318. rect(14, 13, 210, 12, 55, 55, 55, vis1)
  319. rect(398, 41, 180, 12, 55, 55, 55, vis2)
  320.  
  321. draw(16, 15, os.date(), rclr, gclr, bclr, vis1)
  322.  
  323. --draw(250, 6, "</> Turn HUD On/Off", rclr, gclr, bclr, vis3)
  324. --draw(250, 16, "-/+ Extra On/Off", rclr, gclr, bclr, vis3)
  325. draw(550, 30, x, rclr, gclr, bclr, vis1)
  326. draw(578, 30, y, rclr, gclr, bclr, vis1)
  327. draw(541, 30, "X:", rclr, gclr, bclr, vis1)
  328. draw(570, 30, "Y:", rclr, gclr, bclr, vis1)
  329. draw(435, 15, ctype, rclr, gclr, bclr, vis1)
  330. draw(400, 15, ptype, rclr, gclr, bclr, vis1)
  331. draw(558, 15, pressure, rclr, gclr, bclr, vis1)
  332. draw(465, 15, "Temp:", rclr, gclr, bclr, vis1)
  333. draw(465, 30, "Tmp:", rclr, gclr, bclr, vis1)
  334. draw(400, 30, "Life:", rclr, gclr, bclr, vis1)
  335. draw(535, 15, "Pres:", rclr, gclr, bclr, vis1)
  336. draw(160, 15, "Parts:", rclr, gclr, bclr, vis1)
  337. draw(490, 15, temp, rclr, gclr, bclr, vis1)
  338. draw(485, 30, tmp, rclr, gclr, bclr, vis1)
  339. draw(422, 30, life, rclr, gclr, bclr, vis1)
  340. draw(187, 15, parts, rclr, gclr, bclr, vis1)
  341.  
  342. draw(400, 44, "Tmp2:", rclr, gclr, bclr, vis2)
  343. draw(426, 44, tmp2, rclr, gclr, bclr, vis2)
  344. draw(465, 44, "VX:", rclr, gclr, bclr, vis2)
  345. draw(535, 44, "VY:", rclr, gclr, bclr, vis2)
  346. draw(480, 44, vx, rclr, gclr, bclr, vis2)
  347. draw(550, 44, vy, rclr, gclr, bclr, vis2)
  348. --Useful for programming, shows an element's number (Not name) at mouse X, Y. By default is commented out.
  349. --draw(550, 54, tpt.get_property("type", x, y), 0, gclr, bclr, 200)
  350.  
  351. --Temperature Colour Graph
  352. local dx = ((tempb-1550)/50)
  353. if dx >= 39 then
  354. ddx = 565
  355. visb = 255
  356. dddx = (dx-39)+490
  357. else
  358. ddx = dx+526
  359. visb = 0
  360. dddx = 1
  361. end
  362.  
  363. if dddx >= 565 then
  364. ddddx = dddx-75
  365. dddx = 565
  366. visbb = 255
  367. else
  368. ddddx = 1
  369. visbb = 0
  370. end
  371. if tempb >=-290 then
  372. tpt.drawpixel(490, 25, 80, 54, 254, vis1)
  373. end
  374. if tempb >= -250 then
  375. tpt.drawpixel(491, 25, 60, 54, 254, vis1)
  376. end
  377. if tempb >= -200 then
  378. tpt.drawpixel(492, 25, 60, 74, 254, vis1)
  379. end
  380. if tempb >= -150 then
  381. tpt.drawpixel(493, 25, 60, 94, 254, vis1)
  382. end
  383. if tempb >= -100 then
  384. tpt.drawpixel(494, 25, 60, 114, 254, vis1)
  385. end
  386. if tempb >= -50 then
  387. tpt.drawpixel(495, 25, 60, 134, 254, vis1)
  388. end
  389. if tempb >= 0 then
  390. tpt.drawpixel(496, 25, 60, 153, 254, vis1)
  391. end
  392. if tempb >= 50 then
  393. tpt.drawpixel(497, 25, 60, 154, 234, vis1)
  394. end
  395. if tempb >= 100 then
  396. tpt.drawpixel(498, 25, 60, 174, 234, vis1)
  397. end
  398. if tempb >= 150 then
  399. tpt.drawpixel(499, 25, 60, 194, 234, vis1)
  400. end
  401. if tempb >= 200 then
  402. tpt.drawpixel(500, 25, 60, 214, 234, vis1)
  403. end
  404. if tempb >= 250 then
  405. tpt.drawpixel(501, 25, 60, 234, 234, vis1)
  406. end
  407. if tempb >= 300 then
  408. tpt.drawpixel(502, 25, 60, 254, 234, vis1)
  409. end
  410. if tempb >= 350 then
  411. tpt.drawpixel(503, 25, 60, 254, 214, vis1)
  412. end
  413. if tempb >= 400 then
  414. tpt.drawpixel(504, 25, 60, 254, 94, vis1)
  415. end
  416. if tempb >= 450 then
  417. tpt.drawpixel(505, 25, 60, 254, 74, vis1)
  418. end
  419. if tempb >= 500 then
  420. tpt.drawpixel(506, 25, 60, 254, 54, vis1)
  421. end
  422. if tempb >= 550 then
  423. tpt.drawpixel(507, 25, 80, 254, 54, vis1)
  424. end
  425. if tempb >= 600 then
  426. tpt.drawpixel(508, 25, 100, 254, 54, vis1)
  427. end
  428. if tempb >= 650 then
  429. tpt.drawpixel(508, 25, 120, 254, 54, vis1)
  430. end
  431. if tempb >= 750 then
  432. tpt.drawpixel(509, 25, 140, 254, 54, vis1)
  433. end
  434. if tempb >= 800 then
  435. tpt.drawpixel(510, 25, 160, 254, 54, vis1)
  436. end
  437. if tempb >= 850 then
  438. tpt.drawpixel(511, 25, 180, 254, 54, vis1)
  439. end
  440. if tempb >= 900 then
  441. tpt.drawpixel(512, 25, 200, 254, 54, vis1)
  442. end
  443. if tempb >= 950 then
  444. tpt.drawpixel(513, 25, 220, 254, 54, vis1)
  445. end
  446. if tempb >= 1000 then
  447. tpt.drawpixel(514, 25, 240, 254, 54, vis1)
  448. end
  449. if tempb >= 1050 then
  450. tpt.drawpixel(515, 25, 254, 254, 54, vis1)
  451. end
  452. if tempb >= 1100 then
  453. tpt.drawpixel(516, 25, 254, 254, 54, vis1)
  454. end
  455. if tempb >= 1150 then
  456. tpt.drawpixel(517, 25, 254, 214, 54, vis1)
  457. end
  458. if tempb >= 1200 then
  459. tpt.drawpixel(518, 25, 254, 194, 54, vis1)
  460. end
  461. if tempb >= 1250 then
  462. tpt.drawpixel(519, 25, 254, 174, 54, vis1)
  463. end
  464. if tempb >= 1300 then
  465. tpt.drawpixel(520, 25, 254, 154, 54, vis1)
  466. end
  467. if tempb >= 1350 then
  468. tpt.drawpixel(521, 25, 254, 134, 54, vis1)
  469. end
  470. if tempb >= 1400 then
  471. tpt.drawpixel(522, 25, 254, 114, 54, vis1)
  472. end
  473. if tempb >= 1450 then
  474. tpt.drawpixel(523, 25, 254, 94, 54, vis1)
  475. end
  476. if tempb >= 1500 then
  477. tpt.drawpixel(524, 25, 254, 74, 54, vis1)
  478. end
  479. if tempb >= 1550 then
  480. tpt.drawpixel(525, 25, 254, 54, 54, vis1)
  481. end
  482. if tempb >= 1600 then
  483. graphics.drawLine(526, 25, ddx, 25, 255, 0, 0, vis1)
  484. end
  485. graphics.drawLine(490, 26, dddx, 26, 255, 0, 0, visb)
  486. graphics.drawLine(490, 27, ddddx, 27, 255, 0, 0, visbb)
  487. --Keeps normal HUD off
  488. tpt.hud(0)
  489. end
  490.  
  491. tpt.register_step(DrawHUD)
  492.  
  493. function keyclicky(key, nkey, modifier, event)
  494. if (key == "m" and event == 1) then
  495. realistic = not realistic
  496. end
  497. end
  498.  
  499. tpt.register_keypress(keyclicky)
  500.  
  501. local counter = 0
  502. function resettemp()
  503. counter = (counter + 1)%5
  504. if counter == 0 and realistic == true then
  505. sim.resetTemp()
  506. tpt.set_property("temp", 293.15, "wtrv")
  507. infoOn = true
  508. end
  509. if realistic == false then
  510. infoOn = false
  511. end
  512. if infoOn == true then
  513. graphics.fillRect(14, 27, 134,12, 55, 55, 55, 200)
  514. graphics.drawText(16, 29, "Realistic Mode Enabled (M)", 0, 255, 165, 200)
  515. end
  516. end
  517. tpt.register_step(resettemp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement