Advertisement
Kijan

Monster Mat

Apr 29th, 2018
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.29 KB | None | 0 0
  1. function onLoad(save_state)
  2.   buttons = {
  3.     click_function = "placeSleeve",
  4.     function_owner = self,
  5.     label          = "",
  6.     position       = {-0.61, 0.1, 0.8},
  7.     width          = 400,
  8.     height         = 100,
  9.     color          = {0,0,0,0}
  10.   }
  11.   self.createButton(buttons)
  12.  
  13.   buttons.click_function = "drawCard"
  14.   buttons.position = {0.535, 0.1, 0.8}
  15.   buttons.width = 250
  16.   self.createButton(buttons)
  17.  
  18.   buttons.click_function = "reshuffle"
  19.   buttons.position = {1.135, 0.1, 0.8}
  20.   buttons.width = 300
  21.   self.createButton(buttons)
  22. end
  23.  
  24. function placeSleeve()
  25.   getObjectFromGUID("b26c16").takeObject({
  26.     position       = self.positionToWorld({0.61, 0.5, -0.1484}),
  27.     rotation       = {0, 0, 0}
  28.   })
  29. end
  30.  
  31. function drawCard()
  32.   local hitlist = Physics.cast({
  33.     origin       = self.positionToWorld({-0.855, 0, -0.551}),
  34.     direction    = {0,1,0},
  35.     type         = 2,
  36.     size         = {1,1,1},
  37.     max_distance = 0,
  38.     debug        = false
  39.   }) -- returns {{Vector point, Vector normal, float distance, Object hit_object}, ...}
  40.  
  41.   for i, j in pairs(hitlist) do
  42.     if j.hit_object.tag == "Deck" then
  43.       j.hit_object.takeObject({
  44.         position       = self.positionToWorld({-0.855, 1, 0.2595}),
  45.         flip           = true
  46.       })
  47.       return
  48.     end
  49.   end
  50. end
  51.  
  52. function reshuffle()
  53.   local hitlist = Physics.cast({
  54.     origin       = self.positionToWorld({-0.855, 0, 0.2595}),
  55.     direction    = {0,1,0},
  56.     type         = 2,
  57.     size         = {1,1,1},
  58.     max_distance = 0,
  59.     debug        = false
  60.   }) -- returns {{Vector point, Vector normal, float distance, Object hit_object}, ...}
  61.  
  62.   for i, j in pairs(hitlist) do
  63.     if j.hit_object.tag == "Deck" or j.hit_object.tag == "Card" then
  64.       deck = Physics.cast({
  65.         origin       = self.positionToWorld({-0.855, 0, -0.551}),
  66.         direction    = {0,1,0},
  67.         type         = 2,
  68.         size         = {1,1,1},
  69.         max_distance = 0,
  70.         debug        = false
  71.       }) -- returns {{Vector point, Vector normal, float distance, Object hit_object}, ...}
  72.  
  73.       for u, v in pairs(deck) do
  74.         if v.hit_object.tag == "Deck" then
  75.           v.hit_object.putObject(j.hit_object)
  76.           v.hit_object.shuffle()
  77.         end
  78.       end
  79.       return
  80.     end
  81.   end
  82. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement