CCHacker132

Wireless Bill Check

Jun 8th, 2021
883
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local args = {...}
  2. rednet.open('top')
  3. if not args[1] then
  4.     error('Input a bill UUID!')
  5. end
  6.  
  7. local uuid = args[1]
  8.  
  9. local dataSend={}
  10.  
  11. for len = 1,#uuid do
  12.     local char = string.byte(string.sub(uuid,len,len))*3
  13.     table.insert(dataSend,char)
  14. end
  15.  
  16. rednet.send(9,dataSend)
  17. local waitCount=0
  18. local isValid=nil
  19. repeat
  20.     local id,data = rednet.receive(3)
  21.     if id==9 then
  22.         isValid=data
  23.     end
  24. until waitCount > 10 or isValid~=nil
  25.  
  26. if waitCount>10 then
  27.     error('Connection Timed Out!')
  28. end
  29.  
  30. if tonumber(isValid) > 0 then
  31.     term.setTextColor(colors.green)
  32.     print('Bill is currently valid!')
  33.     term.setTextColor(colors.cyan)
  34.     print('Value: '..isValid)
  35.     print('')
  36.     sleep(2)
  37.     term.setTextColor(colors.orange)
  38.     print('Press any key to continue . . .')
  39.     os.pullEvent('key_up')
  40.     term.clear()
  41. else
  42.     term.setTextColor(colors.red)
  43.     print('Invalid bill!')
  44. end
RAW Paste Data