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("playermat/ClueCounter", function(require, _LOADED, __bundle_register, __bundle_modules)
|
|
|
|
-- Table of items which can be counted in this Bowl
|
|
|
|
-- Each entry has 2 things to enter
|
|
|
|
-- a name (what is in the name field of that object)
|
|
|
|
-- a value (how much it is worth)
|
|
|
|
-- a number in the items description will override the number entry in this table
|
|
|
|
local validCountItemList = {
|
|
|
|
["Clue"] = 1,
|
|
|
|
[""] = 1
|
|
|
|
}
|
|
|
|
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
|
|
|
|
})
|
|
|
|
loopID = Wait.time(countItems, 1, -1)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Activated once per second, counts items in bowls
|
|
|
|
function countItems()
|
|
|
|
local totalValue = 0
|
2024-01-06 21:32:29 -05:00
|
|
|
for _, item in ipairs(findValidItemsInSphere()) do
|
|
|
|
local descValue = tonumber(item.getDescription())
|
|
|
|
local stackMult = math.abs(item.getQuantity())
|
2023-01-29 19:31:52 -05:00
|
|
|
-- Use value in description if available
|
|
|
|
if descValue ~= nil then
|
|
|
|
totalValue = totalValue + descValue * stackMult
|
|
|
|
else
|
|
|
|
-- Otherwise use the value in validCountItemList
|
2024-01-06 21:32:29 -05:00
|
|
|
totalValue = totalValue + validCountItemList[item.getName()] * stackMult
|
2023-01-29 19:31:52 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
exposedValue = totalValue
|
|
|
|
self.editButton({ index = 0, label = totalValue })
|
|
|
|
end
|
|
|
|
|
|
|
|
function findValidItemsInSphere()
|
|
|
|
local items = Physics.cast({
|
|
|
|
origin = self.getPosition(),
|
|
|
|
direction = { 0, 1, 0 },
|
|
|
|
type = 2,
|
|
|
|
max_distance = 0,
|
2024-01-06 21:32:29 -05:00
|
|
|
size = { 2, 2, 2 }
|
2023-01-29 19:31:52 -05:00
|
|
|
})
|
|
|
|
|
2024-01-06 21:32:29 -05:00
|
|
|
local validItemList = {}
|
2023-01-29 19:31:52 -05:00
|
|
|
for _, entry in ipairs(items) do
|
|
|
|
if entry.hit_object ~= self then
|
2024-01-06 21:32:29 -05:00
|
|
|
if validCountItemList[entry.hit_object.getName()] ~= nil then
|
|
|
|
table.insert(validItemList, entry.hit_object)
|
2023-01-29 19:31:52 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2024-01-06 21:32:29 -05:00
|
|
|
return validItemList
|
2023-01-29 19:31:52 -05:00
|
|
|
end
|
|
|
|
|
2024-01-06 21:32:29 -05:00
|
|
|
function removeAllClues(trash)
|
|
|
|
for _, obj in ipairs(findValidItemsInSphere()) do
|
|
|
|
trash.putObject(obj)
|
2023-01-29 19:31:52 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
2024-01-06 21:32:29 -05:00
|
|
|
__bundle_register("__root", function(require, _LOADED, __bundle_register, __bundle_modules)
|
|
|
|
require("playermat/ClueCounter")
|
|
|
|
end)
|
2023-01-29 19:31:52 -05:00
|
|
|
return __bundle_require("__root")
|