Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. self.interactable = false
  2. --Card zone
  3. Zone = 'fdf87c'
  4. -- Zone Items
  5. ZoneItems = {}
  6. -- Item Counts
  7. Counts = {
  8. ['Ace'] = 1,
  9. ['Two'] = 2,
  10. ['Three'] = 3,
  11. ['Four'] = 4,
  12. ['Five'] = 5,
  13. ['Six'] = 6,
  14. ['Seven'] = 7,
  15. ['Eight'] = 8,
  16. ['Nine'] = 9,
  17. ['Ten'] = 10,
  18. ['Jack'] = 10,
  19. ['Queen'] = 10,
  20. ['King'] = 10,
  21. ['10-Up'] = 10,
  22. ['5-Up'] = 5,
  23. ['1-Up'] = 1,
  24. ['Fire Flower'] = -3,
  25. ['Frost Flower'] = -6
  26. }
  27. --Init Function
  28. function onLoad(save_state)
  29. --Load zone objects.
  30. Zone = getObjectFromGUID(Zone)
  31.  
  32. --Update Count Timer
  33. function startTimer()
  34. Timer.destroy(Zone.getGUID())
  35. Timer.create({
  36. ['identifier'] = Zone.getGUID(),
  37. ['function_name'] = 'updateCount',
  38. ['delay'] = 0.5,
  39. ['repetitions'] = 0,
  40. })
  41. end
  42. function countTable(table)
  43. local count = 0
  44. for _ in pairs(table) do count = count + 1 end
  45. return count
  46. end
  47. function updateCount()
  48. function startTimer()
  49. local count = 0
  50. local aces = 0
  51. local cards = 0
  52. local objects = Zone.getObjects()
  53. end
  54. for key,obj in pairs(objects) do
  55. local z = obj.getRotation().z
  56. if obj.tag == 'Deck' then
  57.  
  58. local deck = obj.getObjects()
  59. cards = countTable(deck) + cards
  60. for key2, deckCard in pairs(deck) do
  61.  
  62. local addValue = Counts[deckCard.nickname]
  63. if addValue == nil then
  64. addValue = 0
  65. end
  66.  
  67. if deckCard.nickname == 'Ace' then
  68. aces = aces + 1
  69. end
  70. count = count + addValue
  71. end
  72.  
  73. else
  74. if Counts[obj.getName()] and (z > 345 or z < 15) then
  75. count = Counts[obj.getName()] + count
  76. if obj.getName() == 'Ace' then
  77. aces = aces + 1
  78. end
  79. end
  80. if obj.tag == 'Card' then
  81. cards = 1 + cards
  82. end
  83. end
  84.  
  85. end
  86.  
  87. if aces ~= 0 then
  88. local testCount = count+10
  89. if testCount == 21 then count = 21 end
  90. end
  91.  
  92. self.setValue(count)
  93. if count == 21 and cards <= 2 then
  94. self.setColorTint( {0.2, 1, 0.5} ) --Blackjack, turns Yellow
  95. elseif count == 21 and cards > 2 then
  96. self.setColorTint( {1, 1, 0} ) --21 turns green
  97. elseif count > 21 then
  98. self.setColorTint( {1, 0, 0} ) --Bust color red
  99. else
  100. self.setColorTint( {0, 0, 0} ) --regular color
  101. end
  102. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement