Posted 23 April 2014 - 06:53 PM
The object is I'm making a universal function that do file writing, copy, and moving. I want the function to be able to take the program you want to transfer as a parameter and input that into the string that it write to the file.
For example this is my current code.
The Object is that when I were to pass in a program name(lets say "build"). I want it where when it writes to the disk by the end the disk is reading.
But when its done it reads.
I understand why it does that looking back and forth. Would I do a string.gsub to replace the text in the string with the one I want to be in there.
Something like
I would do some variable changes to make it easier to read.
For example this is my current code.
function transfer(type)
fs.copy(type, "disk/"..type.."Prog")
file = fs.open("disk/startup", "w")
file.writeLine("fs.move(\"disk/\""..type.."\"Prog\","..type..")")
file.writeLine("shell.run(\"receive \""..type..")")
file.close()
end
The Object is that when I were to pass in a program name(lets say "build"). I want it where when it writes to the disk by the end the disk is reading.
fs.move("disk/buildProg", "build")
But when its done it reads.
fs.move("disk/"build"Prog", build)
I understand why it does that looking back and forth. Would I do a string.gsub to replace the text in the string with the one I want to be in there.
Something like
string.gsub("fs.move(\"disk/type/Prog\", \"type\")", "type", type)
I would do some variable changes to make it easier to read.
Edited on 23 April 2014 - 04:53 PM