Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onload()
- generateButtonParamitersHP()
- countHP = 0
- b_displayHP.label = tostring(countHP)
- b_displayHP.font_size = 70
- self.createButton(b_displayHP)
- self.createButton(b_plusHP)
- self.createButton(b_minusHP)
- self.createButton(b_plusHP5)
- self.createButton(b_minusHP5)
- end
- --Activates when + is hit. Adds 1 to 'countHP' then updates the display button.
- function increaseHP()
- countHP = countHP + 1
- updateDisplayHP()
- end
- function decreaseHP()
- --Prevents countHP from going below 0
- if countHP > 0 then
- countHP = countHP - 1
- updateDisplayHP()
- end
- end
- function increaseHP5()
- countHP = countHP + 5
- updateDisplayHP()
- end
- function decreaseHP5()
- --Prevents countHP from going below 0
- if countHP > 4 then
- countHP = countHP - 5
- else
- countHP = 0
- end
- updateDisplayHP()
- end
- function customSetHP()
- local descriptionHP = self.getDescription()
- if descriptionHP != '' and type(tonumber(descriptionHP)) == 'number' then
- self.setDescription('')
- countHP = tonumber(descriptionHP)
- updateDisplayHP()
- end
- end
- function updateDisplayHP()
- b_displayHP.font_size = 70
- b_displayHP.label = tostring(countHP)
- self.editButton(b_displayHP)
- end
- function generateButtonParamitersHP()
- b_displayHP = {
- index = 0, click_function = 'customSetHP', function_owner = self, label = '',
- position = {0,0.1,0}, width = 600, height = 600, font_size = 500
- }
- b_plusHP = {
- click_function = 'increaseHP', function_owner = self, label = '+1',
- position = {0.75,0.1,0.26}, width = 150, height = 300, font_size = 100
- }
- b_minusHP = {
- click_function = 'decreaseHP', function_owner = self, label = '-1',
- position = {-0.75,0.1,0.26}, width = 150, height = 300, font_size = 100
- }
- b_plusHP5 = {
- click_function = 'increaseHP5', function_owner = self, label = '+5',
- position = {0.75,0.1,-0.29}, width = 150, height = 230, font_size = 100
- }
- b_minusHP5 = {
- click_function = 'decreaseHP5', function_owner = self, label = '-5',
- position = {-0.75,0.1,-0.29}, width = 150, height = 230, font_size = 100
- }
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement