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

Ejecting without string 'side'

Started by EveryOS, 11 April 2016 - 03:21 PM
EveryOS #1
Posted 11 April 2016 - 05:21 PM
According to the wiki:
The wiki said:
disk.eject(string side)
Can I eject a disk without using a string? I wanna do something like this:
disk.eject(peripheral.find('disk')[1])
Edited on 11 April 2016 - 03:26 PM
Sewbacca #2
Posted 11 April 2016 - 05:26 PM
According to the wiki:
The wiki said:
disk.eject(string side)
Can I eject a disk without using a string? I wanna do something like this:

disk.e[color=#ff0000]b[/color]ject(peripheral.find('disk')[1])

No, you can't, but you can do this to eject all disks (even connected on the network) (untested):

for _, str in ipairs(peripheral.getNames) do
  if str:find('disk') == 1 then
    disk.eject(str)
  end
end
EveryOS #3
Posted 11 April 2016 - 05:28 PM
According to the wiki:
The wiki said:
disk.eject(string side)
Can I eject a disk without using a string? I wanna do something like this:
disk.eject(peripheral.find('disk')[1])

No, you can't, but you can do this to eject all disks (even connected on the network) (untested):

for _, str in ipairs(peripheral.getNames) do
  if str:find('disk') == 1 then
	disk.eject(str)
  end
end
But I just wanna eject one disk.
I'm surprised it happens to be you who replied, because it's for something I was making you.
Edited on 11 April 2016 - 03:29 PM
moTechPlz #4
Posted 11 April 2016 - 06:21 PM
Yes, you can do this;

local drive = peripheral.find( "drive" )
drive.ejectDisk( )

or this;

peripheral.find( "drive", function( _, drive ) drive.ejectDisk( ) end )
EveryOS #5
Posted 11 April 2016 - 07:07 PM
Yes, you can do this;

local drive = peripheral.find( "drive" )
drive.ejectDisk( )

or this;

peripheral.find( "drive", function( _, drive ) drive.ejectDisk( ) end )
THX
Sewbacca #6
Posted 11 April 2016 - 07:51 PM
I'm surprised it happens to be you who replied, because it's for something I was making you.

I just don't wanted to read a whlole novel. :D/>
Edited on 11 April 2016 - 05:51 PM