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

read variables from a floppy

Started by Milso, 30 November 2012 - 10:38 AM
Milso #1
Posted 30 November 2012 - 11:38 AM
Im looking to use a program to display something on a monitor. The trick is i would like to have it read variables from a file on the floppy so i can easly change out the display as needed.


Side = "back"
mon = peripheral.wrap(Side)
mon.clear()
mon.setTextScale(5)
mon.setCursorPos(3,1)
mon.write("Teleporter")
mon.setCursorPos(6,2)
mon.write("Hub 1")

What i would like to do is read variables from a floppy for both the msg and to position.
Kingdaro #2
Posted 30 November 2012 - 12:04 PM
I'd say a good way to go about this is to have drawing operations stored on your disks, so you wouldn't be limited with just variables, and you could basically write/print/draw anything you need.

This could be the file called "data" on your disk, for example.

mon.setTextScale(5)
mon.setCursorPos(3,1)
mon.write("Teleporter")
mon.setCursorPos(6,2)
mon.write("Hub 1")

Then you could have your computer dofile() the data file.

Side = "back"
mon = peripheral.wrap(Side)
mon.clear()
dofile("disk/data")

There's probably a better way of doing this though, so someone else can step up if they please. :)/>
Milso #3
Posted 01 December 2012 - 09:02 AM
so

dofile("disk/data")
Will acttualy run the program on the disk inside the other program?

Thanks i think that was exactly what i was looking for ill give it a try tonight
darkrising #4
Posted 01 December 2012 - 11:20 AM
dofile is an easy way to do it, but you can use the textutils api to serialize and then save a table to the disk, that way you could import it into just a table instead of having variables here there and everywhere :)/>