Advertisement
Guest User

Database API

a guest
Sep 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. --[[||
  2. Wow's database API
  3. This API need:
  4. -Rednet (Opened)
  5. ||]]
  6.  
  7. --[[
  8. Error codes:
  9. 0x0: no error
  10. 0x1: nil arg
  11. 0x2: not connected
  12. 0x3: Rednet not opened
  13. 0x4: Bad ID
  14. ]]
  15. local id = 0
  16. function findServerID()
  17. local id = rednet.lookup("HomePI", "main")
  18. return id
  19. end
  20.  
  21. local function send(sTable)
  22. if sTable == nil then return 0x1 end
  23. rednet.send(findServerID(), sTable)
  24. event, msg, id = rednet.receive()
  25. if id ~= findServerID() then return 0x4 end
  26. print("Succefuly")
  27. if msg == 0x0 then
  28. end
  29. end
  30.  
  31. function database(action, arg1, arg2, arg3, arg4, arg5)
  32. if action == "createUser" then
  33. if arg1 == nil or arg2 == nil or arg3 == nil or arg4 == nil or type(arg4) ~= "number" or type(arg1) ~= "string" or type(arg2) ~= "string" or type(arg3) ~= "string" then
  34. return 0x1
  35. else
  36. local TEMP_TABLE = {todo = action, Username = arg1, Password = arg2, Biolock = arg3, accesslevel == arg4}
  37. send(TEMP_TABLE)
  38. end
  39. end
  40. end
  41.  
  42. function setToken(token)
  43. if token == nil then return 0x1 end
  44.  
  45. end
  46.  
  47. function connect(token)
  48. if token == nil then return 0x1 end
  49.  
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement