Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onScriptingButtonDown(index, color)
- local playerList = {Player["Red"], Player["White"], Player["Blue"], Player["Green"]}
- local activeColor = ""
- if index < 3 then
- local activePlayer = 0
- local obj = Player[color].getHoverObject()
- for k, v in pairs(playerList) do
- for i, j in pairs(v.getHandObjects()) do
- if obj == j then
- activePlayer = "P" .. k
- activeColor = v.color
- break
- end
- end
- end
- if activePlayer ~= 0 then
- local tabInfo = getNotebookTabs()
- local tab = ""
- for _, t in pairs(tabInfo) do
- if t.title == "Options" then tab = t.body end
- end
- if tab:find("flip revealed:yes") then
- obj.flip()
- end
- local hitlist = Physics.cast({
- origin = cardPositions[activePlayer][index],
- direction = {0, 1, 0},
- type = 3,
- size = {0.5, 2, 0.5},
- max_distance = 0,
- debug = false
- })
- for i, j in pairs(hitlist) do
- if j.hit_object.tag == "Card" or j.hit_object.tag == "Deck" then
- j.hit_object.deal(20, activeColor)
- end
- end
- Wait.frames(function() obj.setPosition(cardPositions[activePlayer][index]) end, 10)
- end
- elseif index == 3 then
- local playArea
- for _, obj in pairs(getAllObjects()) do
- if obj.getName() == "Play Area" then playArea = obj end
- end
- if playArea then
- playArea.call("buttonClickedEx", {"AMD"})
- end
- elseif index < 7 then
- local activePlayer = 0
- local obj = Player[color].getHoverObject()
- if obj == nil then return end
- for k, v in pairs(playerList) do
- local objPos = obj.getPosition()
- if objPos[1] > cardPositions["P" .. k][1][1]-1 and objPos[1] < cardPositions["P" .. k][2][1]+1 and objPos[3] > cardPositions["P" .. k][2][3] - 1 and objPos[3] < cardPositions["P" .. k][2][3] + 1 then
- activePlayer = "P" .. k
- break
- end
- end
- if activePlayer ~= 0 then
- if index == 6 then
- local pos = checkEmpty(cardPositions[activePlayer][index])
- if pos then
- obj.setPosition(pos)
- end
- else
- Wait.frames(function() obj.setPosition(cardPositions[activePlayer][index]) end, 10)
- end
- end
- elseif index > 6 and index < 10 then
- local token = getObjectFromGUID(tableToken)
- token.setCustomObject({image = backgroundImages[index - 6]})
- token.reload()
- Wait.frames(function() Wait.condition(function() local obj = getObjectFromGUID("7ef9dd") obj.tooltip = false obj.lock() obj.interactable = false end, function() return checkLoaded(token) end) end, 1)
- end
- end
- function checkEmpty(posTable)
- local found = false
- for i, j in pairs(posTable) do
- found = false
- local hitlist = Physics.cast({
- origin = j,
- direction = {0, 1, 0},
- type = 3,
- size = {1, 1, 1},
- max_distance = 0,
- debug = false
- })
- for u, v in pairs(hitlist) do
- if v.hit_object.tag == "Card" then found = true end
- end
- if found == false then return j end
- end
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement