28 posts
Location
Spain
Posted 17 March 2014 - 02:46 PM
Hello, I have a script (main.lua) and I want, when executed, to copy that script to a file in rom memory. And later run the script (the script that is in rom)
for example, when I get a script with "pastebin get …."
That will be for restart-resistant programs
PD: For turtles please
Edited on 17 March 2014 - 01:47 PM
1281 posts
Posted 17 March 2014 - 02:51 PM
Are you by any chance mistaking ram and rom? You do not have write acess to the read only memory, it's where the default computer files are stored, as in the folder /rom. Ram on the other hand, would just be the variables and such loaded on the computer. Meaning you could load your program into ram(execute it) on startup, if you want to. If you really want to put files in /rom, you'll have to do so externally, as in on your actual computer.
116 posts
Location
France
Posted 17 March 2014 - 04:36 PM
If you're talking about RAM, just do this :
file = fs.open("yourprogram", "r")
myProg = file.readAll()
file.close()
And then to run it :
loadstring(myProg)
Of course, you can't reboot the computer, else you'll have to run the first code back.
EDIT : Wow, I think I missed something.
If you want something which is loaded on the startup, just rename the program "startup".
Edited on 17 March 2014 - 03:45 PM
1610 posts
Posted 17 March 2014 - 05:47 PM
You can't edit ROM from a script. Period.
If you mean just save a file on the computer, you can take a look at the fs API.