Addressed Feedback on Summoned Servitor changes from #227

This commit is contained in:
Jorge Parra 2023-03-07 11:48:30 -05:00
parent 392c7f94b0
commit c48533ec29

View File

@ -31,16 +31,13 @@ existingBoxes = { 1, 1, 1, 1, 1, 2, 3, 5 }
inputBoxes = {} inputBoxes = {}
-- Locations of the skill selectors -- Locations of the slot selectors
local SLOT_ICON_POSITIONS = { local SLOT_ICON_POSITIONS = {
arcane = { x = 0.160, z = 0.65}, arcane = { x = 0.160, z = 0.65},
ally = { x = -0.073, z = 0.65} ally = { x = -0.073, z = 0.65}
} }
local selectedSlots = { local selectedSlot = ""
arcane = false,
ally = false
}
-- override 'marked boxes' for debugging ('all' or 'none') -- override 'marked boxes' for debugging ('all' or 'none')
markDEBUG = "" markDEBUG = ""
@ -48,15 +45,7 @@ markDEBUG = ""
-- save state when going into bags / decks -- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end function onDestroy() self.script_state = onSave() end
function onSave() function onSave() return JSON.encode({ markedBoxes, inputValues, selectedSlot }) end
local slotArray = { }
for slot, isSelected in pairs(selectedSlots) do
if (isSelected) then
table.insert(slotArray, slot)
end
end
return JSON.encode({ markedBoxes, inputValues, slotArray })
end
-- Startup procedure -- Startup procedure
function onLoad(saved_data) function onLoad(saved_data)
@ -64,12 +53,10 @@ function onLoad(saved_data)
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1] markedBoxes = loaded_data[1]
inputValues = loaded_data[2] inputValues = loaded_data[2]
log(loaded_data[3]) if #loaded_data > 2 then
for _, slot in ipairs(loaded_data[3]) do selectedSlot = loaded_data[3]
if (slot ~= "") then else
log("Slot from load "..slot) selectedSlot = ""
selectedSlots[slot] = true
end
end end
else else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
@ -210,7 +197,7 @@ function createButtonsAndBoxes()
makeSlotSelectionButtons() makeSlotSelectionButtons()
end end
-- Creates the invisible buttons overlaying the skill icons -- Creates the invisible buttons overlaying the slot words
function makeSlotSelectionButtons() function makeSlotSelectionButtons()
local buttonPositions = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z } local buttonPositions = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z }
local buttonData = { local buttonData = {
@ -230,45 +217,33 @@ function makeSlotSelectionButtons()
end end
function click_arcane() function click_arcane()
selectedSlots.arcane = not selectedSlots.arcane if selectedSlot ~= "arcane" then
updateSlotDisplay() selectedSlot = "arcane"
end else
selectedSlot = ""
function click_ally()
selectedSlots.ally = not selectedSlots.ally
updateSlotDisplay()
end
-- Refresh the vector circles indicating a slot is selected. Since we can only have one table of
-- vectors set, have to refresh all 2 at once
function updateSlotDisplay()
local circles = { }
for slot, isSelected in pairs(selectedSlots) do
if isSelected then
local circle = getCircleVector(SLOT_ICON_POSITIONS[slot], slot)
if circle ~= nil then
table.insert(circles, circle)
end
end
end end
self.setVectorLines(circles) updateSlotDisplay()
end end
function getCircleVector(center, slot) function click_ally()
-- local diameter = Vector(0, 0, 0.1) if selectedSlot ~= "ally" then
-- local pointOfOrigin = Vector(center.x, 0.3, center.z) selectedSlot = "ally"
else
selectedSlot = ""
end
updateSlotDisplay()
end
-- Refresh the vector circles indicating a slot is selected.
function updateSlotDisplay()
local box = {}
if selectedSlot ~= "" then
box = getBoxVector(SLOT_ICON_POSITIONS[selectedSlot], selectedSlot)
end
self.setVectorLines({box})
end
-- -- Declare Results vectors function getBoxVector(center, slot)
-- local vec = Vector(0, 0, 0)
-- local vecList = {}
-- local arcStep = 5
-- for i = 0, 360, arcStep do
-- diameter:rotateOver('y', arcStep)
-- vec = pointOfOrigin + diameter
-- vec.y = pointOfOrigin.y
-- table.insert(vecList, vec)
-- end
local vecList = {} local vecList = {}
if slot == "arcane" then if slot == "arcane" then
vecList = { vecList = {