SHARE
TWEET

ComputerCraft Tutorial: modify_editcmd0_1

hevohevo Jan 19th, 2014 173 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- ##########################
  2. -- modify_editcmd
  3. -- version 0.1
  4. -- http://hevohevo.hatenablog.com/
  5. -- This program modifies "/rom/programs/edit"
  6. -- to convert acces menu key (ctrl_key) into alt_key.
  7.  
  8. input_file = "/rom/programs/edit"
  9. output_file = "edit2"
  10.  
  11. trans = {}
  12. trans['local sStatus = "Press Ctrl to access menu"'] = 'local sStatus = "Press Alt to access menu"'
  13. trans['         elseif param == keys.leftCtrl or param == keys.rightCtrl then'] = '             elseif param == keys.leftAlt or param == keys.rightAlt then'
  14.  
  15. if fs.exists(output_file) then
  16.   print("Error: output file exists")
  17. else
  18.   print("input file: ",input_file)  
  19.   local tmp = {}
  20.   for line in io.lines(input_file) do
  21.     table.insert(tmp,(trans[line] or line))
  22.   end
  23.  
  24.   local fh = fs.open(output_file,"w")
  25.   for _,l in ipairs(tmp) do
  26.     fh.writeLine(l)
  27.   end
  28.   fh.close()
  29.  
  30.   print("output file: ",output_file)  
  31. end
RAW Paste Data
Top