Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Gloomhaven Character Sheet
- --Adapted from MrStumps Universal Counter Tokens
- --Character Sheet for Seren
- --Saves the count value into a table (data_to_save) then encodes it into the Tabletop save
- function onSave()
- local data_to_save = {saved_countXP = countXP, saved_countGold = countGold}
- saved_data = JSON.encode(data_to_save)
- return saved_data
- end
- function onLoad(saved_data)
- --Checks if there is a saved data. If there is, it gets the saved value for 'count'
- if saved_data != '' then
- local loaded_data = JSON.decode(saved_data)
- countXP = loaded_data.saved_countXP
- countGold = loaded_data.saved_countGold
- else
- --If there wasn't saved data, the default value is set to 0.
- countXP = 0
- countGold = 0
- end
- --countXP = 0
- --countGold = 0
- --Tables for all the button paramiters
- generateButtonParamiters()
- --Updates the counter labels
- b_displayXP.label = tostring(countXP)
- b_displayGold.label = tostring(countGold)
- -- Creates labels for xp counter
- self.createButton(b_displayXP)
- self.createButton(b_plusXP)
- self.createButton(b_minusXP)
- self.createButton(b_plus5XP)
- self.createButton(b_minus5XP)
- self.createButton(b_displayGold)
- self.createButton(b_plusGold)
- self.createButton(b_minusGold)
- self.createButton(b_plus5Gold)
- self.createButton(b_minus5Gold)
- self.createButton(label_update_parameters)
- self.createButton(label_name_parameters)
- self.createButton(label_items_parameters)
- --Function to pull in character name and items
- updateSheet()
- end
- --Activates when + is hit. Adds 1 to 'count' then updates the display button.
- function increaseXP()
- countXP = countXP + 1
- updateDisplayXP()
- end
- --Activates when - is hit. Subtracts 1 from 'count' then updates the display button.
- function decreaseXP()
- --Prevents count from going below 0
- if countXP > 0 then
- countXP = countXP - 1
- updateDisplayXP()
- end
- end
- --Activates when + is hit. Adds 5 to 'count' then updates the display button.
- function increase5XP()
- countXP = countXP + 5
- updateDisplayXP()
- end
- --Activates when - is hit. Subtracts 5 from 'count' then updates the display button.
- function decrease5XP()
- --Prevents count from going below 0
- if countXP > 4 then
- countXP = countXP - 5
- else
- countXP = 0
- end
- updateDisplayXP()
- end
- --function that updates the XP Counter display. Triggered whenever 'countxp' is changed
- function updateDisplayXP()
- --b_displayXP.label = tostring(countXP)
- --self.editButton(b_displayXP)
- self.editButton({index = 0, label = tostring(countXP)})
- end
- --Activates when + is hit. Adds 1 to 'count' then updates the display button.
- function increaseGold()
- countGold = countGold + 1
- updateDisplayGold()
- end
- --Activates when - is hit. Subtracts 1 from 'count' then updates the display button.
- function decreaseGold()
- --Prevents count from going below 0
- if countGold > 0 then
- countGold = countGold - 1
- updateDisplayGold()
- end
- end
- --Activates when + is hit. Adds 5 to 'count' then updates the display button.
- function increase5Gold()
- countGold = countGold + 5
- updateDisplayGold()
- end
- --Activates when - is hit. Subtracts 5 from 'count' then updates the display button.
- function decrease5Gold()
- --Prevents count from going below 0
- if countGold > 4 then
- countGold = countGold - 5
- else
- countGold = 0
- end
- updateDisplayGold()
- end
- --function that updates the Gold Counter display.
- function updateDisplayGold()
- --b_displayGold.label = tostring(countGold)
- --self.editButton(b_displayGold)
- self.editButton({index = 5, label = tostring(countGold)})
- end
- function updateSheet()
- local name = self.getName()
- self.editButton({index = 11, label = tostring(name)})
- local items = self.getDescription()
- self.editButton({index = 12, label = tostring(items)})
- end
- function generateButtonParamiters()
- -- Sets all the paramiters for the XP counter
- -- Sets XYZ center position for all buttons
- xpXPos = -0.3
- xpYPos = 0.1
- xpZPos = -0.35
- lableScale = 0.20
- b_displayXP = {
- index = 0, click_function="none", function_owner = self, label = '',
- position = {xpXPos,xpYPos,xpZPos}, width = 0, height = 0,
- font_size = 500, scale = {lableScale,lableScale,lableScale}
- }
- b_plusXP = {
- click_function = 'increaseXP', function_owner = self, label = '+1',
- position = {xpXPos + 0.15,xpYPos, xpZPos + 0.05}, width = 150,
- height = 300, font_size = 100, scale = {lableScale,lableScale,lableScale}
- }
- b_minusXP = {
- click_function = 'decreaseXP', function_owner = self, label = '-1',
- position = {xpXPos + -0.15,xpYPos, xpZPos + 0.05}, width = 150,
- height = 300, font_size = 100, scale = {lableScale,lableScale,lableScale}
- }
- b_plus5XP = {
- click_function = 'increase5XP', function_owner = self, label = '+5',
- position = {xpXPos + 0.15,xpYPos, xpZPos + -0.07}, width = 150,
- height = 230, font_size = 100, scale = {lableScale,lableScale,lableScale}
- }
- b_minus5XP = {
- click_function = 'decrease5XP', function_owner = self, label = '-5',
- position = {xpXPos + -0.15,xpYPos, xpZPos + -0.07}, width = 150,
- height = 230, font_size = 100, scale = {lableScale,lableScale,lableScale}
- }
- -- Sets all the paramiters for the Gold counter
- -- Sets XYZ center position for all buttons
- goldXPos = -0.3
- goldYPos = 0.1
- goldZPos = -0.05
- b_displayGold = {
- click_function="none", function_owner = self, label = '',
- position = {goldXPos,goldYPos,goldZPos}, width = 0, height = 0,
- font_size = 500, scale = {lableScale,lableScale,lableScale}
- }
- b_plusGold = {
- click_function = 'increaseGold', function_owner = self, label = '+1',
- position = {goldXPos + 0.15,goldYPos, goldZPos + 0.05}, width = 150,
- height = 300, font_size = 100, scale = {lableScale,lableScale,lableScale}
- }
- b_minusGold = {
- click_function = 'decreaseGold', function_owner = self, label = '-1',
- position = {goldXPos + -0.15,goldYPos, goldZPos + 0.05}, width = 150,
- height = 300, font_size = 100, scale = {lableScale,lableScale,lableScale}
- }
- b_plus5Gold = {
- click_function = 'increase5Gold', function_owner = self, label = '+5',
- position = {goldXPos + 0.15,goldYPos, goldZPos + -0.07}, width = 150,
- height = 230, font_size = 100, scale = {lableScale,lableScale,lableScale}
- }
- b_minus5Gold = {
- click_function = 'decrease5Gold', function_owner = self, label = '-5',
- position = {goldXPos + -0.15,goldYPos, goldZPos + -0.07}, width = 150,
- height = 230, font_size = 100, scale = {lableScale,lableScale,lableScale}
- }
- --Label to update character name and iteam list
- label_update_parameters = {
- click_function="updateSheet", function_owner=self, label='Update',
- position={-0.74,0.15,-0.96}, rotation={0,0,0}, height=60, width=420,
- font_size=100, scale = {0.15,0.15,0.15}
- }
- -- Label for character name
- label_name_parameters = {
- click_function="none", function_owner=self, label='',
- position={-0.3,0.15,-0.72}, rotation={0,0,0}, height=0, width=0,
- font_size=100, scale = {0.3,0.3,0.3}
- }
- --When alingment left works use position={-0.7,0.15,0.2}
- label_items_parameters = {
- click_function="none", function_owner=self, label='',
- position={-0.3,0.15,0.4}, rotation={0,0,0}, height=0, width=0,
- font_size=100, scale = {0.3,0.3,0.3},
- }
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement