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

VM Error

Started by nateracecar5, 25 November 2013 - 06:41 PM
nateracecar5 #1
Posted 25 November 2013 - 07:41 PM
When I run this code:

term.clear()
term.setCursorPos(1,1)
write("Minecraft Name: ")
nameread = read()
print("Insert Ticket")
while not disk.isPresent("right") do
  local event, side = os.pullEvent("disk")
  break
end
if not fs.exists("/disk/.ticketnumber") then
  print("Non existant ticket! Tell Rail Manager error 102 (Blank ticket)")
  sleep(3)
  os.reboot()
elseif not fs.exists("/disk/.ticketnumber/.conf") then
  print("No confirmation key. Flagging player")
  if not fs.exists("/.flag") then
	flag = fs.open("/.flag","w")
	flag.close()
  end
  flag = fs.open("/.flag","w")
  flag.writeLine(nameread)
  flag.close()
  os.reboot()
elseif not fs.exists("/disk/.ticketnumber/.tn") then
  print("Non existant ticket! Tell Rail Manager error 102 (Blank ticket)")
  sleep(3)
  os.reboot()
end

local owner = disk.getLabel("right")
conf = fs.open("/disk/.ticketnumber/.conf","r")
conf1 = conf.readAll()
conf.close()
if conf1 == "Official Ticket" then
  tn = fs.open("/disk/.ticketnumber/.tn","r")
  ticketNum = tn.readAll()
  tn.close()
  if #ticketNum == 0 then
	print("Ticket number blank! Tell Rail Manager error 108 (No ticket number)")
	sleep(3)
	os.reboot()
  end
  if not fs.exists("/.used") then
	used = fs.open("/.used","w")
	used.close()
  end
  check = fs.open("/.used","r")
  test = check.readAll()
  check.close()
  if ticketNum:match(test) then --[[LINE 56 IS RIGHT HERE]]--
	print("Used ticket. Flagging player")
	if not fs.exists("/.flag") then
	  flag = fs.open("/.flag","w")
	  flag.close()
	end
	flag = fs.open("/.flag","w")
	flag.writeLine(nameread)
	flag.close()
	sleep(1)
	os.reboot()
  end
  check = fs.open("/.used","w")
  check.writeLine(test)
  check.close()
  rs.setOutput("bottom",true)
  sleep(5)
  rs.setOutput("bottom",false)
  os.reboot()
end

At line 56, I'm getting a invalid pattern capture. This didn't happen the first time I tried this, about a week ago, am I doing something wrong?

Please help.

EDIT: Never mind, my random string generator had symbols that were used as pattern codes, so it was thinking about patterns. Removed those symbols, problem solved.
Edited on 25 November 2013 - 07:18 PM
VaNnOrus #2
Posted 25 November 2013 - 11:30 PM

  if not fs.exists("/.flag") then
	    flag = fs.open("/.flag","w")
	    flag.close()
  end
  flag = fs.open("/.flag","w")
  flag.writeLine(nameread)
  flag.close()
Why do you doing the same thing twice? fs.open with "w" will create new file if it don't exists