Advertisement
freacknate09

hexedit.lua

Jan 13th, 2021
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. local term = require("term")
  2. local component = require("component")
  3. local shell = require("shell")
  4. local fs = require("filesystem")
  5. local drive = component.drive
  6. local offset = 1
  7. local data = {}
  8. local filename = ""
  9. local length = 0
  10.  
  11. local args = shell.parse(...)
  12.  
  13. filename = args[1]
  14. length = drive.getCapacity()
  15.  
  16. local function displayBytes()
  17.   length = drive.getCapacity()
  18.   repeat
  19.     data = drive.readByte(offset)
  20.     offset = offset + 1
  21.     term.write(string.format("%02x",math.abs(data)))
  22.     local cursorX, cursorY = term.getCursor()
  23.     term.setCursor(cursorX + 1, cursorY)
  24.   until string.byte(data)  == 48
  25. end
  26.  
  27. displayBytes()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement