Advertisement
gravitowl

[gravicard] newCard

Jan 8th, 2021 (edited)
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. local modem = peripheral.wrap("left")
  2. local diskDrive = peripheral.wrap("right")
  3. modem.open(420)
  4.  
  5. function getName()
  6. shell.execute("clear")
  7. print("Name of new card user:")
  8. local name = read()
  9. print("Checking if card name already exists...")
  10. modem.transmit(420, 420, name)
  11. local _, side, freq, rfreq, message = os.pullEvent('modem_message')
  12. if message[1] == "Found" then
  13. print("Card already exists, please use a different name. Stopping program.")
  14. print("Current balance: "..message[2])
  15. diskDrive.setDiskLabel(name.." $"..message[2].." - GraviCard")
  16. sleep(2)
  17. return
  18. elseif message[1] == "Not Found" then
  19. print("Card created.")
  20. print("Name: "..name.." Current balance: 0")
  21. diskDrive.setDiskLabel(name.." $"..message[2].." - GraviCard")
  22. sleep(2)
  23. end
  24. end
  25.  
  26. shell.execute("clear")
  27. print("Welcome to the GraviCard card setup!")
  28. sleep(2)
  29. if diskDrive.isDiskPresent() then
  30. getName()
  31. else
  32. print("Please insert a disk in the disk drive.")
  33. sleep(2)
  34. end
  35. shell.execute("clear")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement