Advertisement
Marlingaming

Standard Digital Items Client Program

Sep 14th, 2021
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. --this is a standardized program for all Computer units that require the use of Digital items
  2. local tArg = {...}
  3. local HostName = tArg[3]
  4. local Mode = tArg[2]
  5. local Item = tArg[1]
  6.  
  7.  
  8. function Interact()
  9. local Modem = peripheral.find("Modem")
  10. rednet.open()
  11. local id = rednet.lookup(6700,"AP_IT_Storage")
  12. local Serverid = id
  13. if mode == "Request" then
  14. rednet.send(Serverid,"Request",6700)
  15. repeat
  16. local id, message = rednet.receive()
  17. until id == Serverid and message == "Send"
  18. rednet.send(Serverid,Item,6700)
  19. repeat
  20. local id, message = rednet.receive()
  21. until id == Serverid
  22. local file = fs.open("StoredItems","a")
  23. local i = 0
  24. while file.readLine()
  25. i = i+1
  26. end
  27. file.setCursorPos(1,i)
  28. file.writeLine(message)
  29. file.close()
  30. elseif Mode == "Send" then
  31. rednet.send(Serverid,"Send",6700)
  32. repeat
  33. local id, message = rednet.receive()
  34. until id == Serverid and message == "Send"
  35. rednet.send(Serverid,Item,6700)
  36. end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement