Merge pull request #94 from argonui/optionpanel-2

Optionpanel: Part 2
This commit is contained in:
Chr1Z 2022-12-16 03:20:01 +01:00 committed by GitHub
commit 67c9cf2643
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 195 additions and 460 deletions

View File

@ -67,6 +67,10 @@
"ScriptingTrigger.67ce9a",
"Detailedphasereference.68fe54",
"RulesIndex.91c83e",
"Clues.3f22e5",
"Clues.db85d6",
"Clues.891403",
"Clues.4111de",
"Resources.4406f0",
"Damage.eb08d6",
"Horror.468e88",
@ -129,11 +133,10 @@
"LeakedItems.42cd6e",
"ChaosTokenReserve.106418",
"3DText.134348",
"Custom_Model.032300",
"Custom_Model.1769ed",
"Custom_Model.37be78",
"Custom_Model.d86b7c",
"ClueCounterSwapper.d919d6",
"ClueCounter.37be78",
"ClueCounter.1769ed",
"ClueCounter.032300",
"ClueCounter.d86b7c",
"MasterClueCounter.4a3aa4",
"LegacyAssets.7165a9",
"Weaknessdecks.750fdd",

View File

@ -46,16 +46,16 @@
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Custom_Model",
"Nickname": "",
"Nickname": "Clue Counter",
"Snap": true,
"Sticky": true,
"Tooltip": true,
"Tooltip": false,
"Transform": {
"posX": -31.911,
"posY": 1.57,
"posZ": 30.97,
"posX": -32.193,
"posY": 1.52,
"posZ": 30.977,
"rotX": 0,
"rotY": 0,
"rotY": 10,
"rotZ": 0,
"scaleX": 0.33,
"scaleY": 0.33,

View File

@ -46,16 +46,16 @@
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Custom_Model",
"Nickname": "",
"Nickname": "Clue Counter",
"Snap": true,
"Sticky": true,
"Tooltip": true,
"Tooltip": false,
"Transform": {
"posX": -59.449,
"posY": 1.57,
"posZ": -22.628,
"posX": -59.426,
"posY": 1.52,
"posZ": -22.721,
"rotX": 0,
"rotY": 270,
"rotY": 280,
"rotZ": 0,
"scaleX": 0.33,
"scaleY": 0.33,

View File

@ -46,16 +46,16 @@
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Custom_Model",
"Nickname": "",
"Nickname": "Clue Counter",
"Snap": true,
"Sticky": true,
"Tooltip": true,
"Tooltip": false,
"Transform": {
"posX": -18.983,
"posY": 1.57,
"posZ": -31.01,
"posX": -18.87,
"posY": 1.52,
"posZ": -30.977,
"rotX": 0,
"rotY": 180,
"rotY": 190,
"rotZ": 0,
"scaleX": 0.33,
"scaleY": 0.33,

View File

@ -46,16 +46,16 @@
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Custom_Model",
"Nickname": "",
"Nickname": "Clue Counter",
"Snap": true,
"Sticky": true,
"Tooltip": true,
"Tooltip": false,
"Transform": {
"posX": -59.499,
"posY": 1.57,
"posZ": 9.561,
"posX": -59.426,
"posY": 1.52,
"posZ": 9.395,
"rotX": 0,
"rotY": 270,
"rotY": 280,
"rotZ": 0,
"scaleX": 0.33,
"scaleY": 0.33,

View File

@ -1,77 +0,0 @@
{
"AltLookAngle": {
"x": 0,
"y": 0,
"z": 0
},
"Autoraise": true,
"Bag": {
"Order": 0
},
"ColorDiffuse": {
"b": 1,
"g": 0.99217,
"r": 1
},
"ContainedObjects_order": [
"Clues.3f22e5",
"Clues.4111de",
"Clues.891403",
"Clues.db85d6"
],
"ContainedObjects_path": "ClueCounterSwapper.d919d6",
"CustomMesh": {
"CastShadows": true,
"ColliderURL": "",
"Convex": true,
"CustomShader": {
"FresnelStrength": 0,
"SpecularColor": {
"b": 1,
"g": 1,
"r": 1
},
"SpecularIntensity": 0,
"SpecularSharpness": 2
},
"DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/1179328606460871995/F2AFA106E788BB456C6F9134CE7A7B14D510F973/",
"MaterialIndex": 3,
"MeshURL": "http://pastebin.com/raw.php?i=uWAmuNZ2",
"NormalURL": "",
"TypeIndex": 6
},
"Description": "Counter mode courtesy of tadgh's clue counter mod: https://steamcommunity.com/sharedfiles/filedetails/?id=2115363630",
"DragSelectable": true,
"GMNotes": "",
"GUID": "d919d6",
"Grid": true,
"GridProjection": false,
"Hands": false,
"HideWhenFaceDown": false,
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScript": "require(\"util/ClueCounterSwapper\")",
"LuaScriptState_path": "ClueCounterSwapper.d919d6.luascriptstate",
"MaterialIndex": -1,
"MeasureMovement": false,
"MeshIndex": -1,
"Name": "Custom_Model_Bag",
"Nickname": "Clue Counter Swapper",
"Snap": true,
"Sticky": true,
"Tooltip": false,
"Transform": {
"posX": -50.9,
"posY": 1.51,
"posZ": 0,
"rotX": 0,
"rotY": 270,
"rotZ": 0,
"scaleX": 0.4,
"scaleY": 0.01,
"scaleZ": 0.4
},
"Value": 0,
"XmlUI": ""
}

View File

@ -1 +0,0 @@
{"ml":{"3f22e5":{"lock":true,"pos":{"x":-59.50,"y":1.54,"z":9.56},"rot":{"x":0,"y":280,"z":0}},"4111de":{"lock":true,"pos":{"x":-59.45,"y":1.54,"z":-22.63},"rot":{"x":0,"y":280,"z":0}},"891403":{"lock":true,"pos":{"x":-31.91,"y":1.54,"z":30.97},"rot":{"x":0,"y":10,"z":0}},"db85d6":{"lock":true,"pos":{"x":-18.98,"y":1.54,"z":-31.01},"rot":{"x":0,"y":190,"z":0}}}}

View File

@ -40,13 +40,16 @@
"Nickname": "Clues",
"Snap": true,
"Sticky": true,
"Tags": [
"CleanUpHelper_ignore"
],
"Tooltip": false,
"Transform": {
"posX": -59.318,
"posY": 1.64,
"posZ": -17.674,
"posX": -59.426,
"posY": 1.3,
"posZ": -22.721,
"rotX": 0,
"rotY": 270,
"rotY": 280,
"rotZ": 0,
"scaleX": 0.26,
"scaleY": 1,

View File

@ -40,13 +40,16 @@
"Nickname": "Clues",
"Snap": true,
"Sticky": true,
"Tags": [
"CleanUpHelper_ignore"
],
"Tooltip": false,
"Transform": {
"posX": -23.81,
"posY": 1.589,
"posZ": -30.927,
"posX": -18.87,
"posY": 1.3,
"posZ": -30.977,
"rotX": 0,
"rotY": 180,
"rotY": 190,
"rotZ": 0,
"scaleX": 0.26,
"scaleY": 1,

View File

@ -40,13 +40,16 @@
"Nickname": "Clues",
"Snap": true,
"Sticky": true,
"Tags": [
"CleanUpHelper_ignore"
],
"Tooltip": false,
"Transform": {
"posX": -31.911,
"posY": 1.564,
"posZ": 30.92,
"posX": -32.193,
"posY": 1.3,
"posZ": 30.977,
"rotX": 0,
"rotY": 0,
"rotY": 10,
"rotZ": 0,
"scaleX": 0.26,
"scaleY": 1,

View File

@ -40,13 +40,16 @@
"Nickname": "Clues",
"Snap": true,
"Sticky": true,
"Tags": [
"CleanUpHelper_ignore"
],
"Tooltip": false,
"Transform": {
"posX": -59.439,
"posY": 1.637,
"posZ": 9.472,
"posX": -59.426,
"posY": 1.3,
"posZ": 9.395,
"rotX": 0,
"rotY": 270,
"rotY": 280,
"rotZ": 0,
"scaleX": 0.26,
"scaleY": 1,

View File

@ -6,7 +6,6 @@
-- - use the IGNORE_TAG to exclude objects from tidying (default: "CleanUpHelper_Ignore")
local playAreaApi = require("core/PlayAreaApi")
-- enable this for debugging
local SHOW_RAYS = false
@ -209,10 +208,10 @@ function resetCounters()
end
-- reset doom on agenda
-- local doomcounter = getObjectFromGUID("85c4c6")
-- if doomcounter ~= nil then
-- doomcounter.call("setToZero")
-- end
local doomcounter = getObjectFromGUID("85c4c6")
if doomcounter ~= nil then
doomcounter.call("updateVal", 0)
end
for i, guid in ipairs(TRACKER_GUIDS) do
local obj = getObjectFromGUID(guid)

View File

@ -34,7 +34,7 @@
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScript": "require(\"core/MasterClueCounter\")",
"LuaScriptState": "",
"LuaScriptState": "false",
"MeasureMovement": false,
"Name": "Custom_Token",
"Nickname": "Master Clue Counter\n",

View File

@ -11,5 +11,7 @@ DISCARD_PILE_POSITION = { x = -58.9, y = 4, z = 4.29 }
TRASHCAN_GUID = "147e80"
STAT_TRACKER_GUID = "e598c2"
RESOURCE_COUNTER_GUID = "4406f0"
CLUE_COUNTER_GUID = "d86b7c"
CLUE_CLICKER_GUID = "db85d6"
require("playermat/Playmat")

View File

@ -11,5 +11,7 @@ DISCARD_PILE_POSITION = { x = -58.96, y = 4, z = -27.82 }
TRASHCAN_GUID = "f7b6c8"
STAT_TRACKER_GUID = "b4a5f7"
RESOURCE_COUNTER_GUID = "816d84"
CLUE_COUNTER_GUID = "1769ed"
CLUE_CLICKER_GUID = "3f22e5"
require("playermat/Playmat")

View File

@ -11,5 +11,7 @@ DISCARD_PILE_POSITION = { x = -37.26, y = 4, z = 30.50 }
TRASHCAN_GUID = "5f896a"
STAT_TRACKER_GUID = "af7ed7"
RESOURCE_COUNTER_GUID = "cd15ac"
CLUE_COUNTER_GUID = "032300"
CLUE_CLICKER_GUID = "891403"
require("playermat/Playmat")

View File

@ -11,5 +11,7 @@ DISCARD_PILE_POSITION = { x = -13.78, y = 4, z = -30.48 }
TRASHCAN_GUID = "4b8594"
STAT_TRACKER_GUID = "e74881"
RESOURCE_COUNTER_GUID = "a4b60d"
CLUE_COUNTER_GUID = "37be78"
CLUE_CLICKER_GUID = "4111de"
require("playermat/Playmat")

View File

@ -675,6 +675,8 @@ function applyOptionPanelChange(id, state)
elseif id == 3 then
playmatAPI.clickableClues(state, "All")
-- update master clue counter
getObjectFromGUID("4a3aa4").setVar("useClickableCounters", state)
end
end

View File

@ -1,16 +1,17 @@
local clueCounters = {}
local clueCounterGUIDS = {
"37be78",
"1769ed",
"032300",
"d86b7c"
}
count = 0
useClickableCounters = false
function onLoad()
local playmatAPI = require("playermat/PlaymatApi")
function onSave() return JSON.encode(useClickableCounters) end
function onLoad(savedData)
if savedData ~= nil then
useClickableCounters = JSON.decode(savedData)
end
self.createButton({
label = "0",
click_function = "removeAllPlayerClues",
tooltip = "Click here to remove all Clues from playermats",
tooltip = "Click here to remove all collected clues",
function_owner = self,
position = { 0, 0.06, 0 },
height = 900,
@ -21,26 +22,18 @@ function onLoad()
color = { 0, 0, 0, 0 }
})
-- loading object references to the counting bowls via GUID
for i = 1, 4 do
clueCounters[i] = getObjectFromGUID(clueCounterGUIDS[i])
end
loopID = Wait.time(sumClues, 2, -1)
end
-- removes all player clues by calling the respective function from the counting bowls
-- removes all player clues by calling the respective function from the counting bowls / clickers
function removeAllPlayerClues()
for i = 1, 4 do
clueCounters[i].call("removeAllClues")
end
printToAll(count .. " clue(s) from playermats removed.", "White")
playmatAPI.removeClues("All")
self.editButton({ index = 0, label = "0" })
end
-- gets the counted values from the counting bowls and sums them up
-- gets the counted values from the counting bowls / clickers and sums them up
function sumClues()
local count = 0
for i = 1, 4 do
count = count + tonumber(clueCounters[i].getVar("exposedValue"))
end
count = playmatAPI.getClueCount(useClickableCounters, "All")
self.editButton({ index = 0, label = tostring(count) })
end

View File

@ -15,6 +15,7 @@ function onLoad()
label = "",
click_function = "removeAllClues",
function_owner = self,
position = { 0, 0.1, 0 },
height = 0,
width = 0,
font_color = { 0, 0, 0 },

View File

@ -688,10 +688,66 @@ function showDrawButton(visible)
end
end
-- Shows or hides the clickable clue counter for this playmat
---@param showCounters Boolean. Whether the clickable clue counter should be present
function clickableClues(showCounters)
print("dummy function for clue counters")
-- Spawns / destroys a clickable clue counter for this playmat with the correct amount of clues
---@param showCounter Boolean Whether the clickable clue counter should be present
function clickableClues(showCounter)
local CLUE_COUNTER = getObjectFromGUID(CLUE_COUNTER_GUID)
local CLUE_CLICKER = getObjectFromGUID(CLUE_CLICKER_GUID)
local clickerPos = CLUE_CLICKER.getPosition()
local clueCount = 0
if showCounter then
-- current clue count
clueCount = CLUE_COUNTER.getVar("exposedValue")
-- remove clues
CLUE_COUNTER.call("removeAllClues")
-- set value for clue clickers
CLUE_CLICKER.call("updateVal", clueCount)
-- move clue counters up
clickerPos.y = 1.52
CLUE_CLICKER.setPosition(clickerPos)
else
-- current clue count
clueCount = CLUE_CLICKER.getVar("val")
-- move clue counters down
clickerPos.y = 1.3
CLUE_CLICKER.setPosition(clickerPos)
-- spawn clues
local pos = self.positionToWorld({x = -1.12, y = 0.05, z = 0.7})
for i = 1, clueCount do
pos.y = pos.y + 0.045 * i
spawnToken(pos, "clue")
end
end
end
-- removes all clues (moving tokens to the trash and setting counters to 0)
function removeClues()
local CLUE_COUNTER = getObjectFromGUID(CLUE_COUNTER_GUID)
local CLUE_CLICKER = getObjectFromGUID(CLUE_CLICKER_GUID)
CLUE_COUNTER.call("removeAllClues")
CLUE_CLICKER.call("updateVal", 0)
end
-- reports the clue count
---@param useClickableCounters Boolean Controls which type of counter is getting checked
function getClueCount(useClickableCounters)
local count = 0
if useClickableCounters then
local CLUE_CLICKER = getObjectFromGUID(CLUE_CLICKER_GUID)
count = tonumber(CLUE_CLICKER.getVar("val"))
else
local CLUE_COUNTER = getObjectFromGUID(CLUE_COUNTER_GUID)
count = tonumber(CLUE_COUNTER.getVar("exposedValue"))
end
return count
end
-- Sets this playermat's snap points to limit snapping to matching card types or not. If matchTypes

View File

@ -6,7 +6,21 @@ do
White = "8b081b",
Orange = "bd0ff4",
Green = "383d8b",
Red = "0840d5",
Red = "0840d5"
}
local CLUE_COUNTER_GUIDS = {
White = "37be78",
Orange = "1769ed",
Green = "032300",
Red = "d86b7c"
}
local CLUE_CLICKER_GUIDS = {
White = "db85d6",
Orange = "3f22e5",
Green = "891403",
Red = "4111de"
}
-- Sets the requested playermat's snap points to limit snapping to matching card types or not. If
@ -43,6 +57,25 @@ do
end
end
-- Removes all clues (to the trash for tokens and counters set to 0) for the requested playermat
---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also
-- accepts "All" as a special value which will apply the setting to all four mats.
PlaymatApi.removeClues = function(matColor)
for _, mat in ipairs(internal.getMatForColor(matColor)) do
mat.call("removeClues")
end
end
-- Reports the clue count for the requested playermat
---@param useClickableCounters Boolean Controls which type of counter is getting checked
PlaymatApi.getClueCount = function(useClickableCounters, matColor)
local count = 0
for _, mat in ipairs(internal.getMatForColor(matColor)) do
count = count + tonumber(mat.call("getClueCount", useClickableCounters))
end
return count
end
-- Convenience function to look up a mat's object by color, or get all mats.
---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also
-- accepts "All" as a special value which will return all four mats.

View File

@ -1,294 +0,0 @@
function updateSave()
local data_to_save = { ["ml"] = memoryList }
saved_data = JSON.encode(data_to_save)
self.script_state = saved_data
end
function onload(saved_data)
if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data)
--Set up information off of loaded_data
memoryList = loaded_data.ml
else
--Set up information for if there is no saved saved data
memoryList = {}
end
if next(memoryList) == nil then
createSetupButton()
else
createMemoryActionButtons()
end
end
--Beginning Setup
--Make setup button
function createSetupButton()
self.createButton({
label = "Setup",
click_function = "buttonClick_setup",
function_owner = self,
position = { 0, 5, -2 },
rotation = { 0, 0, 0 },
height = 250,
width = 600,
font_size = 150,
color = { 0, 0, 0 },
font_color = { 1, 1, 1 }
})
end
--Triggered by setup button,
function buttonClick_setup()
memoryListBackup = duplicateTable(memoryList)
memoryList = {}
self.clearButtons()
createButtonsOnAllObjects()
createSetupActionButtons()
end
--Creates selection buttons on objects
function createButtonsOnAllObjects()
local howManyButtons = 0
for _, obj in ipairs(getAllObjects()) do
if obj ~= self then
local dummyIndex = howManyButtons
--On a normal bag, the button positions aren't the same size as the bag.
globalScaleFactor = 1.25 * 1 / self.getScale().x
--Super sweet math to set button positions
local selfPos = self.getPosition()
local objPos = obj.getPosition()
local deltaPos = findOffsetDistance(selfPos, objPos, obj)
local objPos = rotateLocalCoordinates(deltaPos, self)
objPos.x = -objPos.x * globalScaleFactor
objPos.y = objPos.y * globalScaleFactor
objPos.z = objPos.z * 4
--Offset rotation of bag
local rot = self.getRotation()
rot.y = -rot.y + 180
--Create function
local funcName = "selectButton_" .. howManyButtons
local func = function() buttonClick_selection(dummyIndex, obj) end
self.setVar(funcName, func)
self.createButton({
click_function = funcName, function_owner = self,
position = objPos, rotation = rot, height = 1000, width = 1000,
color = { 0.75, 0.25, 0.25, 0.6 },
})
howManyButtons = howManyButtons + 1
end
end
end
--Creates submit and cancel buttons
function createSetupActionButtons()
self.createButton({
label = "Cancel", click_function = "buttonClick_cancel", function_owner = self,
position = { 1.5, 5, 2 }, rotation = { 0, 0, 0 }, height = 350, width = 1100,
font_size = 250, color = { 0, 0, 0 }, font_color = { 1, 1, 1 }
})
self.createButton({
label = "Submit", click_function = "buttonClick_submit", function_owner = self,
position = { -1.2, 5, 2 }, rotation = { 0, 0, 0 }, height = 350, width = 1100,
font_size = 250, color = { 0, 0, 0 }, font_color = { 1, 1, 1 }
})
self.createButton({
label = "Reset", click_function = "buttonClick_reset", function_owner = self,
position = { -3.5, 5, 2 }, rotation = { 0, 0, 0 }, height = 350, width = 800,
font_size = 250, color = { 0, 0, 0 }, font_color = { 1, 1, 1 }
})
end
--During Setup
--Checks or unchecks buttons
function buttonClick_selection(index, obj)
local color = { 0, 1, 0, 0.6 }
if memoryList[obj.getGUID()] == nil then
self.editButton({ index = index, color = color })
--Adding pos/rot to memory table
local pos, rot = obj.getPosition(), obj.getRotation()
--I need to add it like this or it won't save due to indexing issue
memoryList[obj.getGUID()] = {
pos = { x = round(pos.x, 4), y = round(pos.y, 4), z = round(pos.z, 4) },
rot = { x = round(rot.x, 4), y = round(rot.y, 4), z = round(rot.z, 4) },
lock = obj.getLock()
}
obj.highlightOn({ 0, 1, 0 })
else
color = { 0.75, 0.25, 0.25, 0.6 }
self.editButton({ index = index, color = color })
memoryList[obj.getGUID()] = nil
obj.highlightOff()
end
end
--Cancels selection process
function buttonClick_cancel()
memoryList = memoryListBackup
self.clearButtons()
if next(memoryList) == nil then
createSetupButton()
else
createMemoryActionButtons()
end
removeAllHighlights()
broadcastToAll("Selection Canceled", { 1, 1, 1 })
end
--Saves selections
function buttonClick_submit()
if next(memoryList) == nil then
broadcastToAll("You cannot submit without any selections.", { 0.75, 0.25, 0.25 })
else
self.clearButtons()
createMemoryActionButtons()
local count = 0
for guid in pairs(memoryList) do
count = count + 1
local obj = getObjectFromGUID(guid)
if obj ~= nil then obj.highlightOff() end
end
broadcastToAll(count .. " Objects Saved", { 1, 1, 1 })
updateSave()
end
end
--Resets bag to starting status
function buttonClick_reset()
memoryList = {}
self.clearButtons()
createSetupButton()
removeAllHighlights()
broadcastToAll("Tool Reset", { 1, 1, 1 })
updateSave()
end
--After Setup
--Creates recall and place buttons
function createMemoryActionButtons()
self.createButton({
label = "Clicker", click_function = "buttonClick_place", function_owner = self,
position = { 4.2, 1, 0 }, rotation = { 0, 0, 0 }, height = 500, width = 1100,
font_size = 350, color = { 0, 0, 0 }, font_color = { 1, 1, 1 }
})
self.createButton({
label = "Counter", click_function = "buttonClick_recall", function_owner = self,
position = { -4.2, 1, -0.1 }, rotation = { 0, 0, 0 }, height = 500, width = 1300,
font_size = 350, color = { 0, 0, 0 }, font_color = { 1, 1, 1 }
})
self.createButton({
label = "Add Draw 1 Buttons", click_function = "addDraw1Buttons", function_owner = self,
position = { 0, 1, -2.5 }, rotation = { 0, 0, 0 }, height = 500, width = 2600,
font_size = 250, color = { 0, 0, 0 }, font_color = { 1, 1, 1 }
})
--[[
self.createButton({
label="Setup", click_function="buttonClick_setup", function_owner=self,
position={-6,1,0}, rotation={0,90,0}, height=500, width=1200,
font_size=350, color={0,0,0}, font_color={1,1,1}
})
--]]
end
function addDraw1Buttons()
if ADD_BUTTONS_DISABLED then return end
local mats = { "8b081b", "bd0ff4", "383d8b", "0840d5" }
for i, guid in ipairs(mats) do
local mat = getObjectFromGUID(guid)
mat.createButton({
label = "Draw 1",
click_function = "doDrawOne",
function_owner = mat,
position = { 1.84, 0.1, -0.36 },
scale = { 0.12, 0.12, 0.12 },
width = 800,
height = 280,
font_size = 180
})
end
ADD_BUTTONS_DISABLED = true
end
--Sends objects from bag/table to their saved position/rotation
function buttonClick_place()
local bagObjList = self.getObjects()
for guid, entry in pairs(memoryList) do
local obj = getObjectFromGUID(guid)
--If obj is out on the table, move it to the saved pos/rot
if obj ~= nil then
obj.setPositionSmooth(entry.pos)
obj.setRotationSmooth(entry.rot)
obj.setLock(entry.lock)
else
--If obj is inside of the bag
for _, bagObj in ipairs(bagObjList) do
if bagObj.guid == guid then
local item = self.takeObject({
guid = guid, position = entry.pos, rotation = entry.rot,
})
item.setLock(entry.lock)
break
end
end
end
end
broadcastToAll("Objects Placed", { 1, 1, 1 })
end
--Recalls objects to bag from table
function buttonClick_recall()
for guid, entry in pairs(memoryList) do
local obj = getObjectFromGUID(guid)
if obj ~= nil then self.putObject(obj) end
end
broadcastToAll("Objects Recalled", { 1, 1, 1 })
end
--Utility functions
--Find delta (difference) between 2 x/y/z coordinates
function findOffsetDistance(p1, p2, obj)
local deltaPos = {}
local bounds = obj.getBounds()
deltaPos.x = (p2.x - p1.x)
deltaPos.y = (p2.y - p1.y) + (bounds.size.y - bounds.offset.y)
deltaPos.z = (p2.z - p1.z)
return deltaPos
end
--Used to rotate a set of coordinates by an angle
function rotateLocalCoordinates(desiredPos, obj)
local objPos, objRot = obj.getPosition(), obj.getRotation()
local angle = math.rad(objRot.y)
local x = desiredPos.x * math.cos(angle) - desiredPos.z * math.sin(angle)
local z = desiredPos.x * math.sin(angle) + desiredPos.z * math.cos(angle)
return { x = x, y = desiredPos.y, z = z }
end
--Coroutine delay, in seconds
function wait(time)
local start = os.time()
repeat coroutine.yield(0) until os.time() > start + time
end
--Duplicates a table (needed to prevent it making reference to the same objects)
function duplicateTable(oldTable)
local newTable = {}
for k, v in pairs(oldTable) do
newTable[k] = v
end
return newTable
end
--Moves scripted highlight from all objects
function removeAllHighlights()
for _, obj in ipairs(getAllObjects()) do
obj.highlightOff()
end
end
--Round number (num) to the Nth decimal (dec)
function round(num, dec)
local mult = 10 ^ (dec or 0)
return math.floor(num * mult + 0.5) / mult
end

View File

@ -17,7 +17,7 @@
<Button icon="yog-sothoth" tooltip="Extras" onClick="onClick_toggleUi(Extras)"/>
<Button icon="elder-sign" tooltip="Investigators" onClick="onClick_toggleUi(Investigators)"/>
<Button icon="devourer" tooltip="Community Content" onClick="onClick_toggleUi(Community Content)"/>
<Button icon="option-gear" tooltip="Options" onClick="onClick_toggleUi(Options)" active="false"/>
<Button icon="option-gear" tooltip="Options" onClick="onClick_toggleUi(Options)"/>
<!--<Button icon="download" tooltip="ArkhamDB Deck Importer" onClick="onClick_toggleUi(Deck Importer)"/> -->
</VerticalLayout>