Merge pull request #289 from argonui/clue-hotkey
added "take a clue" hotkey
This commit is contained in:
commit
bf2352f79b
@ -2,11 +2,12 @@ local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
|
|||||||
local playmatApi = require("playermat/PlaymatApi")
|
local playmatApi = require("playermat/PlaymatApi")
|
||||||
|
|
||||||
function onLoad()
|
function onLoad()
|
||||||
|
addHotkey("Add Doom to Agenda", addDoomToAgenda)
|
||||||
|
addHotkey("Bless/Curse Status", showBlessCurseStatus)
|
||||||
|
addHotkey("Move card to Victory Display", moveCardToVictoryDisplay)
|
||||||
|
addHotkey("Take clue from location", takeClueFromLocation)
|
||||||
addHotkey("Upkeep", triggerUpkeep)
|
addHotkey("Upkeep", triggerUpkeep)
|
||||||
addHotkey("Upkeep (Multi-handed)", triggerUpkeepMultihanded)
|
addHotkey("Upkeep (Multi-handed)", triggerUpkeepMultihanded)
|
||||||
addHotkey("Add Doom to Agenda", addDoomToAgenda)
|
|
||||||
addHotkey("Move card to Victory Display", moveCardToVictoryDisplay)
|
|
||||||
addHotkey("Bless/Curse Status", showBlessCurseStatus)
|
|
||||||
addHotkey("Wendy's Menu", addWendysMenu)
|
addHotkey("Wendy's Menu", addWendysMenu)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -48,6 +49,75 @@ function moveCardToVictoryDisplay(playerColor, hoveredObject)
|
|||||||
getObjectFromGUID("6ccd6d").call("placeCard", hoveredObject)
|
getObjectFromGUID("6ccd6d").call("placeCard", hoveredObject)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- takes a clue from a location, player needs to hover the clue directly or the location
|
||||||
|
function takeClueFromLocation(playerColor, hoveredObject)
|
||||||
|
local cardName, clue
|
||||||
|
|
||||||
|
if hoveredObject == nil then
|
||||||
|
broadcastToColor("Hover a clue or card with clues and try again.", playerColor, "Yellow")
|
||||||
|
return
|
||||||
|
elseif hoveredObject.tag == "Card" then
|
||||||
|
cardName = hoveredObject.getName()
|
||||||
|
|
||||||
|
for _, v in ipairs(searchOnObj(hoveredObject)) do
|
||||||
|
local obj = v.hit_object
|
||||||
|
if obj.memo == "clueDoom" and obj.is_face_down == false then
|
||||||
|
clue = obj
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if clue == nil then
|
||||||
|
broadcastToColor("This card does not have any clues on it.", playerColor, "Yellow")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
elseif hoveredObject.memo == "clueDoom" then
|
||||||
|
if hoveredObject.is_face_down then
|
||||||
|
broadcastToColor("This is a doom token and not a clue.", playerColor, "Yellow")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
clue = hoveredObject
|
||||||
|
|
||||||
|
local search = Physics.cast({
|
||||||
|
direction = { 0, -1, 0 },
|
||||||
|
max_distance = 0.1,
|
||||||
|
type = 3,
|
||||||
|
size = { 0.1, 0.1, 0.1 },
|
||||||
|
origin = clue.getPosition()
|
||||||
|
})
|
||||||
|
|
||||||
|
for _, v in ipairs(search) do
|
||||||
|
local obj = v.hit_object
|
||||||
|
if obj.tag == "Card" then
|
||||||
|
cardName = obj.getName()
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
broadcastToColor("Hover a clue or card with clues and try again.", playerColor, "Yellow")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local playerName = Player[playerColor].steam_name
|
||||||
|
local matColor = playmatApi.getMatColor(playerColor)
|
||||||
|
local pos = playmatApi.transformLocalPosition({x = -1.12, y = 0.05, z = 0.7}, matColor)
|
||||||
|
local rot = playmatApi.returnRotation(matColor)
|
||||||
|
|
||||||
|
if cardName == "" or cardName == nil then
|
||||||
|
cardName = "nameless card"
|
||||||
|
end
|
||||||
|
|
||||||
|
clue.setPositionSmooth(pos)
|
||||||
|
clue.setRotation(rot)
|
||||||
|
|
||||||
|
if cardName then
|
||||||
|
broadcastToAll(playerName .. " took one clue from " .. cardName .. ".", playerColor)
|
||||||
|
else
|
||||||
|
broadcastToAll(playerName .. " took one clue.", "Green")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- broadcasts the bless/curse status to the calling player
|
-- broadcasts the bless/curse status to the calling player
|
||||||
function showBlessCurseStatus(playerColor)
|
function showBlessCurseStatus(playerColor)
|
||||||
blessCurseManagerApi.broadcastStatus(playerColor)
|
blessCurseManagerApi.broadcastStatus(playerColor)
|
||||||
@ -57,3 +127,15 @@ end
|
|||||||
function addWendysMenu(playerColor, hoveredObject)
|
function addWendysMenu(playerColor, hoveredObject)
|
||||||
blessCurseManagerApi.addWendysMenu(playerColor, hoveredObject)
|
blessCurseManagerApi.addWendysMenu(playerColor, hoveredObject)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- searches on an object (by using its bounds)
|
||||||
|
---@param obj Object Object to search on
|
||||||
|
function searchOnObj(obj)
|
||||||
|
return Physics.cast({
|
||||||
|
direction = { 0, 1, 0 },
|
||||||
|
max_distance = 0.5,
|
||||||
|
type = 3,
|
||||||
|
size = obj.getBounds().size,
|
||||||
|
origin = obj.getPosition()
|
||||||
|
})
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user