Aadvert

booltobin

Feb 12th, 2012
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.44 KB | None | 0 0
  1.  
  2.  
  3. function convertBool(...)
  4.     local sConverted = ""
  5.     for i, v in ipairs(arg) do
  6.         if type(v) ~= "boolean" then
  7.             error("convertBool: All arguments must be boolean!")
  8.         end
  9.         sConverted = sConverted .. (v and "1" or "0")
  10.     end
  11.     return sConverted
  12. end
  13.  
  14.  
  15. local table = {}
  16. table["1010"] = "Hello, world!"
  17. local a, b, c, d = true, false, true, false
  18. local converted = convertBool(a, b, c, d)
  19. print(converted)
  20.  
  21. print(table[converted])
Advertisement
Add Comment
Please, Sign In to add comment