←  Ask a Pro

ComputerCraft | Programmable Computers for Minecraft

»

File Reading?

anidude98's Photo anidude98 08 Feb 2012

I want to make a simple program that reads files inside a floppy.
It could be used for MANY things including money, locks, adventure maps, and a ton more!
But I haven't found any function that lets me read a file or set a variable as a line of a file. Anyone know what i could do?

I'm currently using labels for this with the disk api... Just to get a simple password type program going...

thanks for any help,
-anidude98
Quote

Espen's Photo Espen 09 Feb 2012

Some starting pointers:
In ComputerCraft type: help fs

Read about I/O in LUA:
http://www.lua.org/pil/21.1.html

You can use ComputerCraft's fs.open() instead of LUA's io.open(), but with the latter you can do things like io.read("*a").
Don't know if you can do the latter in same other way with fs.open() as well though. Only know how it works with LUA.

K, hope this sets you on the right path. Have fun exploring! :P/>
Quote

anidude98's Photo anidude98 09 Feb 2012

View PostEspen, on 09 February 2012 - 12:48 AM, said:

Some starting pointers:
In ComputerCraft type: help fs

Read about I/O in LUA:
http://www.lua.org/pil/21.1.html

You can use ComputerCraft's fs.open() instead of LUA's io.open(), but with the latter you can do things like io.read("*a").
Don't know if you can do the latter in same other way with fs.open() as well though. Only know how it works with LUA.

K, hope this sets you on the right path. Have fun exploring! :P/>

Actually i found this out on irc, Now im going to learn about hiding information so it cant be read without being decoded. then i can make a real money system for a server... connect all the computers on my server to one computer holding all data for all users... basically a bank program...
Quote

Selkitty's Photo Selkitty 09 Feb 2012

theres a lock program designed that already uses this idea, you should look into it to see how the person reads the file
You can probably get some good ideas as to how to string it together
http://www.computerc...-misc-programs/
Quote

anidude98's Photo anidude98 09 Feb 2012

View PostSelkitty, on 09 February 2012 - 06:36 AM, said:

theres a lock program designed that already uses this idea, you should look into it to see how the person reads the file
You can probably get some good ideas as to how to string it together
http://www.computerc...-misc-programs/

are you refering to the reading files from a disk?
or the encoding the files?
Quote

Selkitty's Photo Selkitty 10 Feb 2012

View Postanidude98, on 09 February 2012 - 06:30 PM, said:

View PostSelkitty, on 09 February 2012 - 06:36 AM, said:

theres a lock program designed that already uses this idea, you should look into it to see how the person reads the file
You can probably get some good ideas as to how to string it together
http://www.computerc...-misc-programs/

are you refering to the reading files from a disk?
or the encoding the files?

this program reads the files on the disk looking for a passcode.
Quote

jpzg's Photo jpzg 31 May 2013

View Postanidude98, on 09 February 2012 - 06:12 AM, said:

Actually i found this out on irc, Now im going to learn about hiding information so it cant be read without being decoded. then i can make a real money system for a server... connect all the computers on my server to one computer holding all data for all users... basically a bank program...
For encrypting information:
http://www.computerc...__fromsearch__1
Might be useful. Or:
http://www.computerc...__fromsearch__1
Which has AES and some others, as well as a Secure Rednet Tunnel api that might be good for sending data over rednet.
Quote

W00dyR's Photo W00dyR 31 May 2013

View Postjpzg, on 31 May 2013 - 03:35 PM, said:

Snap

Please look at the date of when this was posted. This is well over a year old ;)
Quote