Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Card zone
- Zone = '7e2432'
- -- Zone Items
- ZoneItems = {}
- -- Item Counts
- Counts = {
- ['Ace'] = 1,
- ['Two'] = 2,
- ['Three'] = 3,
- ['Four'] = 4,
- ['Five'] = 5,
- ['Six'] = 6,
- ['Seven'] = 7,
- ['Eight'] = 8,
- ['Nine'] = 9,
- ['Ten'] = 10,
- ['Jack'] = 10,
- ['Queen'] = 10,
- ['King'] = 10
- }
- --Init Function
- function onLoad(save_state)
- --Load zone objects.
- Zone = getObjectFromGUID(Zone)
- PowerUpZone = getObjectFromGUID(PowerUpZone)
- --Update Count Timer
- Timer.create({
- ['identifier'] = Zone.getGUID(),
- ['function_name'] = 'updateCount',
- ['delay'] = 0.5,
- ['repetitions'] = 0,
- })
- end
- function countTable(table)
- local count = 0
- for _ in pairs(table) do count = count + 1 end
- return count
- end
- function updateCount()
- local count = 0
- local aces = 0
- local cards = 0
- local objects = Zone.getObjects()
- for key,obj in pairs(objects) do
- local z = obj.getRotation().z
- if obj.tag == 'Deck' then
- local deck = obj.getObjects()
- cards = countTable(deck) + cards
- for key2, deckCard in pairs(deck) do
- local addValue = Counts[deckCard.nickname]
- if addValue == nil then
- addValue = 0
- end
- if deckCard.nickname == 'Ace' then
- aces = aces + 1
- end
- count = count + addValue
- end
- else
- if Counts[obj.getName()] and (z > 345 or z < 15) then
- count = Counts[obj.getName()] + count
- if obj.getName() == 'Ace' then
- aces = aces + 1
- end
- end
- if obj.tag == 'Card' then
- cards = 1 + cards
- end
- end
- end
- if aces ~= 0 then
- local testCount = count+10
- if testCount == 21 then count = 21 end
- end
- self.setValue(count)
- if count == 21 and cards <= 2 and aces == 1 then
- self.setColorTint( {0.2, 1, 0.5} ) --Blackjack, turns Yellow
- elseif count == 21 and cards > 2 then
- self.setColorTint( {1, 1, 0} ) --21 turns green
- elseif count > 21 then
- self.setColorTint( {1, 0, 0} ) --Bust color red
- else
- self.setColorTint( {0, 0, 0} ) --regular color
- end
- end
Add Comment
Please, Sign In to add comment