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)
|
|
|
|
__bundle_register("__root", function(require, _LOADED, __bundle_register, __bundle_modules)
|
|
|
|
require("playermat/ClueCounter")
|
|
|
|
end)
|
|
|
|
__bundle_register("playermat/ClueCounter", function(require, _LOADED, __bundle_register, __bundle_modules)
|
2024-02-04 10:51:51 -05:00
|
|
|
local searchLib = require("util/SearchLib")
|
2023-01-29 19:31:52 -05:00
|
|
|
exposedValue = 0
|
|
|
|
|
|
|
|
function onLoad()
|
|
|
|
self.createButton({
|
|
|
|
label = "",
|
2024-01-06 21:32:29 -05:00
|
|
|
click_function = "countItems",
|
2023-01-29 19:31:52 -05:00
|
|
|
function_owner = self,
|
|
|
|
position = { 0, 0.1, 0 },
|
|
|
|
height = 0,
|
|
|
|
width = 0,
|
|
|
|
font_color = { 0, 0, 0 },
|
|
|
|
font_size = 2000
|
|
|
|
})
|
2024-02-04 10:51:51 -05:00
|
|
|
loopID = Wait.time(countItems, 1.5, -1)
|
2023-01-29 19:31:52 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Activated once per second, counts items in bowls
|
|
|
|
function countItems()
|
|
|
|
local totalValue = 0
|
2024-02-04 10:51:51 -05:00
|
|
|
for _, item in ipairs(getClues()) do
|
|
|
|
totalValue = totalValue + math.abs(item.getQuantity())
|
2023-01-29 19:31:52 -05:00
|
|
|
end
|
|
|
|
exposedValue = totalValue
|
|
|
|
self.editButton({ index = 0, label = totalValue })
|
|
|
|
end
|
|
|
|
|
2024-02-04 10:51:51 -05:00
|
|
|
function removeAllClues(trash)
|
|
|
|
for _, obj in ipairs(getClues()) do
|
|
|
|
trash.putObject(obj)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function getClues()
|
|
|
|
return searchLib.inArea(self.getPosition(), self.getRotation(), { 2, 1, 2 }, "isClue")
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
__bundle_register("util/SearchLib", function(require, _LOADED, __bundle_register, __bundle_modules)
|
|
|
|
do
|
|
|
|
local SearchLib = {}
|
|
|
|
local filterFunctions = {
|
|
|
|
isActionToken = function(x) return x.getDescription() == "Action Token" end,
|
|
|
|
isCard = function(x) return x.type == "Card" end,
|
|
|
|
isDeck = function(x) return x.type == "Deck" end,
|
|
|
|
isCardOrDeck = function(x) return x.type == "Card" or x.type == "Deck" end,
|
|
|
|
isClue = function(x) return x.memo == "clueDoom" and x.is_face_down == false end,
|
|
|
|
isTileOrToken = function(x) return x.type == "Tile" end
|
|
|
|
}
|
|
|
|
|
|
|
|
-- performs the actual search and returns a filtered list of object references
|
|
|
|
---@param pos Table Global position
|
|
|
|
---@param rot Table Global rotation
|
|
|
|
---@param size Table Size
|
|
|
|
---@param filter String Name of the filter function
|
|
|
|
---@param direction Table Direction (positive is up)
|
|
|
|
---@param maxDistance Number Distance for the cast
|
|
|
|
local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)
|
|
|
|
if filter then filter = filterFunctions[filter] end
|
|
|
|
local searchResult = Physics.cast({
|
|
|
|
origin = pos,
|
|
|
|
direction = direction or { 0, 1, 0 },
|
|
|
|
orientation = rot or { 0, 0, 0 },
|
|
|
|
type = 3,
|
|
|
|
size = size,
|
|
|
|
max_distance = maxDistance or 0
|
|
|
|
})
|
2023-01-29 19:31:52 -05:00
|
|
|
|
2024-02-04 10:51:51 -05:00
|
|
|
-- filtering the result
|
|
|
|
local objList = {}
|
|
|
|
for _, v in ipairs(searchResult) do
|
|
|
|
if not filter or filter(v.hit_object) then
|
|
|
|
table.insert(objList, v.hit_object)
|
2023-01-29 19:31:52 -05:00
|
|
|
end
|
|
|
|
end
|
2024-02-04 10:51:51 -05:00
|
|
|
return objList
|
2023-01-29 19:31:52 -05:00
|
|
|
end
|
|
|
|
|
2024-02-04 10:51:51 -05:00
|
|
|
-- searches the specified area
|
|
|
|
SearchLib.inArea = function(pos, rot, size, filter)
|
|
|
|
return returnSearchResult(pos, rot, size, filter)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- searches the area on an object
|
|
|
|
SearchLib.onObject = function(obj, filter)
|
|
|
|
pos = obj.getPosition()
|
|
|
|
size = obj.getBounds().size:setAt("y", 1)
|
|
|
|
return returnSearchResult(pos, _, size, filter)
|
2023-01-29 19:31:52 -05:00
|
|
|
end
|
2024-02-04 10:51:51 -05:00
|
|
|
|
|
|
|
-- searches the specified position (a single point)
|
|
|
|
SearchLib.atPosition = function(pos, filter)
|
|
|
|
size = { 0.1, 2, 0.1 }
|
|
|
|
return returnSearchResult(pos, _, size, filter)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- searches below the specified position (downwards until y = 0)
|
|
|
|
SearchLib.belowPosition = function(pos, filter)
|
|
|
|
direction = { 0, -1, 0 }
|
|
|
|
maxDistance = pos.y
|
|
|
|
return returnSearchResult(pos, _, size, filter, direction, maxDistance)
|
|
|
|
end
|
|
|
|
|
|
|
|
return SearchLib
|
2023-01-29 19:31:52 -05:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
return __bundle_require("__root")
|