Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Initialize counter to number of players at table
- function onload()
- if isOnCounter() == false then
- return
- end
- if self.Counter.getValue() == nil or self.Counter.getValue() == 0 then
- local total = getPlayerCount()
- previousPlayerCount = total
- self.Counter.setValue(total)
- end
- end
- --Increments the counter if a player sits down
- function onPlayerChangedColor()
- if isOnCounter() == false then
- return
- end
- local currentPlayerCount = getPlayerCount()
- if currentPlayerCount > previousPlayerCount then
- self.Counter.increment()
- end
- previousPlayerCount = currentPlayerCount
- end
- --Returns number of players seated at the table
- function getPlayerCount()
- local players = getSeatedPlayers()
- local total = 0
- if #players != nil then
- total = #players
- end
- return total
- end
- --Check if script is on a counter
- function isOnCounter()
- if self.Counter == nil then
- local color = {1, 0, 0}
- printToAll("Error: This script needs to be placed on a Counter object. (" .. self.guid .. ")", color)
- return false
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement