Advertisement
kensuaga

Gloomhaven Original Character Sheet

Aug 27th, 2017
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.58 KB | None | 0 0
  1. --Gloomhaven Character Sheet
  2. --Adapted from MrStumps Universal Counter Tokens
  3.  
  4. --Character Sheet for Seren
  5.  
  6.  
  7. --Saves the count value into a table (data_to_save) then encodes it into the Tabletop save
  8. function onSave()
  9.     local data_to_save = {saved_countXP = countXP, saved_countGold = countGold}
  10.     saved_data = JSON.encode(data_to_save)
  11.     return saved_data
  12. end
  13.  
  14.  
  15. function onLoad(saved_data)
  16.  
  17.  
  18.  
  19.     --Checks if there is a saved data. If there is, it gets the saved value for 'count'
  20.     if saved_data != '' then
  21.         local loaded_data = JSON.decode(saved_data)
  22.             countXP = loaded_data.saved_countXP
  23.             countGold = loaded_data.saved_countGold
  24.     else
  25.         --If there wasn't saved data, the default value is set to 0.
  26.            countXP = 0
  27.            countGold = 0
  28.     end
  29.  
  30.     --countXP = 0
  31.     --countGold = 0
  32.  
  33.  
  34.     --Tables for all the button paramiters
  35.     generateButtonParamiters()
  36.  
  37.     --Updates the counter labels
  38.     b_displayXP.label = tostring(countXP)
  39.     b_displayGold.label = tostring(countGold)
  40.  
  41.     -- Creates labels for xp counter
  42.  
  43.  
  44.  
  45.     self.createButton(b_displayXP)
  46.     self.createButton(b_plusXP)
  47.     self.createButton(b_minusXP)
  48.     self.createButton(b_plus5XP)
  49.     self.createButton(b_minus5XP)
  50.  
  51.     self.createButton(b_displayGold)
  52.     self.createButton(b_plusGold)
  53.     self.createButton(b_minusGold)
  54.     self.createButton(b_plus5Gold)
  55.     self.createButton(b_minus5Gold)
  56.  
  57.     self.createButton(label_update_parameters)
  58.     self.createButton(label_name_parameters)
  59.     self.createButton(label_items_parameters)
  60.  
  61.     --Function to pull in character name and items
  62.     updateSheet()
  63. end
  64.  
  65.  
  66. --Activates when + is hit. Adds 1 to 'count' then updates the display button.
  67. function increaseXP()
  68.     countXP = countXP + 1
  69.     updateDisplayXP()
  70. end
  71.  
  72. --Activates when - is hit. Subtracts 1 from 'count' then updates the display button.
  73. function decreaseXP()
  74.     --Prevents count from going below 0
  75.     if countXP > 0 then
  76.         countXP = countXP - 1
  77.         updateDisplayXP()
  78.     end
  79. end
  80.  
  81. --Activates when + is hit. Adds 5 to 'count' then updates the display button.
  82. function increase5XP()
  83.     countXP = countXP + 5
  84.     updateDisplayXP()
  85. end
  86.  
  87. --Activates when - is hit. Subtracts 5 from 'count' then updates the display button.
  88. function decrease5XP()
  89.     --Prevents count from going below 0
  90.     if countXP > 4 then
  91.         countXP = countXP - 5
  92.     else
  93.         countXP = 0
  94.     end
  95.     updateDisplayXP()
  96. end
  97.  
  98.  
  99. --function that updates the XP Counter display. Triggered whenever 'countxp' is changed
  100. function updateDisplayXP()
  101.  
  102.     --b_displayXP.label = tostring(countXP)
  103.     --self.editButton(b_displayXP)
  104.     self.editButton({index = 0, label  = tostring(countXP)})
  105.  
  106. end
  107.  
  108.  
  109.  
  110.  
  111.  
  112. --Activates when + is hit. Adds 1 to 'count' then updates the display button.
  113. function increaseGold()
  114.     countGold = countGold + 1
  115.     updateDisplayGold()
  116. end
  117.  
  118. --Activates when - is hit. Subtracts 1 from 'count' then updates the display button.
  119. function decreaseGold()
  120.     --Prevents count from going below 0
  121.     if countGold > 0 then
  122.         countGold = countGold - 1
  123.         updateDisplayGold()
  124.     end
  125. end
  126.  
  127. --Activates when + is hit. Adds 5 to 'count' then updates the display button.
  128. function increase5Gold()
  129.     countGold = countGold + 5
  130.     updateDisplayGold()
  131. end
  132.  
  133. --Activates when - is hit. Subtracts 5 from 'count' then updates the display button.
  134. function decrease5Gold()
  135.     --Prevents count from going below 0
  136.     if countGold > 4 then
  137.         countGold = countGold - 5
  138.     else
  139.         countGold = 0
  140.     end
  141.     updateDisplayGold()
  142. end
  143.  
  144.  
  145. --function that updates the Gold Counter display.
  146. function updateDisplayGold()
  147.  
  148.     --b_displayGold.label = tostring(countGold)
  149.     --self.editButton(b_displayGold)
  150.     self.editButton({index = 5, label = tostring(countGold)})
  151. end
  152.  
  153.  
  154.  
  155. function updateSheet()
  156.     local name = self.getName()
  157.     self.editButton({index = 11, label = tostring(name)})
  158.  
  159.     local items = self.getDescription()
  160.     self.editButton({index = 12, label = tostring(items)})
  161. end
  162.  
  163.  
  164.  
  165.  
  166. function generateButtonParamiters()
  167.  
  168.  
  169.  
  170.     -- Sets all the paramiters for the XP counter
  171.     -- Sets XYZ center position for all buttons
  172.  
  173.     xpXPos = -0.3
  174.     xpYPos = 0.1
  175.     xpZPos = -0.35
  176.     lableScale = 0.20
  177.  
  178.     b_displayXP = {
  179.         index = 0, click_function="none", function_owner = self, label = '',
  180.         position = {xpXPos,xpYPos,xpZPos}, width = 0, height = 0,
  181.         font_size = 500, scale = {lableScale,lableScale,lableScale}
  182.     }
  183.  
  184.     b_plusXP = {
  185.         click_function = 'increaseXP', function_owner = self, label =  '+1',
  186.         position = {xpXPos + 0.15,xpYPos, xpZPos + 0.05}, width = 150,
  187.         height = 300, font_size = 100, scale = {lableScale,lableScale,lableScale}
  188.     }
  189.  
  190.     b_minusXP = {
  191.         click_function = 'decreaseXP', function_owner = self, label =  '-1',
  192.         position = {xpXPos + -0.15,xpYPos, xpZPos + 0.05}, width = 150,
  193.         height = 300, font_size = 100, scale = {lableScale,lableScale,lableScale}
  194.     }
  195.  
  196.     b_plus5XP = {
  197.         click_function = 'increase5XP', function_owner = self, label =  '+5',
  198.         position = {xpXPos + 0.15,xpYPos, xpZPos + -0.07}, width = 150,
  199.         height = 230, font_size = 100, scale = {lableScale,lableScale,lableScale}
  200.     }
  201.  
  202.     b_minus5XP = {
  203.         click_function = 'decrease5XP', function_owner = self, label =  '-5',
  204.         position = {xpXPos + -0.15,xpYPos, xpZPos + -0.07}, width = 150,
  205.         height = 230, font_size = 100, scale = {lableScale,lableScale,lableScale}
  206.     }
  207.  
  208.  
  209.     -- Sets all the paramiters for the Gold counter
  210.     -- Sets XYZ center position for all buttons
  211.  
  212.     goldXPos = -0.3
  213.     goldYPos = 0.1
  214.     goldZPos = -0.05
  215.  
  216.  
  217.     b_displayGold = {
  218.         click_function="none", function_owner = self, label = '',
  219.         position = {goldXPos,goldYPos,goldZPos}, width = 0, height = 0,
  220.         font_size = 500, scale = {lableScale,lableScale,lableScale}
  221.     }
  222.  
  223.     b_plusGold = {
  224.         click_function = 'increaseGold', function_owner = self, label =  '+1',
  225.         position = {goldXPos + 0.15,goldYPos, goldZPos + 0.05}, width = 150,
  226.         height = 300, font_size = 100, scale = {lableScale,lableScale,lableScale}
  227.     }
  228.  
  229.     b_minusGold = {
  230.         click_function = 'decreaseGold', function_owner = self, label =  '-1',
  231.         position = {goldXPos + -0.15,goldYPos, goldZPos + 0.05}, width = 150,
  232.         height = 300, font_size = 100, scale = {lableScale,lableScale,lableScale}
  233.     }
  234.  
  235.     b_plus5Gold = {
  236.         click_function = 'increase5Gold', function_owner = self, label =  '+5',
  237.         position = {goldXPos + 0.15,goldYPos, goldZPos + -0.07}, width = 150,
  238.         height = 230, font_size = 100, scale = {lableScale,lableScale,lableScale}
  239.     }
  240.  
  241.     b_minus5Gold = {
  242.         click_function = 'decrease5Gold', function_owner = self, label =  '-5',
  243.         position = {goldXPos + -0.15,goldYPos, goldZPos + -0.07}, width = 150,
  244.         height = 230, font_size = 100, scale = {lableScale,lableScale,lableScale}
  245.     }
  246.  
  247.  
  248.     --Label to update character name and iteam list
  249.     label_update_parameters = {
  250.         click_function="updateSheet", function_owner=self, label='Update',
  251.         position={-0.74,0.15,-0.96}, rotation={0,0,0}, height=60, width=420,
  252.         font_size=100, scale = {0.15,0.15,0.15}
  253.     }
  254.  
  255.  
  256.     -- Label for character name
  257.     label_name_parameters = {
  258.         click_function="none", function_owner=self, label='',
  259.         position={-0.3,0.15,-0.72}, rotation={0,0,0}, height=0, width=0,
  260.         font_size=100, scale = {0.3,0.3,0.3}
  261.     }
  262.  
  263.     --When alingment left works use position={-0.7,0.15,0.2}
  264.     label_items_parameters = {
  265.         click_function="none", function_owner=self, label='',
  266.         position={-0.3,0.15,0.4}, rotation={0,0,0}, height=0, width=0,
  267.         font_size=100, scale = {0.3,0.3,0.3},
  268.     }
  269.  
  270. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement