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

Is It Possible To Import Programs From The Host Computer's File System?

Started by blockly, 17 October 2013 - 06:24 PM
blockly #1
Posted 17 October 2013 - 08:24 PM
I am building a tool outside of Minecraft to create Lua programs, which I would like the user to be able to run in game. I know of two ways of getting the program into the game:
  1. Having the user copy and paste it.
  2. Saving it onto pastebin, then using the pastebin command to import it into the game.
Are there any other ways to get Lua programs into the game? I'd like to be able to store the programs on the file system of the host computer (e.g., Mac, PC, etc.) and import them into the game through ComputerCraft. Is that possible or an addition I could make without access to the ComputerCraft source?

Thanks.
Lyqyd #2
Posted 17 October 2013 - 08:27 PM
You can add resource packs to the server with additional programs.
immibis #3
Posted 17 October 2013 - 09:07 PM
You can also save the programs to .minecraft/saves/<save name>/computer/<computer ID>.
They will only be accessible to one computer. However, this way doesn't require the user to restart Minecraft with every change.
ElvishJerricco #4
Posted 18 October 2013 - 04:09 PM
You can also save the programs to .minecraft/saves/<save name>/computer/<computer ID>.
They will only be accessible to one computer. However, this way doesn't require the user to restart Minecraft with every change.

If the resource pack is in a folder instead of a zip you shouldn't need restarts.
mark332 #5
Posted 18 October 2013 - 05:42 PM
You may save them in your /rom directory, too
blockly #6
Posted 21 October 2013 - 08:14 PM
Thanks a lot for all of the great suggestions!
theoriginalbit #7
Posted 21 October 2013 - 08:25 PM
It should also be mentioned, in addition to the way immibis stated you could have a location on the file system that you store them, and then create a Symlink to that location in each of those computers, I'm not too sure if it works with older versions but Symlinks definitely work with the latest version of ComputerCraft. By using a Symlink it means that you can have the files in one location for easy editing and have all computers be able to access the files. Also when an edit is made to the file each computer would obviously get the update, however be aware that any computers running the program wouldn't show the changes until they restarted it.

It should be quite easy in your tool to scan each of the well known Minecraft instances folders for the `saves/computers` folder and setup a listener to the `nextid` file, that way each time a new computer is added you could automatically generate its folder and create the symlink too. (assuming your tool would be running at the same time as people are adding computers/turtles in Minecraft)

You may save them in your /rom directory, too
Doesn't work on the new versions however that require resource packs.