Advertisement
jamawie

Decompiler

Jul 24th, 2016
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.63 KB | None | 0 0
  1. --Decompiler from JoJa Productions
  2.  
  3. x,y = term.getSize()
  4. percentage = 0
  5. notrunning = true
  6. newfile = ""
  7.  
  8. args = { ... }
  9.  
  10. function gui()
  11.     term.clear()
  12.     term.setCursorPos(1,1)
  13.     term.setTextColor(colors.cyan)
  14.     term.setBackgroundColor(colors.black)
  15.     term.setCursorPos((x-16)/2,1)
  16.     term.write("Jo")
  17.     term.setTextColor(colors.orange)
  18.     term.write("Ja")
  19.     term.setTextColor(colors.gray)
  20.     term.write(" Productions")
  21.  
  22.     term.setTextColor(colors.white)
  23.     if notrunning then
  24.         term.setCursorPos((x-20)/2,y-6)
  25.         term.write("Dateinamen eingeben:")
  26.         term.setCursorPos((x-20)/2,y-4)
  27.     else
  28.         term.setCursorPos(4, y-6)
  29.         term.setBackgroundColor(colors.green)
  30.         for i=0,percent do
  31.             term.write(" ")
  32.         end
  33.         term.setBackgroundColor(colors.red)
  34.         for i=percent,x-8 do
  35.             term.write(" ")
  36.         end
  37.     end
  38. end
  39.  
  40. function compile(pname)
  41.     file = fs.open(pname,"r")
  42.     lines = file.readAll()
  43.     linesarray = {}
  44.     lines:gsub(".",function(c) table.insert(linesarray,c) end)
  45.  
  46.     for i=1,#linesarray do
  47.         code = string.byte(linesarray[i])
  48.         char = string.char(code-12)
  49.         newfile = newfile..char
  50.     end
  51.     file.close()
  52.  
  53.     file = fs.open(string.sub(pname, 1, string.find(pname, ".joja")-1), "w")
  54.     file.write(newfile)
  55.     file.close()
  56. end
  57.  
  58. running = true
  59. while notrunning do
  60.     gui()
  61.     if #args ~= 1 then
  62.         pname = io.read()
  63.     else
  64.         pname = args[1]
  65.     end
  66.     if fs.exists(pname) and string.find(pname, ".joja") then
  67.         notrunning = false
  68.         compile(pname)
  69.     end
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement