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

[1.4] File extensions

Started by ComputerCraftFan11, 01 April 2012 - 07:15 PM
ComputerCraftFan11 #1
Posted 01 April 2012 - 09:15 PM
In 1.4, there should be file extensions. For example, leaving a file without a extension or having .lua at the end will make it a lua program. A .txt will be read/edited when ran, and also have the options for users to create their own.

Examples:

.lua/blank = lua program
.txt = text file
.java/class = java program (Minecraft in minecraft with java in java?)
.img/any image extension = images (limited to 16x16?)
etc….
grinchfox #2
Posted 01 April 2012 - 09:57 PM
All but .java is possible, you can just make it in your own shell. Runing custom java classes on server is kinda bad for security, but good for perfomance (instead of using lua under java :)/>/> )
ComputerCraftFan11 #3
Posted 01 April 2012 - 10:08 PM
All but .java is possible, you can just make it in your own shell. Runing custom java classes on server is kinda bad for security, but good for perfomance (instead of using lua under java :)/>/> )

I'm making a peripheral called jBox with java.
Hawk777 #4
Posted 02 April 2012 - 05:29 AM
Having the default shell recognize files ending with “.lua” without having to type that extension to run them would be really nice (having “os.loadAPI” recognize the same would be even nicer). The advantage of having the file extension is that a lot of (external to CC) text editors do syntax highlighting based on the extension; without any extension, as it is right now, one has to set the filetype for each file manually, which is annoying.

(Edit) Notably, though, I just discovered Lua ignores the first line of a source file if it starts with the # character, which means vim anyway can do automatic syntax highlighting just by writing “#!/usr/bin/lua” on the first line of the file. Mileage will vary with other editors, obviously.
Edited on 02 April 2012 - 03:34 AM
Ian-Moone #5
Posted 02 April 2012 - 12:32 PM
isn't there an api for this

edit: found it http://www.computercraft.info/forums2/index.php?/topic/784-file-extension-mod/