Razvii

CC replace program

Jul 1st, 2021 (edited)
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.58 KB | None | 0 0
  1. local yes = 21
  2. local no = 49
  3.  
  4. tArgs = {...}
  5.  
  6. fileName = tArgs[1]
  7.  
  8. pasteBinCode = tArgs[2]
  9.  
  10. local x, y = term.getCursorPos()
  11.  
  12. if (#tArgs == 2) then
  13. term.write("Are you sure you want to overwrite " .. fileName .. "? <y/n>")
  14. term.setCursorPos(1,(y+1))
  15. local event, key = os.pullEvent("key")
  16. while ((key ~= yes) and (key ~= no)) do
  17. local event, key = os.pullEvent("key")
  18. end
  19. if key == yes then
  20. shell.run("delete", fileName)
  21. shell.run("pastebin", "get", pasteBinCode, fileName)
  22. end
  23. else
  24. term.write("Usage: replace <File Name> <Pastebin Code>")
  25. term.setCursorPos(1,(y+1))
  26. end
Add Comment
Please, Sign In to add comment