Advertisement
Kijan

Scripting keys

Sep 11th, 2020
1,494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.36 KB | None | 0 0
  1. function onScriptingButtonDown(index, color)
  2.    local playerList = {Player["Red"], Player["White"], Player["Blue"], Player["Green"]}
  3.    local activeColor = ""
  4.    if index < 3 then
  5.       local activePlayer = 0
  6.       local obj = Player[color].getHoverObject()
  7.       for k, v in pairs(playerList) do
  8.          for i, j in pairs(v.getHandObjects()) do
  9.             if obj == j then
  10.                activePlayer = "P" .. k
  11.                activeColor = v.color
  12.                break
  13.             end
  14.          end
  15.       end
  16.       if activePlayer ~= 0 then
  17.          local tabInfo = getNotebookTabs()
  18.          local tab = ""
  19.  
  20.          for _, t in pairs(tabInfo) do
  21.             if t.title == "Options" then tab = t.body end
  22.          end
  23.  
  24.          if tab:find("flip revealed:yes") then
  25.             obj.flip()
  26.          end
  27.  
  28.          local hitlist = Physics.cast({
  29.             origin = cardPositions[activePlayer][index],
  30.             direction = {0, 1, 0},
  31.             type = 3,
  32.             size = {0.5, 2, 0.5},
  33.             max_distance = 0,
  34.             debug = false
  35.          })
  36.  
  37.          for i, j in pairs(hitlist) do
  38.             if j.hit_object.tag == "Card" or j.hit_object.tag == "Deck" then
  39.                j.hit_object.deal(20, activeColor)
  40.             end
  41.          end
  42.          Wait.frames(function() obj.setPosition(cardPositions[activePlayer][index]) end, 10)
  43.       end
  44.    elseif index == 3 then
  45.       local playArea
  46.       for _, obj in pairs(getAllObjects()) do
  47.          if obj.getName() == "Play Area" then playArea = obj end
  48.       end
  49.  
  50.       if playArea then
  51.          playArea.call("buttonClickedEx", {"AMD"})
  52.       end
  53.    elseif index < 7 then
  54.       local activePlayer = 0
  55.       local obj = Player[color].getHoverObject()
  56.       if obj == nil then return end
  57.       for k, v in pairs(playerList) do
  58.          local objPos = obj.getPosition()
  59.          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
  60.             activePlayer = "P" .. k
  61.             break
  62.          end
  63.       end
  64.       if activePlayer ~= 0 then
  65.          if index == 6 then
  66.             local pos = checkEmpty(cardPositions[activePlayer][index])
  67.             if pos then
  68.                obj.setPosition(pos)
  69.             end
  70.          else
  71.             Wait.frames(function() obj.setPosition(cardPositions[activePlayer][index]) end, 10)
  72.          end
  73.       end
  74.    elseif index > 6 and index < 10 then
  75.       local token = getObjectFromGUID(tableToken)
  76.       token.setCustomObject({image = backgroundImages[index - 6]})
  77.       token.reload()
  78.       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)
  79.    end
  80. end
  81.  
  82. function checkEmpty(posTable)
  83.    local found = false
  84.    for i, j in pairs(posTable) do
  85.       found = false
  86.       local hitlist = Physics.cast({
  87.          origin = j,
  88.          direction = {0, 1, 0},
  89.          type = 3,
  90.          size = {1, 1, 1},
  91.          max_distance = 0,
  92.          debug = false
  93.       })
  94.  
  95.       for u, v in pairs(hitlist) do
  96.          if v.hit_object.tag == "Card" then found = true end
  97.       end
  98.       if found == false then return j end
  99.    end
  100.  
  101.    return false
  102. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement