Advertisement
freacknate09

hexedit.lua

Jan 14th, 2021
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 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", string.byte(data)))
  22.     term.write(" ")
  23.     -- term.write(offset)
  24.     local cursorX, cursorY = term.getCursor()
  25.     term.setCursor(cursorX + 2, cursorY)
  26.   until string.byte(data)  == 48
  27. end
  28.  
  29. displayBytes()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement