Merge pull request #712 from argonui/nav-overlay
Navigation Overlay: Added additional check to see whether playmat is already occupied
This commit is contained in:
commit
21cbeb220d
@ -189,7 +189,6 @@ end
|
|||||||
|
|
||||||
-- XML button creation
|
-- XML button creation
|
||||||
function createXmlButtonHelper(ui, params)
|
function createXmlButtonHelper(ui, params)
|
||||||
local color
|
|
||||||
local guid = self.getGUID()
|
local guid = self.getGUID()
|
||||||
local xml = findTagWithId(ui, params.id)
|
local xml = findTagWithId(ui, params.id)
|
||||||
|
|
||||||
@ -338,8 +337,8 @@ function loadCamera(player, camera)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- swap to that color if it isn't claimed by someone else
|
-- swap to that color if it isn't claimed by someone else and it's currently unoccopied
|
||||||
if #getSeatedPlayers() == 1 or not isClaimed then
|
if #getSeatedPlayers() == 1 or (not isClaimed and isPlaymatAvailable(matColor)) then
|
||||||
local newPlayerColor = playmatApi.getPlayerColor(matColor)
|
local newPlayerColor = playmatApi.getPlayerColor(matColor)
|
||||||
copyVisibility({ startColor = player.color, targetColor = newPlayerColor })
|
copyVisibility({ startColor = player.color, targetColor = newPlayerColor })
|
||||||
player.changeColor(newPlayerColor)
|
player.changeColor(newPlayerColor)
|
||||||
@ -372,6 +371,17 @@ function loadCamera(player, camera)
|
|||||||
Wait.frames(function() player.lookAt(lookHere) end, 2)
|
Wait.frames(function() player.lookAt(lookHere) end, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- helper function to check if a playmat is available for a color swap
|
||||||
|
function isPlaymatAvailable(matColor)
|
||||||
|
local newPlayerColor = playmatApi.getPlayerColor(matColor)
|
||||||
|
for _, color in ipairs(getSeatedPlayers()) do
|
||||||
|
if color == newPlayerColor then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
-- settings related functionality
|
-- settings related functionality
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user