Posted 09 April 2020 - 01:33 AM
local sPrefix = "Class "
local sSufix = " Keycard"
local iLevelLength = 6
local sDiskSide = "right"
local tVarargs = {...}
local iLevel = tVarargs[1]
local sLevel = "4"
if (iLevel == "1") then sLevel = "E" end
if (iLevel == "2") then sLevel = "D" end
if (iLevel == "3") then sLevel = "C" end
if (iLevel == "4") then sLevel = "B" end
if (iLevel == "5") then sLevel = "A" end
local hMKey = fs.open("masterkey.lua", "r")
local hKey = fs.open("disk/key", "w")
local sMKey = hMKey.readAll()
local sWriteKey = string.sub(sMKey, 1, iLevel*iLevelLength)
disk.setLabel(sDiskSide, sPrefix .. sLevel .. sSufix)
hKey.write(sWriteKey)
hMKey.close()
hKey.close()