ah_sce_unpacked/unpacked/Custom_Token Clues 3f22e5.ttslua

103 lines
2.8 KiB
Plaintext
Raw Normal View History

2023-01-29 19:31:52 -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)
2024-02-17 19:48:30 -05:00
__bundle_register("__root", function(require, _LOADED, __bundle_register, __bundle_modules)
require("core/GenericCounter")
end)
2023-01-29 19:31:52 -05:00
__bundle_register("core/GenericCounter", function(require, _LOADED, __bundle_register, __bundle_modules)
MIN_VALUE = 0
MAX_VALUE = 99
val = 0
function onSave() return JSON.encode(val) end
function onLoad(savedData)
2024-06-09 10:10:21 -04:00
if savedData and savedData ~= "" then
2023-01-29 19:31:52 -05:00
val = JSON.decode(savedData)
end
local name = self.getName()
2024-06-09 10:10:21 -04:00
local position = { 0, 0.06, 0 }
2023-01-29 19:31:52 -05:00
2024-06-09 10:10:21 -04:00
-- set position of label depending on object
2023-01-29 19:31:52 -05:00
if name == "Damage" or name == "Resources" or name == "Resource Counter" then
position = { 0, 0.06, 0.1 }
elseif name == "Horror" then
position = { -0.025, 0.06, -0.025 }
2024-01-06 21:32:07 -05:00
elseif name == "Elder Sign Counter" or name == "Auto-fail Counter" then
position = { 0, 0.1, 0 }
2023-01-29 19:31:52 -05:00
end
self.createButton({
label = tostring(val),
click_function = "addOrSubtract",
function_owner = self,
position = position,
height = 600,
width = 1000,
scale = { 1.5, 1.5, 1.5 },
font_size = 600,
font_color = { 1, 1, 1, 100 },
color = { 0, 0, 0, 0 }
})
2024-06-09 10:10:21 -04:00
-- add context menu entries
2023-01-29 19:31:52 -05:00
self.addContextMenuItem("Add 5", function() updateVal(val + 5) end)
self.addContextMenuItem("Subtract 5", function() updateVal(val - 5) end)
self.addContextMenuItem("Add 10", function() updateVal(val + 10) end)
self.addContextMenuItem("Subtract 10", function() updateVal(val - 10) end)
end
function updateVal(newVal)
if tonumber(newVal) then
val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)
self.editButton({ index = 0, label = tostring(val) })
end
end
function addOrSubtract(_, _, isRightClick)
val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)
self.editButton({ index = 0, label = tostring(val) })
end
end)
return __bundle_require("__root")