This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
nearlyp's profile picture

editing programs in CC

Started by nearlyp, 18 November 2015 - 10:38 PM
nearlyp #1
Posted 18 November 2015 - 11:38 PM
Hi everyone

I'm super new to ComputerCraft (got it working yesterday) and have been struggling with finding up to date information on how to handle programs. The tutorial I was originally following was written before the change to resource packs and as far as I can tell, the current implementation seems to be different from how a lot of threads discuss it (read: complain).

To get to my question: when I "edit filename", it seems to only be creating a blank file in-game. Is this how it's supposed to work? I can only seem to see the code for individual programs I've created/edited in-game and not anything that comes preloaded (or that I've added via the resourcepack folder). It seems strange that I shouldn't be able to edit or even view my code without having to completely rewrite in MC from scratch, and from everything I've read, it doesn't sound like this is actually the case. The beginner's tutorial (computer basics II), for example, talks about using edit to see what a given program looks like. Am I doing the command wrong? Did I possibly install something incorrectly? Is there something I need to turn on or off?

Any help would be appreciated.
Lyqyd #2
Posted 19 November 2015 - 12:03 AM
The edit program's argument will open files in the current directory or via absolute paths. Try using `edit /rom/programs/edit` or similar to view the built-in programs.
nearlyp #3
Posted 19 November 2015 - 03:11 AM
Thank you, I must have missed that step in the tuturial. It definitely helped and definitely let me see the code, but still no editing. The only option control gives me at that point is to exit.
Bomb Bloke #4
Posted 19 November 2015 - 04:09 AM
ROM stands for Read Only Memory - anything in the "rom" folder hence cannot be modified, and so the edit script won't give you the option to save over files stored there.

If you wanted to copy a script from ROM to the computer's own drive, you'd use cp:

cp <source> <destination>

Eg:

cp /rom/programs/edit /edit

You can then alter and save over the new copy.
Edited on 19 November 2015 - 03:09 AM
nearlyp #5
Posted 19 November 2015 - 04:54 AM
Aha. Thank you both so much. That makes a lot more sense. So is there a way to load programs outside of ROM with a different subfolder in the resourcespack folder maybe (/lua/edit rather than /lua/rom) or is the best option for tinkering to make a copy and then just update the file in a text editor once I know I have the program sorted out?
Bomb Bloke #6
Posted 19 November 2015 - 05:39 AM
Resource packs can only target the rom folder, so it's not possible to have one computer alter the files that're available to all other computers.
MKlegoman357 #7
Posted 19 November 2015 - 05:49 AM
Are you looking for a way to edit your files with an external editor, like Notepad++? If so then you could get the computer's ID by running 'id' in the terminal. Then navigate to <minecraft>/saves/<your world>/computer/<your computer's id> and you'll find your files there.
nearlyp #8
Posted 20 November 2015 - 04:42 PM
Thanks a ton everyone. These answers all address my questions and are a big hep for getting started.
Lyqyd #9
Posted 20 November 2015 - 05:36 PM
Resource packs can only target the rom folder, so it's not possible to have one computer alter the files that're available to all other computers.

Interesting! I haven't played with them much, but I was under the impression that resource packs could add files anywhere, and replace files in /rom. I didn't know that they were restricted to only add or replace files in /rom.
Lupus590 #10
Posted 20 November 2015 - 05:56 PM
Resource packs can only target the rom folder, so it's not possible to have one computer alter the files that're available to all other computers.

Interesting! I haven't played with them much, but I was under the impression that resource packs could add files anywhere, and replace files in /rom. I didn't know that they were restricted to only add or replace files in /rom.

They can do treasure disks too, if you want a file on every computer then it has to go in rom
Edited on 21 November 2015 - 05:25 PM
Bomb Bloke #11
Posted 21 November 2015 - 04:51 AM
Interesting! I haven't played with them much, but I was under the impression that resource packs could add files anywhere, and replace files in /rom. I didn't know that they were restricted to only add or replace files in /rom.

Er, well, to be honest - I haven't actually tried putting them in other locations, I've just been taking Dan's word for it.

The most interesting features are often undocumented, however. It wouldn't surprise me all that much if you could target, say, bios.lua. Still, I can't envision that they could be used to generate anything but read-only files / folders, no matter where you end up putting them.
Lyqyd #12
Posted 21 November 2015 - 05:49 PM
Well, I do know for certain that bios.lua cannot be replaced via resource pack. But I would have thought we could add new folders at the same level as /rom with them. Maybe I'll experiment with it sometime.