Advertisement
MjnMixael

Untitled

Sep 12th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 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(var)
  7.  
  8. copyfrom = ("data/" .. var)
  9. --ba.print(copyfrom .. "\n")
  10.  
  11. end
  12.  
  13. function cpyto(var)
  14.  
  15. copyto = ("data/" .. var)
  16. --ba.print(copyto .. "\n")
  17.  
  18. end
  19.  
  20. function cpyt(var)
  21.  
  22. tarname = var
  23. --ba.print(targname .. "\n")
  24.  
  25. end
  26.  
  27. function cpyd(var)
  28.  
  29. destname = var
  30. --ba.print(destname .. "\n")
  31.  
  32. end
  33.  
  34. function copy()
  35.  
  36. if (copyfrom == nil) then
  37. ba.print("Invalid variable 'copyfrom' in filecopy function...\n")
  38. end
  39. if (copyto == nil) then
  40. ba.print("Invalid variable 'copyto' in filecopy function...\n")
  41. end
  42. if (targname == nil) then
  43. ba.print("Invalid variable 'targname' in filecopy function...\n")
  44. end
  45. if (destname == nil) then
  46. ba.print("Invalid variable 'destname' in filecopy function...\n")
  47. end
  48. if ((copyfrom ~= nil) and (copyto ~= nil) and (targname ~= nil) and (destname ~= nil)) then
  49. local file = cf.openFile(targname, "r", copyfrom)
  50. local mstring = file:read("*a")
  51.  
  52. file:close()
  53.  
  54. file = cf.openFile(destname, "w+", copyto)
  55. file:write(mstring)
  56. file:close()
  57. else
  58. ba.print("Warning: One or more necessary variables for filecopy function were nil! Operation cancelled...\n")
  59. end
  60.  
  61. end
  62.  
  63. ]
  64. #end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement