Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local explosiveCombinations = {
- --[[
- make a table of the cards that should explode with each other
- combinations only need to appear once for this to work but you can
- duplicate them if that makes it easier to manage.
- --]]
- {"Fire", "Water"},
- {"Fire", "Ice"},
- {"Fire", "Another Card Name"},
- }
- function isExplosive(name1, name2)
- --[[
- Simple function to loop through the table of explosiveCombinations and check for
- entries that match the card names provided
- --]]
- for _,card in ipairs(explosiveCombinations) do
- if (card[1]==name1 and card[2]==name2) or
- (card[1]==name2 and card[2]==name1) then
- return true
- end
- end
- return false
- end
- function compareCardsInZone(zoneGUID)
- --[[
- Loops through all the objects in a zone, finds the cards, and reads their names to look for
- any of the explosive compbinations declared above
- --]]
- --get a reference to the zone
- local zone = getObjectFromGUID(zoneGUID)
- --create a blank table to store found Card object references
- local cards = {}
- --loop through all the Objects in the zone and add any Cards found to the blank cards table we just created
- for _,obj in ipairs(zone.getObjects()) do
- if obj.tag == "Card" then
- table.insert(cards, obj)
- end
- end
- --abort if we don't find at least 2 Cards in the zone
- if #cards < 2 then return false end
- --loop through all the found Cards, checking if they're explosive with any of the other found Cards
- for i=1,#cards-1 do
- --pop the first Card from the table of found cards
- local card1 = table.remove(cards, 1)
- local card1Name = card1.getName()
- --loop through the other found Cards and check if they form an explosive combination
- for _,card2 in ipairs(cards) do
- local card2Name = card2.getName()
- if isExplosive(card1Name, card2Name) then
- print("The cards "..card1Name.." and "..card2Name.." are explosive!")
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement