diff --git a/objects/OptionPanelSource.830bd0/jaqenZannsNavigationOverlay.a8affa/CameraPlacementHelper.cecc3e.ttslua b/objects/OptionPanelSource.830bd0/jaqenZannsNavigationOverlay.a8affa/CameraPlacementHelper.cecc3e.ttslua
index 86536348..2f40b35c 100644
--- a/objects/OptionPanelSource.830bd0/jaqenZannsNavigationOverlay.a8affa/CameraPlacementHelper.cecc3e.ttslua
+++ b/objects/OptionPanelSource.830bd0/jaqenZannsNavigationOverlay.a8affa/CameraPlacementHelper.cecc3e.ttslua
@@ -1,162 +1,174 @@
+--Data tables used in button creation
+ref_modifyPitchButtons = {
+ { offset = -0.37, func = function() click_modify(-1, 0) end },
+ { offset = -1.11, func = function() click_modify(-5, 0) end },
+ { offset = 0.37, func = function() click_modify(1, 0) end },
+ { offset = 1.11, func = function() click_modify(5, 0) end },
+}
+ref_modifyDistanceButtons = {
+ { offset = -0.37, func = function() click_modify(-1, 1) end },
+ { offset = -1.11, func = function() click_modify(-5, 1) end },
+ { offset = 0.37, func = function() click_modify(1, 1) end },
+ { offset = 1.11, func = function() click_modify(5, 1) end },
+}
+
--On-demand save function, remembers pitch and distance values
function updateSave()
- saved_data = JSON.encode({pitch=pitch, distance=distance})
- self.script_state = saved_data
+ self.script_state = JSON.encode({ pitch = pitch, distance = distance })
end
--Startup, loading memory
function onload(saved_data)
- --Loads the tracking for if the game has started yet
- if saved_data ~= "" then
- local loaded_data = JSON.decode(saved_data)
- pitch = loaded_data.pitch
- distance = loaded_data.distance
- else
- pitch = 45
- distance = 30
- end
+ --Loads the tracking for if the game has started yet
+ if saved_data ~= "" then
+ local loaded_data = JSON.decode(saved_data)
+ pitch = loaded_data.pitch
+ distance = loaded_data.distance
+ else
+ pitch = 45
+ distance = 30
+ end
- createInputs()
- createButtons()
+ createInputs()
+ createButtons()
end
--Activated by finishing writing in the input box, updates save info
-function input_entered(inputString, stillEditing , typeIndex)
- if stillEditing == false then
- --Check to avoid empty input strings
- if tonumber(inputString) == nil then inputString = 0 end
- --Update save data
- if typeIndex==0 then
- pitch = inputString
- else
- distance = inputString
- end
- updateSave()
+function input_entered(inputString, stillEditing, typeIndex)
+ if stillEditing == false then
+ --Check to avoid empty input strings
+ if tonumber(inputString) == nil then inputString = 0 end
+ --Update save data
+ if typeIndex == 0 then
+ pitch = inputString
+ else
+ distance = inputString
end
+ updateSave()
+ end
end
--Activated by button, the -5 -1 +1 +5 buttons
function click_modify(amount, typeIndex)
- if typeIndex==0 then
- pitch = pitch + amount
- self.editInput({index=typeIndex, value=pitch})
- else
- distance = distance + amount
- self.editInput({index=typeIndex, value=distance})
- end
- updateSave()
+ if typeIndex == 0 then
+ pitch = pitch + amount
+ self.editInput({ index = typeIndex, value = pitch })
+ else
+ distance = distance + amount
+ self.editInput({ index = typeIndex, value = distance })
+ end
+ updateSave()
end
--Activated by button, uses the data to move the camera
function click_setCamera(_, color)
- --Check if there is another object to use instead of self
- local targetObj = self
- local nameGUID = string.sub(self.getName(), 1, 6)
- if getObjectFromGUID(nameGUID) ~= nil then
- targetObj = getObjectFromGUID(nameGUID)
- end
-
- --Check if there is an offset to use instead of 180
- local offsetY = 180
- local offsetString = string.sub(self.getName(), 7)
- if tonumber(string.match(offsetString, "%d+")) ~= nil then
- offsetY = tonumber(string.match(offsetString, "%d+"))
- end
-
- --Move camera into position around object
- local pos = targetObj.getPosition()
- local rot = targetObj.getRotation()
- rot.y = rot.y + offsetY
- Player[color].lookAt({position=pos, pitch=pitch, yaw=rot.y, distance=distance})
-
- local objectList = getObjects()
- local AHLCGNavTile = nil
-
- for i,v in ipairs(objectList) do
- if v.getName() == "jaqenZann's Navigation Overlay Tile" then
- AHLCGNavTile = v
- break
- end
- end
-
--- local AHLCGNavTile = getObjectFromGUID("0ffbc5")
- if AHLCGNavTile then
- AHLCGNavTile.call('updateEditCamera', { { pos.x, pos.y, pos.z }, tonumber(pitch), rot.y, tonumber(distance) })
+ --Check if there is another object to use instead of self
+ local targetObj = self
+ local nameGUID = string.sub(self.getName(), 1, 6)
+ if getObjectFromGUID(nameGUID) ~= nil then
+ targetObj = getObjectFromGUID(nameGUID)
+ end
+
+ --Check if there is an offset to use instead of 180
+ local offsetY = 180
+ local offsetString = string.sub(self.getName(), 7)
+ if tonumber(string.match(offsetString, "%d+")) ~= nil then
+ offsetY = tonumber(string.match(offsetString, "%d+"))
+ end
+
+ --Move camera into position around object
+ local pos = targetObj.getPosition()
+ local rot = targetObj.getRotation()
+ rot.y = rot.y + offsetY
+ Player[color].lookAt({ position = pos, pitch = pitch, yaw = rot.y, distance = distance })
+
+ --Send values to main tile
+ for _, v in ipairs(getObjects()) do
+ if v.getName() == "jaqenZann's Navigation Overlay Tile" then
+ v.call('updateEditCamera', { { pos.x, pos.y, pos.z }, tonumber(pitch), rot.y, tonumber(distance) })
+ break
end
+ end
end
-
-
-
--Button/Input creation
-
-
-
--Text boxes for number input
function createInputs()
- local funcName = "inputFuncNamePitch"
- local func = function(_,_,x,z) input_entered(x,z,0) end
- self.setVar(funcName, func)
- self.createInput({
- input_function=funcName, function_owner=self, label="input",
- alignment=2, position={-3.4,0.35,-0.21}, rotation={0,0,0}, height=420, width=1400,
- font_size=400, color={57/255,46/255,40/255},
- font_color={1,1,1}, value=pitch,
- validation=3 -- int (1 = None, 2 = Integer, 3 = Float, 4 = Alphanumeric, 5 = Username, 6 = Name),
- })
- local funcName = "inputFuncNameDistance"
- local func = function(_,_,x,z) input_entered(x,z,1) end
- self.setVar(funcName, func)
- self.createInput({
- input_function=funcName, function_owner=self, label="input",
- alignment=4, position={3.4,0.35,-0.21}, rotation={0,0,0}, height=420, width=1400,
- font_size=400, color={57/255,46/255,40/255},
- font_color={1,1,1}, value=distance,
- validation=3 -- int (1 = None, 2 = Integer, 3 = Float, 4 = Alphanumeric, 5 = Username, 6 = Name),
- })
+ local funcName = "inputFuncNamePitch"
+ local func = function(_, _, x, z) input_entered(x, z, 0) end
+ self.setVar(funcName, func)
+ self.createInput({
+ input_function = funcName,
+ function_owner = self,
+ label = "input",
+ alignment = 2,
+ position = { -3.4, 0.35, -0.21 },
+ rotation = { 0, 0, 0 },
+ height = 420,
+ width = 1400,
+ font_size = 400,
+ color = { 57 / 255, 46 / 255, 40 / 255 },
+ font_color = { 1, 1, 1 },
+ value = pitch,
+ validation = 3
+ })
+ local funcName = "inputFuncNameDistance"
+ local func = function(_, _, x, z) input_entered(x, z, 1) end
+ self.setVar(funcName, func)
+ self.createInput({
+ input_function = funcName,
+ function_owner = self,
+ label = "input",
+ alignment = 4,
+ position = { 3.4, 0.35, -0.21 },
+ rotation = { 0, 0, 0 },
+ height = 420,
+ width = 1400,
+ font_size = 400,
+ color = { 57 / 255, 46 / 255, 40 / 255 },
+ font_color = { 1, 1, 1 },
+ value = distance,
+ validation = 3
+ })
end
--Center button and -5 - +5 buttons
function createButtons()
+ self.createButton({
+ click_function = "click_setCamera",
+ function_owner = self,
+ position = { 0, 0.4, 0 },
+ height = 900,
+ width = 900,
+ color = { 1, 1, 1, 0 },
+ tooltip = "Set camera to this angle"
+ })
+
+ for i, ref in ipairs(ref_modifyPitchButtons) do
+ local funcName = "pitchModifyFunction_" .. i
+ self.setVar(funcName, ref.func)
+ local pos = { -3.4 + ref.offset, 0.3, 0.6 }
self.createButton({
- click_function="click_setCamera", function_owner=self,
- position={0,0.4,0}, height=900, width=900, color={1,1,1,0},
- tooltip="Set camera to this angle"
+ click_function = funcName,
+ function_owner = self,
+ position = pos,
+ height = 240,
+ width = 320,
+ color = { 1, 1, 1, 0 }
})
+ end
- for i, ref in ipairs(ref_modifyPitchButtons) do
- local funcName = "pitchModifyFunction_"..i
- self.setVar(funcName, ref.func)
- local pos = {-3.4+ref.offset,0.3,0.6}
- self.createButton({
- click_function=funcName, function_owner=self,
- position=pos, height=240, width=320, color={1,1,1,0}
- })
- end
-
- for i, ref in ipairs(ref_modifyDistanceButtons) do
- local funcName = "distanceModifyFunction_"..i
- self.setVar(funcName, ref.func)
- local pos = {3.4+ref.offset,0.3,0.6}
- self.createButton({
- click_function=funcName, function_owner=self,
- position=pos, height=240, width=320, color={1,1,1,0}
- })
- end
+ for i, ref in ipairs(ref_modifyDistanceButtons) do
+ local funcName = "distanceModifyFunction_" .. i
+ self.setVar(funcName, ref.func)
+ local pos = { 3.4 + ref.offset, 0.3, 0.6 }
+ self.createButton({
+ click_function = funcName,
+ function_owner = self,
+ position = pos,
+ height = 240,
+ width = 320,
+ color = { 1, 1, 1, 0 }
+ })
+ end
end
-
---Data tables used in button creation
-
-ref_modifyPitchButtons = {
- {offset=-0.37, func=function() click_modify(-1, 0) end},
- {offset=-1.11, func=function() click_modify(-5, 0) end},
- {offset=0.37, func=function() click_modify(1, 0) end},
- {offset=1.11, func=function() click_modify(5, 0) end},
-}
-
-ref_modifyDistanceButtons = {
- {offset=-0.37, func=function() click_modify(-1, 1) end},
- {offset=-1.11, func=function() click_modify(-5, 1) end},
- {offset=0.37, func=function() click_modify(1, 1) end},
- {offset=1.11, func=function() click_modify(5, 1) end},
-}
diff --git a/objects/OptionPanelSource.830bd0/jaqenZannsNavigationOverlay.a8affa/jaqenZannsNavigationOverlayTile.9f2481.ttslua b/objects/OptionPanelSource.830bd0/jaqenZannsNavigationOverlay.a8affa/jaqenZannsNavigationOverlayTile.9f2481.ttslua
index f52a08a2..906d5572 100644
--- a/objects/OptionPanelSource.830bd0/jaqenZannsNavigationOverlay.a8affa/jaqenZannsNavigationOverlayTile.9f2481.ttslua
+++ b/objects/OptionPanelSource.830bd0/jaqenZannsNavigationOverlay.a8affa/jaqenZannsNavigationOverlayTile.9f2481.ttslua
@@ -197,7 +197,6 @@ function onLoad(saved_data)
editing = false
claiming = false
selectedEditButton = -1
-
editPos = { 0, 0, 0 }
editPitch = 0
editYaw = 0
@@ -205,12 +204,11 @@ function onLoad(saved_data)
if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data)
-
cameraParams = loaded_data.cameras
fullVisibility = loaded_data.fullVis
playVisibility = loaded_data.playVis
- local allclaims = loaded_data.claims
+ local allclaims = loaded_data.claims
for i = 1, 4 do
playermatData[i].claims = allclaims[i]
end
@@ -285,7 +283,7 @@ function displayPlayArea(object, color)
colors = { getIndexForPlayerColor(color) }
end
- for i, v in ipairs(colors) do
+ for _, v in ipairs(colors) do
if v > 0 then
fullVisibility[v] = false
playVisibility[v] = true
@@ -334,7 +332,7 @@ function closeOverlay(object, color)
colors = { getIndexForPlayerColor(color) }
end
- for iv, v in ipairs(colors) do
+ for _, v in ipairs(colors) do
if v > 0 then
fullVisibility[v] = false
playVisibility[v] = false
@@ -356,7 +354,7 @@ function resizeOverlay(object, color)
colors = { getIndexForPlayerColor(color) }
end
- for iv, v in ipairs(colors) do
+ for _, v in ipairs(colors) do
if v > 0 then
local full = fullVisibility[v]
fullVisibility[v] = not full
@@ -429,7 +427,7 @@ function resetOverlay()
[[" allowDragging="true" returnToOriginalPositionWhenReleased="false" rectAlignment="LowerRight" offsetXY="-40 0">
]]
- for i, d in ipairs(data) do
+ for _, d in ipairs(data) do
local buttonID = tonumber(d.id)
if editing and buttonID < 19 then
@@ -474,7 +472,7 @@ function resetOverlay()
[[" allowDragging="true" returnToOriginalPositionWhenReleased="false" rectAlignment="LowerRight" offsetXY="-40 0">
]]
- for i, d in ipairs(data) do
+ for _, d in ipairs(data) do
local buttonID = tonumber(d.id)
if editing and buttonID < 19 then
@@ -514,8 +512,8 @@ function resetOverlay()
local largeOverlay = nil
local smallOverlay = nil
- for i, v in pairs(existingAssets) do
- for ii, vv in pairs(v) do
+ for _, v in pairs(existingAssets) do
+ for _, vv in pairs(v) do
if vv == 'OverlayLarge' then
largeOverlay = v
end
@@ -548,12 +546,11 @@ end
function buttonClicked(player, _, idValue)
local buttonID = tonumber(idValue)
- if buttonID >= 19 then
- if buttonID == 19 then
- resizeOverlay(nil, player.color)
- elseif buttonID == 20 then
- closeOverlay(nil, player.color)
- end
+ if buttonID == 19 then
+ resizeOverlay(nil, player.color)
+ return
+ elseif buttonID == 20 then
+ closeOverlay(nil, player.color)
return
end
@@ -637,7 +634,7 @@ function loadCamera(player, _, idValue)
local minZ = 100
local maxZ = -100
- for i, v in pairs(mapObjects) do
+ for _, v in pairs(mapObjects) do
local obj = v.hit_object
if obj.type == 'Card' or obj.type == 'Infinite' then
@@ -647,32 +644,19 @@ function loadCamera(player, _, idValue)
local z1 = bounds['center'][3] - bounds['size'][3] / 2
local z2 = bounds['center'][3] + bounds['size'][3] / 2
- if x1 < minX then
- minX = x1
- end
- if x2 > maxX then
- maxX = x2
- end
- if z1 < minZ then
- minZ = z1
- end
- if z2 > maxZ then
- maxZ = z2
- end
+ minX = math.min(x1, minX)
+ maxX = math.max(x2, maxX)
+ minZ = math.min(z1, minZ)
+ maxZ = math.max(z2, maxZ)
end
end
if minX < 100 then
local dx = maxX - minX
- local dz = (maxZ - minZ) / (1.6) -- screen ratio * 1.2 (for my macbook pro, no idea how to generalize this)
- local centerX = (minX + maxX) /
- 2 -- - dx*0.12 -- offset is to move it a bit up, so the cards don't block anything
+ local dz = (maxZ - minZ) / (1.6) -- screen ratio * 1.2 (for my macbook pro, no idea how to generalize this)
+ local centerX = (minX + maxX) / 2 -- offset is to move it a bit up, so the cards don't block anything
local centerZ = (minZ + maxZ) / 2
-
- local scale = dx
- if dz > dx then
- scale = dz
- end
+ local scale = math.max(dx, dz)
-- regression line from the following data points, seems linear
-- rows 1 scale 4.5 d 12
@@ -682,13 +666,8 @@ function loadCamera(player, _, idValue)
-- rows 5 scale 23.25 d 28
-- rows 6 scale 30.8 d 34
- -- local d = 0.8685 * scale + 7.4505
-
-- modified by testing
- -- local d = 0.8685 * scale + 5
- -- local d = 1.04 * scale + 5
local d = 0.96 * scale + 5
-
player.lookAt({ position = { centerX, 0, centerZ }, pitch = 74, yaw = 90, distance = d })
else
player.lookAt({ position = { -30.667, 0, 0 }, pitch = 74, yaw = 90, distance = 32 })
@@ -721,75 +700,42 @@ function loadCamera(player, _, idValue)
for i, v in pairs(matObjects) do
local obj = v.hit_object
-
if obj.type == 'Card' or obj.type == 'Infinite' then
local bounds = obj.getBounds()
-
local x1 = bounds['center'][1] - bounds['size'][1] / 2
local x2 = bounds['center'][1] + bounds['size'][1] / 2
local z1 = bounds['center'][3] - bounds['size'][3] / 2
local z2 = bounds['center'][3] + bounds['size'][3] / 2
- if x1 < minX then
- minX = x1
- end
- if x2 > maxX then
- maxX = x2
- end
- if z1 < minZ then
- minZ = z1
- end
- if z2 > maxZ then
- maxZ = z2
- end
+ minX = math.min(x1, minX)
+ maxX = math.max(x2, maxX)
+ minZ = math.min(z1, minZ)
+ maxZ = math.max(z2, maxZ)
end
end
- local dx
- local dz
- local centerX
- local centerZ
- local scale
- local yaw
- local d
+ local dx, dz, centerX, centerZ, yaw
-- White/Orange
if index > 3 and index < 6 then
dx = maxX - minX
dz = (maxZ - minZ) / 1.6 -- screen ratio * 1.2 (for my macbook pro, no idea how to generalize this)
-
- -- offset is to move it a bit up, so the cards don't block anything
- centerX = (minX + maxX) / 2 - dx * playermatData[newMatIndex].xOffset
-
- -- offset is to move it right a bit, so the toolbar doesn't block anything
- centerZ = (minZ + maxZ) / 2 + dz * playermatData[newMatIndex].zOffset
yaw = 90
- scale = dx
- if dz > dx then
- scale = dz
- end
-
- d = 0.64 * scale + 7
- else -- Green/Red
- dx = (maxX - minX) / 1.6 -- screen ratio * 1.2 (for my macbook pro, no idea how to generalize this)
+ -- offset is to move it a bit up and right, so the cards/toolbar don't block anything
+ centerX = (minX + maxX) / 2 - dx * playermatData[newMatIndex].xOffset
+ centerZ = (minZ + maxZ) / 2 + dz * playermatData[newMatIndex].zOffset
+ -- Green/Red
+ else
+ dx = (maxX - minX) / 1.6
dz = maxZ - minZ
-
+ yaw = playermatData[newMatIndex].orientation.y + 180
centerX = (minX + maxX) / 2 + dx * playermatData[newMatIndex].zOffset
centerZ = (minZ + maxZ) / 2 - dz * playermatData[newMatIndex].xOffset
- yaw = playermatData[newMatIndex].orientation.y + 180
-
- scale = dz
- if dx > dz then
- scale = dx
- end
-
- d = 0.64 * scale + 7
end
- -- 15.46 -> 17.081
- -- 18.88 -> 19.33
- -- 24.34 -> 22.6
+ local scale = math.max(dx, dz)
+ local d = 0.64 * scale + 7
-- need to wait if the player color changed
Wait.frames(function()
@@ -882,13 +828,10 @@ function getPlayerColorForIndex(index)
end
local guid = playermatData[index]['guid']
-
if guid ~= nil then
local mat = getObjectFromGUID(guid)
return mat.getVar("playerColor")
end
-
- return nil
end
function getIndexForPlayerColor(color)