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

Set name of disk over network

Started by cmdpwnd, 06 March 2016 - 04:07 PM
cmdpwnd #1
Posted 06 March 2016 - 05:07 PM
anyone know how to set the name of a floppy disk when attached to a disk drive over the network?
doublequestionmark #2
Posted 06 March 2016 - 05:12 PM
this code requires computer b, the receiving computer, to have a drive on the left. and for both computers to have wireless modems on the top

btw, this is by no means secure

computer a:

rednet.open('top')
write('Label: ')
r = read()
rednet.broadcast(r) 

computer b:

rednet.open('top')
i, m = rednet.receive()
shell.run('label set left ' .. m)
cmdpwnd #3
Posted 06 March 2016 - 05:14 PM
so in short, you can't set it directly
Edited on 06 March 2016 - 04:14 PM
doublequestionmark #4
Posted 06 March 2016 - 05:23 PM
you MIGHT be able to set it directly using wired modems and just wrapping it as a peripheral.
sadly i dont have access to a mc installation rn so i cant test.

these wonderful pages on the wiki might be able to help:
http://www.computerc...wiki/Disk_(API)
http://www.computerc...eripheral_(API)
http://www.computerc...Peripheral_APIs

and here is some code that *MIGHT* work:


ModemID = 'disk_0'
d = peripheral.wrap(ModemID)
d.setLabel('ThisIsALabel')
Edited on 06 March 2016 - 04:24 PM
Bomb Bloke #5
Posted 06 March 2016 - 10:34 PM
When using the disk API, you'd simply do:

disk.setLabel("drive_0", "NewLabel")

If you wanted to wrap the drive as a peripheral, you'd do:

local drive = peripheral.wrap("drive_0")
drive.setDiskLabel("NewLabel")

DQM, please don't post code unless you know it works. If you have to wait to test it, then by all means wait - it's better than causing confusion by posting incorrect info.
Lupus590 #6
Posted 07 March 2016 - 11:47 AM
and here is some code that *MIGHT* work:
DQM, please don't post code unless you know it works. If you have to wait to test it, then by all means wait - it's better than causing confusion by posting incorrect info.

There is always the wiki to check that you are using an API correctly
Edited on 07 March 2016 - 10:47 AM