Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local charset = {} do -- [0-9a-zA-Z]
- for c = 48, 57 do table.insert(charset, string.char(c)) end
- for c = 65, 90 do table.insert(charset, string.char(c)) end
- for c = 97, 122 do table.insert(charset, string.char(c)) end
- end
- local function randomString(length)
- if not length or length <= 0 then return '' end
- math.randomseed(os.clock()^5)
- return randomString(length - 1) .. charset[math.random(1, #charset)]
- end
- write("Ready to receive disk...")
- while true do
- turtle.suck()
- item = turtle.getItemDetail(1)
- if not item or item.name ~= "computercraft:disk" then
- turtle.drop()
- else
- turtle.dropDown()
- write("\nEnter Owner's Name: ")
- owner = read()
- diskId = disk.getID("bottom")
- diskKey = randomString(5)
- slotId = 0
- file = fs.open("slot/index", "r")
- if file then
- slotId = file.read()
- file.close()
- end
- file = fs.open("slot/index", "w")
- file.write(slotId + 1)
- file.close()
- --Write Key to Floppy
- file = fs.open("disk/keycard", "w")
- file.write(diskKey)
- file.close()
- file = fs.open("disk/slot", "w")
- file.write(slotId)
- file.close()
- --Write Key to Server
- file = fs.open("slot/"..slotId, "w")
- file.write(diskKey)
- disk.setLabel("bottom", owner.."'s Slot Key")
- write("Key Created, DiskID: "..diskId)
- disk.eject("bottom")
- os.sleep(5)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement