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

disk:3: Expected string

Started by Astrophylite, 04 April 2016 - 08:22 AM
Astrophylite #1
Posted 04 April 2016 - 10:22 AM
Hello everyone!

I am getting the error "disk:3: Expected string" when attempting to run my program.
I have put debugging methods in and it says "Lock started!" and "Found the staff member!"

Here is the code:

local oldPull = os.pullEvent
os.pullEvent = os.pullEventRaw
local doorLoc = "left"
local sleepTime = 2
local staff = {"cookemoonster","Astrophylite"}
local staffMember = false
term.clear()
term.setCursorPos(1,1)
while true do
  print("Lock started!")
  if(disk.isPresent("top") and disk.hasData("top")) then
	for _,v in pairs(staff) do
	  if v == disk.getLabel("top") then
		print("Found the staff member!")
		staffMember = true	  
		break
	  end
	end
	if(staffMember) then
	  local file = io.open("/disk/hash","r")
	  local localHash = io.open("/users/"..disk.getLabel(),"r")
	  if(file:readLine() == localHash:readLine()) then
		print("The hash is correct!")
		rs.setOutput(doorLoc, true)
		sleep(sleepTime)
		rs.setOutput(doorLoc, false)
		disk.eject("top")
		print(disk.getLabel("top") .. " unlocked the door!")
	  else
		print(disk.getLabel("top") .. " didn't have a valid hash!")
		disk.eject("top")
	  end
	end
	sleep(0.5)
  else
	sleep(0.5)
  end
end

Any help will be appreciated,
Astrophylite.
SquidDev #2
Posted 04 April 2016 - 10:25 AM
This line:

local localHash = io.open("/users/"..disk.getLabel(),"r")
Is missing an argument for disk.getLabel(). Should probably read:

local localHash = io.open("/users/"..disk.getLabel("top"),"r")
Edited on 04 April 2016 - 08:26 AM
Astrophylite #3
Posted 04 April 2016 - 10:27 AM
OML - I changed all the others to disk.getLabel("top") and not that one ;-;

Thanks,
Astrophylite.