Advertisement
MjnMixael

Untitled

Sep 23rd, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #Conditional Hooks
  2. $Application: FS2_Open
  3. $On Game Init: [
  4. --table for moving files around
  5.  
  6. function cpyfr(cpyfrpass)
  7.  
  8. copyfrom = ("data/" .. cpyfrpass)
  9.  
  10. end
  11.  
  12. function cpyto(cpytopass)
  13.  
  14. copyto = ("data/" .. cpytopass)
  15.  
  16. end
  17.  
  18. function cpyt(targname)
  19.  
  20. end
  21.  
  22. function cpyd(destname)
  23.  
  24. end
  25.  
  26. function copy()
  27.  
  28. if (copyfrom == nil) then
  29. ba.print("Invalid variable 'copyfrom' in filecopy function...\n")
  30. end
  31. if (copyto == nil) then
  32. ba.print("Invalid variable 'copyto' in filecopy function...\n")
  33. end
  34. if (targname == nil) then
  35. ba.print("Invalid variable 'targname' in filecopy function...\n")
  36. end
  37. if (destname == nil) then
  38. ba.print("Invalid variable 'destname' in filecopy function...\n")
  39. end
  40. if ((copyfrom ~= nil) and (copyto ~= nil) and (targname ~= nil) and (destname ~= nil)) then
  41. local file = cf.openFile(targname, "r", copyfrom)
  42. local mstring = file:read("*a")
  43.  
  44. file:close()
  45.  
  46. file = cf.openFile(destname, "w+", copyto)
  47. file:write(mstring)
  48. file:close()
  49. else
  50. ba.print("Warning: One or more necessary variables for filecopy function were nil! Operation cancelled...\n")
  51. end
  52.  
  53. end
  54.  
  55. ]
  56. #end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement