Advertisement
Pinkl

Untitled

Jan 16th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1.  
  2.  
  3. function onload()
  4. generateButtonParamitersHP()
  5. countHP = 0
  6. b_displayHP.label = tostring(countHP)
  7. b_displayHP.font_size = 70
  8.  
  9. self.createButton(b_displayHP)
  10. self.createButton(b_plusHP)
  11. self.createButton(b_minusHP)
  12. self.createButton(b_plusHP5)
  13. self.createButton(b_minusHP5)
  14. end
  15.  
  16. --Activates when + is hit. Adds 1 to 'countHP' then updates the display button.
  17. function increaseHP()
  18. countHP = countHP + 1
  19. updateDisplayHP()
  20. end
  21.  
  22.  
  23. function decreaseHP()
  24. --Prevents countHP from going below 0
  25. if countHP > 0 then
  26. countHP = countHP - 1
  27. updateDisplayHP()
  28. end
  29. end
  30.  
  31.  
  32. function increaseHP5()
  33. countHP = countHP + 5
  34. updateDisplayHP()
  35. end
  36.  
  37.  
  38. function decreaseHP5()
  39. --Prevents countHP from going below 0
  40. if countHP > 4 then
  41. countHP = countHP - 5
  42. else
  43. countHP = 0
  44. end
  45. updateDisplayHP()
  46. end
  47.  
  48. function customSetHP()
  49. local descriptionHP = self.getDescription()
  50. if descriptionHP != '' and type(tonumber(descriptionHP)) == 'number' then
  51. self.setDescription('')
  52. countHP = tonumber(descriptionHP)
  53. updateDisplayHP()
  54. end
  55. end
  56.  
  57.  
  58. function updateDisplayHP()
  59. b_displayHP.font_size = 70
  60. b_displayHP.label = tostring(countHP)
  61. self.editButton(b_displayHP)
  62. end
  63.  
  64.  
  65. function generateButtonParamitersHP()
  66. b_displayHP = {
  67. index = 0, click_function = 'customSetHP', function_owner = self, label = '',
  68. position = {0,0.1,0}, width = 600, height = 600, font_size = 500
  69. }
  70. b_plusHP = {
  71. click_function = 'increaseHP', function_owner = self, label = '+1',
  72. position = {0.75,0.1,0.26}, width = 150, height = 300, font_size = 100
  73. }
  74. b_minusHP = {
  75. click_function = 'decreaseHP', function_owner = self, label = '-1',
  76. position = {-0.75,0.1,0.26}, width = 150, height = 300, font_size = 100
  77. }
  78. b_plusHP5 = {
  79. click_function = 'increaseHP5', function_owner = self, label = '+5',
  80. position = {0.75,0.1,-0.29}, width = 150, height = 230, font_size = 100
  81. }
  82. b_minusHP5 = {
  83. click_function = 'decreaseHP5', function_owner = self, label = '-5',
  84. position = {-0.75,0.1,-0.29}, width = 150, height = 230, font_size = 100
  85. }
  86. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement