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

Disk Label Gate

Started by Nick0157, 25 June 2013 - 12:59 PM
Nick0157 #1
Posted 25 June 2013 - 02:59 PM
This is my first ever program, so no hate please.

This is a fairly simple program, that waits until a disk is inserted into a drive. When it is, it checks the label. If the label is "pass", a redstone signal is output, which can be set to do anything. If not, it is ejected and nothing else happens.



local side = "right" --change "right" to the side you want
local pass = "pass" -- change "pass" to the label of your disk
local output = "back" --change what side redstone output goes
local time = 5  -- change how long redstone output lasts

--Don't edit past here --

local label = disk.getLabel
local redstone = redstone.setOutput

print("Waiting for a disk...")

while true do
local _, side = os.pullEvent("disk")
  if label(side) == pass then
    print("Valid")
    disk.eject(side)
    redstone(output, false)
    redstone(output, true)
    sleep(time)
    redstone(output, false)
    os.reboot()
  else
    print("Invalid")
    disk.eject(side)
    os.reboot()
  end
end

You can download it directly to your in-game computer, by typing:

pastebin get WMSqjGEA <filename>

Hope this can help some of you. Its a simple program, but I'm proud, as its my first working one!

Nick! :)/>
svdragster #2
Posted 25 June 2013 - 03:04 PM
Oh nice, not like the other locks I have seen!
ScruffyRules #3
Posted 26 June 2013 - 07:27 AM
I was going to make one of these but i had lots of other things to do. Also does redstone go though disk drives?
Nick0157 #4
Posted 26 June 2013 - 11:38 AM
I noticed that this part isn't clear, so here is the explanation:

Local side is this side of the computer that the disk drive is
Local output is the side of the computer that the redstone output will come out from

Just to clear that up! XD