kd2bwzgen

TDLViewer

Apr 10th, 2016
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. local tArgs = { ... }
  2. if #tArgs ~= 1 then
  3. printError("Usage: "..shell.getRunningProgram().." <tdl file>")
  4. end
  5. local todolist = tArgs[1]
  6. local f = fs.open(todolist,"r")
  7. local tdl = textutils.unserialize(f.readAll())
  8. f.close()
  9. if not tdl then error("TDL file is empty!") end
  10. local bn = 0
  11. local function convert(num)
  12. return tostring(math.floor(num*100))
  13. end
  14. local function pad(num)
  15. local str = convert(num)
  16. local ret = ""
  17. local len = str:len()
  18. ret = string.rep(" ",3-len) .. str
  19. return ret
  20. end
  21. term.clear()
  22. term.setCursorPos(1,1)
  23. print("TDLViewer 0.2")
  24. print("-------------")
  25. for _,i in pairs(tdl) do
  26. if type(i[2]) == "number" then
  27. local str = pad(i[2])
  28. print(str .. " " .. i[1])
  29. else
  30. print(" - "..i[1])
  31. for _,t in pairs(i[2]) do
  32. local str = pad(t[2])
  33. print("|"..str.." "..t[1])
  34. end
  35. end
  36. end
Advertisement
Add Comment
Please, Sign In to add comment