Jump to content




How to save a Lua program?



8 replies to this topic

#1 C_D_V

  • New Members
  • 1 posts

Posted 14 March 2017 - 01:45 AM

Sorry if this is a bad title.. I'm super new to CC. I'm playing Tekkit Classic. I made a program in the Lua console and I want to save it onto a disk. How would I do this?

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 14 March 2017 - 03:29 AM

Moved to Ask a Pro.

#3 D3matt

  • Members
  • 830 posts

Posted 14 March 2017 - 04:27 AM

In the lua console? Not in the edit program? I don't think there is a way to do that, at least not that I'm aware of. If you could figure out what variable stores the console's command history you could write that out to a file but I have no idea where to start with that.

If you mean the edit program, just save the file and then use "mv" to move it to /disk.

#4 The Higher Realm

  • Members
  • 23 posts
  • LocationUSA

Posted 14 March 2017 - 05:51 AM

Place a disk drive next to the computer and put a floppy disk in it. Turn on the computer and type
cp [filename] /disk/
it will make a copy of it on the disk. To take it off the disk do
cp /disk/[filename] /


#5 TheRockettek

  • Members
  • 547 posts
  • LocationRem is best girl

Posted 14 March 2017 - 07:50 AM

the simplist way to do it is via the edit command in the shell which can be run by doing
edit <path/to/program>
However if you really want to use lua console look at the http://www.computerc...fo/wiki/Fs.open wiki page
fFile = fs.open("hello","a")
fFile.writeLine("I am writing text to this file")
fFile.close()

Edited by TheRockettek, 14 March 2017 - 04:23 PM.


#6 Lupus590

  • Members
  • 2,029 posts
  • LocationUK

Posted 14 March 2017 - 11:06 AM

(reiterating what others have said but clearer)
The lua console doesn't have a save option as that's not its job, there is no easy way to export or save what has been written in the lua console. You should use the edit program for writing programs.
To use edit you need to give it a file name (the file doesn't have to exist yet). Example: edit exampleFile will create a file called example and open it in the edit program.
You can then write your program like with any text editor in real life. A menu can be opened with the ctrl key, you can the use the arrow keys and return to select save or exit, if you are using an advanced computer you may also have an option to run your code.
remember to save before you exit, edit will not remind you if you forget and you will lose your code.
Your new program can be run with the name you gave it (my example was exampleFile )
you can copy your code onto a disk with the copy command which has the 'nickname' cp Actiquack322 explained this quite well.

View PostActiquack322, on 14 March 2017 - 05:51 AM, said:

Place a disk drive next to the computer and put a floppy disk in it. Turn on the computer and type
cp [filename] /disk/
it will make a copy of it on the disk. To take it off the disk do
cp /disk/[filename] /


#7 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 14 March 2017 - 01:26 PM

If you've really written it to the lua console, just write that line out to a file. Put this in front:

handle = io.open("filename", "w"); handle:write([=[

and this behind your existing line in the lua prompt:

]=].."\n"); handle:close()


#8 andrew65952

  • New Members
  • 2 posts

Posted 05 April 2017 - 12:33 PM

View PostLupus590, on 14 March 2017 - 11:06 AM, said:

(reiterating what others have said but clearer)
The lua console doesn't have a save option as that's not its job, there is no easy way to export or save what has been written in the lua console. You should use the edit program for writing programs.

Just pointing out what TheRockettek said earlier...

View PostTheRockettek, on 14 March 2017 - 07:50 AM, said:

However if you really want to use lua console look at the http://www.computerc...fo/wiki/Fs.open wiki page
fFile = fs.open("hello","a")
fFile.writeLine("I am writing text to this file")
fFile.close()


#9 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 05 April 2017 - 01:31 PM

Rockettek said that later, not earlier. Notice the edit timestamp on his post. The part you quoted wasn't present in his initial post.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users