2022-12-13 14:02:30 -05:00
|
|
|
-- Bundled by luabundle {"version":"1.6.0"}
|
|
|
|
local __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)
|
|
|
|
local loadingPlaceholder = {[{}] = true}
|
|
|
|
|
|
|
|
local register
|
|
|
|
local modules = {}
|
|
|
|
|
|
|
|
local require
|
|
|
|
local loaded = {}
|
|
|
|
|
|
|
|
register = function(name, body)
|
|
|
|
if not modules[name] then
|
|
|
|
modules[name] = body
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
require = function(name)
|
|
|
|
local loadedModule = loaded[name]
|
|
|
|
|
|
|
|
if loadedModule then
|
|
|
|
if loadedModule == loadingPlaceholder then
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if not modules[name] then
|
|
|
|
if not superRequire then
|
|
|
|
local identifier = type(name) == 'string' and '\"' .. name .. '\"' or tostring(name)
|
|
|
|
error('Tried to require ' .. identifier .. ', but no such module has been registered')
|
|
|
|
else
|
|
|
|
return superRequire(name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
loaded[name] = loadingPlaceholder
|
|
|
|
loadedModule = modules[name](require, loaded, register, modules)
|
|
|
|
loaded[name] = loadedModule
|
|
|
|
end
|
|
|
|
|
|
|
|
return loadedModule
|
|
|
|
end
|
|
|
|
|
|
|
|
return require, loaded, register, modules
|
|
|
|
end)(nil)
|
|
|
|
__bundle_register("playermat/InvestigatorSkillTracker", function(require, _LOADED, __bundle_register, __bundle_modules)
|
2024-02-04 10:51:51 -05:00
|
|
|
local buttonParameters = {}
|
|
|
|
buttonParameters.function_owner = self
|
|
|
|
buttonParameters.height = 650
|
|
|
|
buttonParameters.width = 700
|
|
|
|
buttonParameters.position = { x = -4.775, y = 0.1, z = -0.03 }
|
|
|
|
buttonParameters.color = { 0, 0, 0, 0 }
|
|
|
|
buttonParameters.font_color = { 0, 0, 0, 100 }
|
|
|
|
buttonParameters.font_size = 450
|
2022-12-13 14:02:30 -05:00
|
|
|
|
|
|
|
function onSave() return JSON.encode(stats) end
|
|
|
|
|
|
|
|
-- load stats and make buttons (left to right)
|
2024-02-04 10:51:51 -05:00
|
|
|
function onLoad(savedData)
|
|
|
|
stats = JSON.decode(savedData) or { 1, 1, 1, 1 }
|
|
|
|
|
|
|
|
for index = 1, 4 do
|
|
|
|
local fnName = "buttonClick" .. index
|
|
|
|
_G[fnName] = function(_, _, isRightClick) buttonClick(isRightClick, index) end
|
|
|
|
buttonParameters.click_function = fnName
|
|
|
|
buttonParameters.position.x = buttonParameters.position.x + 1.91
|
|
|
|
self.createButton(buttonParameters)
|
|
|
|
updateButtonLabel(index)
|
2024-01-06 21:32:07 -05:00
|
|
|
end
|
2022-12-13 14:02:30 -05:00
|
|
|
|
2024-01-06 21:32:07 -05:00
|
|
|
self.addContextMenuItem("Reset to 1s", function() updateStats({ 1, 1, 1, 1 }) end)
|
2022-12-13 14:02:30 -05:00
|
|
|
end
|
|
|
|
|
2024-02-04 10:51:51 -05:00
|
|
|
function buttonClick(isRightClick, index)
|
2024-01-06 21:32:07 -05:00
|
|
|
stats[index] = math.min(math.max(stats[index] + (isRightClick and -1 or 1), 0), 99)
|
2024-02-04 10:51:51 -05:00
|
|
|
updateButtonLabel(index)
|
2022-12-13 14:02:30 -05:00
|
|
|
end
|
|
|
|
|
2024-02-04 10:51:51 -05:00
|
|
|
-- sync the button label to the internal value
|
|
|
|
function updateButtonLabel(index)
|
|
|
|
local fontSize = buttonParameters.font_size
|
2024-01-06 21:32:07 -05:00
|
|
|
local whitespace = " "
|
2022-12-13 14:02:30 -05:00
|
|
|
|
2024-01-06 21:32:07 -05:00
|
|
|
if stats[index] > 9 then
|
2024-02-04 10:51:51 -05:00
|
|
|
fontSize = buttonParameters.font_size * 0.65
|
2024-01-06 21:32:07 -05:00
|
|
|
whitespace = " "
|
|
|
|
end
|
2022-12-13 14:02:30 -05:00
|
|
|
|
2024-02-04 10:51:51 -05:00
|
|
|
self.editButton({ index = index - 1, label = stats[index] .. whitespace, font_size = fontSize })
|
2022-12-13 14:02:30 -05:00
|
|
|
end
|
|
|
|
|
2024-02-04 10:51:51 -05:00
|
|
|
-- update the stats to the provided values
|
|
|
|
---@param newStats Table Contains the new values for the stats: {Willpower, Intellect, Fight, Agility}
|
2022-12-13 14:02:30 -05:00
|
|
|
function updateStats(newStats)
|
2024-01-06 21:32:07 -05:00
|
|
|
if newStats and #newStats == 4 then
|
|
|
|
stats = newStats
|
2024-02-04 10:51:51 -05:00
|
|
|
|
|
|
|
for i = 1, 4 do updateButtonLabel(i) end
|
2024-01-06 21:32:07 -05:00
|
|
|
elseif newStats then
|
|
|
|
printToAll("Provided new stats are incomplete or incorrectly formatted.", "Red")
|
|
|
|
end
|
2022-12-13 14:02:30 -05:00
|
|
|
end
|
|
|
|
end)
|
2024-02-04 10:51:51 -05:00
|
|
|
__bundle_register("__root", function(require, _LOADED, __bundle_register, __bundle_modules)
|
|
|
|
require("playermat/InvestigatorSkillTracker")
|
|
|
|
end)
|
2022-12-13 14:02:30 -05:00
|
|
|
return __bundle_require("__root")
|