Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onload()
- self.setScale({2.30,2.30,2.30})
- setGlobalVariables()
- makeButtons()
- end
- function setGlobalVariables()
- TopLabel = 'Top Button Name' -- Name of Top Button
- BotLabel = 'Bottom Button Name' -- Name of Top Button
- MinButtonLength = 2500
- end
- --------------------------------------------------------------------------------
- -- Place Demo Code in Here -----------------------------------------------------
- function Top_Left_Click(obj, color, alt_click)
- print('Top Function : Left Click')
- end
- function Top_Right_Click(obj, color, alt_click)
- print('Top Function : Right Click')
- end
- --------------------------------------------------------------------------------
- -- Place Demo Code in Here -----------------------------------------------------
- function Bot_Left_Click(obj, color, alt_click)
- print('Bottom Function : Left Click')
- end
- function Bot_Right_Click(obj, color, alt_click)
- print('Bottom Function : Right Click')
- end
- --******************************************************************************
- --*** Ignore Below this line ***************************************************
- --******************************************************************************
- function f_Top(obj, color, alt_click)
- if not alt_click then
- Top_Left_Click(obj, color, alt_click)
- else
- Top_Right_Click(obj, color, alt_click)
- end
- end
- function f_Bot(obj, color, alt_click)
- if not alt_click then
- Bot_Left_Click(obj, color, alt_click)
- else
- Bot_Right_Click(obj, color, alt_click)
- end
- end
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- function makeButtons()
- local lable = nil
- local ButtonList = {};
- local button = {}
- button.click_function = 'f_Top'
- button.function_owner = self
- button.position = setDynamicButtonSizes_pos(TopLabel) --{0,0.5,1}
- button.rotation = {0,180,0}
- button.label = TopLabel
- button.width = setDynamicButtonSizes_Width(TopLabel, MinButtonLength)
- button.height = setDynamicButtonSizes_Hight(TopLabel)
- button.font_size = 250
- table.insert(ButtonList, button)
- button = {}
- button.click_function = 'f_Bot'
- button.function_owner = self
- button.label = BotLabel
- button.position = setDynamicButtonSizes_pos(BotLabel) --{0,0.5,-1}
- button.rotation = {0,180,0}
- button.width = setDynamicButtonSizes_Width(BotLabel, MinButtonLength)
- button.height = setDynamicButtonSizes_Hight(BotLabel)
- button.font_size = 250
- table.insert(ButtonList, button)
- for k, b in pairs (ButtonList) do
- self.createButton(b)
- end
- end
- function setDynamicButtonSizes_pos(label)
- local posVec = Vector(0,0.5,1)
- local lines = {}
- for line in label:gmatch("[^\r\n]+") do
- table.insert(lines, line)
- end
- adjustZ = 1 + 0.1*#lines
- if label == TopLabel then
- posVec:setAt('z', adjustZ)
- elseif label == BotLabel then
- posVec:setAt('z', -adjustZ)
- end
- --print(logString(lines, 'lines'))
- return posVec
- end
- function setDynamicButtonSizes_Hight(lable)
- local minHight = 450
- local lines = {}
- for line in lable:gmatch("[^\r\n]+") do
- table.insert(lines, line)
- end
- local count = #lines
- local adjust_hight = 200
- if count > 1 then
- for i=1, count, 1 do
- minHight = minHight + adjust_hight
- end
- end
- return minHight
- end
- function setDynamicButtonSizes_Width(str, minWidth)
- local lable = string.upper(str)--str:gsub("^%l", string.upper)
- local lableSize = #lable
- --print(lable)
- local adjust_Width = 100
- local widthBorder = 600
- local Width = 0
- local lines = {}
- for line in lable:gmatch("[^\r\n]+") do
- table.insert(lines, line)
- end
- local size = 0
- if lines[2] ~= nil then
- for _, line in pairs(lines) do
- if size < #line then size = #line end
- end
- lableSize = size
- end
- for i=1, lableSize, 1 do
- Width = Width + adjust_Width
- end
- Width = Width + widthBorder
- if Width < minWidth then
- Width = minWidth
- end
- return Width
- end
Advertisement
Add Comment
Please, Sign In to add comment