Advertisement
Guest User

Untitled

a guest
May 5th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. --Initialize counter to number of players at table
  2. function onload()
  3.     if isOnCounter() == false then
  4.         return
  5.     end
  6.     if self.Counter.getValue() == nil or self.Counter.getValue() == 0 then
  7.        local total = getPlayerCount()
  8.        previousPlayerCount = total
  9.        self.Counter.setValue(total)
  10.     end
  11. end
  12.  
  13. --Increments the counter if a player sits down
  14. function onPlayerChangedColor()
  15.     if isOnCounter() == false then
  16.         return
  17.     end
  18.     local currentPlayerCount = getPlayerCount()
  19.     if currentPlayerCount > previousPlayerCount then
  20.         self.Counter.increment()
  21.     end
  22.     previousPlayerCount = currentPlayerCount
  23. end
  24.  
  25. --Returns number of players seated at the table
  26. function getPlayerCount()
  27.     local players = getSeatedPlayers()
  28.     local total = 0
  29.     if #players != nil then
  30.         total = #players
  31.     end
  32.     return total
  33. end
  34.  
  35. --Check if script is on a counter
  36. function isOnCounter()
  37.     if self.Counter == nil then
  38.         local color = {1, 0, 0}
  39.         printToAll("Error: This script needs to be placed on a Counter object. (" .. self.guid .. ")", color)
  40.         return false
  41.     end
  42.     return true
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement