ah_sce_unpacked/unpacked/Custom_Token Investigator S...

115 lines
3.4 KiB
Plaintext

-- 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)
-- Stat Tracker
-- made by: Chr1Z
-- description: helps tracking the stats of your investigator
local BUTTON_PARAMETERS = {}
BUTTON_PARAMETERS.function_owner = self
BUTTON_PARAMETERS.height = 650
BUTTON_PARAMETERS.width = 700
BUTTON_PARAMETERS.position = { x = -4.775, y = 0.1, z = -0.03 }
BUTTON_PARAMETERS.color = { 0, 0, 0, 0 }
BUTTON_PARAMETERS.font_color = { 0, 0, 0, 100 }
BUTTON_PARAMETERS.font_size = 450
function onSave() return JSON.encode(stats) end
-- load stats and make buttons (left to right)
function onLoad(saved_data)
stats = JSON.decode(saved_data) or { 1, 1, 1, 1 }
for i = 1, 4 do
BUTTON_PARAMETERS.label = stats[i] .. " "
BUTTON_PARAMETERS.position.x = BUTTON_PARAMETERS.position.x + 1.91
BUTTON_PARAMETERS.click_function = attachIndex("button_click", i)
self.createButton(BUTTON_PARAMETERS)
end
self.addContextMenuItem("Reset to 1s", function() updateStats({ 1, 1, 1, 1 }) end)
end
-- helper function to carry index
function attachIndex(click_function, index)
local fn_name = click_function .. index
_G[fn_name] = function(obj, player_color, isRightClick)
_G[click_function](obj, player_color, isRightClick, index)
end
return fn_name
end
function button_click(_, _, isRightClick, index)
stats[index] = math.min(math.max(stats[index] + (isRightClick and -1 or 1), 0), 99)
changeButton(index)
end
function changeButton(index)
local font_size = BUTTON_PARAMETERS.font_size
local whitespace = " "
if stats[index] > 9 then
font_size = BUTTON_PARAMETERS.font_size * 0.65
whitespace = " "
end
self.editButton({ index = index - 1, label = stats[index] .. whitespace, font_size = font_size })
end
-- formatting of "newStats": {Willpower, Intellect, Fight, Agility}
function updateStats(newStats)
if newStats and #newStats == 4 then
stats = newStats
elseif newStats then
printToAll("Provided new stats are incomplete or incorrectly formatted.", "Red")
return
end
for i = 1, 4 do changeButton(i) end
end
end)
__bundle_register("__root", function(require, _LOADED, __bundle_register, __bundle_modules)
require("playermat/InvestigatorSkillTracker")
end)
return __bundle_require("__root")