i can a little bit lua but not enough for this :D/>
i have bounded 2 disk drives with an cable modem,
the problem is, how can i read them for the disk.isPresent command over rednet ?
i try to learn and understand rednet but not so easy for me :D/>
if disk.isPresent("drive_0") then
--# do stuff
end
local file = fs.open("disk","r")
where disk can also be disk2 depending on the number of the disk.
term.clear()
drive1 = ("drive_0")-- Disk Drive 1
drive2 = ("drive_1")-- Disk Drive 2
disklabel = ("Securitycard")-- Disk Label Needed
Securitylp = ("Level 1 File")-- Security Level File Needed on Keycard
while true do
if (disk.isPresent(drive1) or (drive2)) then-- check if keycard in drive 1 or drive 2
current_disklabel = disk.getLabel("disk") or ("disk2")-- get disklabel from disk
if (current_disklabel == disklabel) then-- if disklabel = Needed disk Label
local file = fs.open("disk", "r")-- search for Security File
if file == Securitylp then-- when security file exist then give redstone signal
redstone.setOutput("bottom", true)
disk.eject("disk") --put Keycard out
sleep(10) --wait 10 seconds and set redstone signal 0
redstone.setOutput("bottom", false)
else (print("false"))-- restart computer or repeat the loop
else (print("false"))-- restart computer or repeat the loop
end
end
term.clear()
drive1 = "disk_0"-- Disk Drive 1
drive2 = "disk_1"-- Disk Drive 2
disklabel = "Securitycard" -- Disk Label Needed
Securitylp = "Level 1 File" -- Security Level File Needed on Keycard
currentDisk = ""
while true do
if (disk.isPresent(drive1) or disk.isPresent(drive2)) then-- check if keycard in drive 1 or drive 2
currentDisk = disk.isPresent(drive1) and "disk_1" or "disk_2"
current_disklabel = disk.getLabel(currentDisk)-- get disklabel from disk
if (current_disklabel == disklabel) then-- if disklabel = Needed disk Label
local file = fs.open(currentDisk.."/file", "r")-- search for Security File
if file.readAll() == Securitylp then-- when security file exist then give redstone signal
redstone.setOutput("bottom", true)
disk.eject("disk") --put Keycard out
sleep(10) --wait 10 seconds and set redstone signal 0
redstone.setOutput("bottom", false)
else (print("false"))-- restart computer or repeat the loop
else (print("false"))-- restart computer or repeat the loop
end
end
term.clear() --terminal clearen
local mon1 = peripheral.wrap("monitor_3")
local mon2 = peripheral.wrap("monitor_2")
pstop = ("left") --programm stop
disk1 = ("drive_0") --Laufwerk 1
disk2 = ("drive_1") --Laufwerk 2
door = ("bottom") --Tuer Ausgang
code = ("Securitycard") --KartenLabel
scode = ("/disk/Level_1_File") --Sicherheitsstufe 1
while not redstone.getInput(pstop) do
if disk.isPresent(disk1) == true then
mon1.clear()
if disk.getLabel(disk1) == code then
if fs.exists(scode) == true then
disk.eject(disk1)
redstone.setOutput("bottom", true)
sleep(10)
redstone.setOutput("bottom", false)
shell.run("reboot")
else
mon1.write("Nicht Authorisiert")
sleep(5)
shell.run("reboot")
end
else mon1.write("Fehlerhafte Sicherheitskarte")
sleep(5)
shell.run("reboot")
end
else
mon1.write("Keycard Einstecken")
end
if disk.isPresent(disk2) == true then
mon2.clear()
if disk.getLabel(disk2) == code then
print(file_exist2)
if fs.exists(scode) == true then
disk.eject(disk2)
redstone.setOutput("bottom", true)
sleep(10)
redstone.setOutput("bottom", false)
shell.run("reboot")
else
mon2.write("Nicht Authorisiert")
sleep(5)
shell.run("reboot")
end
else
mon2.write("Fehlerhafte Sicherheitskarte")
sleep(5)
shell.run("reboot")
end
else
mon2.write("Keycard Einstecken")
end
sleep(0.5)
end
while no redstone signal do
if there's a disk in the first drive then
if it's labeled as a keycard then
if the first mounted disk has a "Level_1_File" on it then
reboot!
else
reboot!
end
else
reboot!
end
else
Don't reboot!
end
-- Program can only reach this point if the computer hasn't rebooted already!
if there's a disk in the second drive then
mon2.clear()
if it's labeled as a keycard then
print(file_exist2)
if the first mounted disk (again) has a "Level_1_File" on it then
reboot!
else
reboot!
end
else
reboot!
end
else
Don't reboot!
end
end
while no redstone signal do
if there's a disk in the first drive then
if it's labeled as a keycard then
if the first mounted disk has a "Level_1_File" on it then
reboot!
else
reboot!
end
else
reboot!
end
else
Don't reboot!
end
-- Program can only reach this point if the computer hasn't rebooted already!
if there's a disk in the second drive then
mon2.clear()
if it's labeled as a keycard then
print(file_exist2)
if the first mounted disk (again) has a "Level_1_File" on it then
reboot! Reboot Yep
else
reboot! Reboot YEP
end
else
reboot! Reboot Yep
end
else
Don't reboot! Here is no Reboot
end
end