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

[Tekkit Classic/v1.33][SSP/SMP]Error - nil: vm error: java.lang.NullPointerException

Started by FireHead996, 07 July 2014 - 10:23 AM
FireHead996 #1
Posted 07 July 2014 - 12:23 PM
Hi. When i run this code:

local pass = "pass"
local doorSide = "bottom"
local delay = 3

while true do
	event, driveSide = os.pullEventRaw
	if event == "disk" and driveSide then
		if disk.getMountPath(driveSide) then
			path = path.."/password"
			file = fs.exists(path) and io.open(path, "r") or nil
		end
		if file and file:read() == pass then
			rs.setOutput(doorSide, true)
			sleep(delay)
			rs.setOutput(doorSide, false)
		end
		disk.eject(driveSide)
		if file then
			file:close()
			file = nil
		end
	end
end
after several seconds error appears and computer's going off. I remember on another modpack this code worked well. I don't know what is wrong with it…
Geforce Fan #2
Posted 07 July 2014 - 08:09 PM
Hi. When i run this code:

local pass = "pass"
local doorSide = "bottom"
local delay = 3

while true do
	event, driveSide = os.pullEventRaw
	if event == "disk" and driveSide then
		if disk.getMountPath(driveSide) then
			path = path.."/password"
			file = fs.exists(path) and io.open(path, "r") or nil
		end
		if file and file:read() == pass then
			rs.setOutput(doorSide, true)
			sleep(delay)
			rs.setOutput(doorSide, false)
		end
		disk.eject(driveSide)
		if file then
			file:close()
			file = nil
		end
	end
end
after several seconds error appears and computer's going off. I remember on another modpack this code worked well. I don't know what is wrong with it…
os.pullEventRaw /= os.pullEventRaw()
Agoldfish #3
Posted 07 July 2014 - 08:18 PM
Hi. When i run this code:

local pass = "pass"
local doorSide = "bottom"
local delay = 3

while true do
	event, driveSide = os.pullEventRaw
	if event == "disk" and driveSide then
		if disk.getMountPath(driveSide) then
			path = path.."/password"
			file = fs.exists(path) and io.open(path, "r") or nil
		end
		if file and file:read() == pass then
			rs.setOutput(doorSide, true)
			sleep(delay)
			rs.setOutput(doorSide, false)
		end
		disk.eject(driveSide)
		if file then
			file:close()
			file = nil
		end
	end
end
after several seconds error appears and computer's going off. I remember on another modpack this code worked well. I don't know what is wrong with it…
os.pullEventRaw /= os.pullEventRaw()
In other words you forgot the parenthesis.
Cranium #4
Posted 07 July 2014 - 08:46 PM
Not a bug, moved to Ask A Pro.
FireHead996 #5
Posted 07 July 2014 - 08:57 PM
Hi. When i run this code:

local pass = "pass"
local doorSide = "bottom"
local delay = 3

while true do
	event, driveSide = os.pullEventRaw
	if event == "disk" and driveSide then
		if disk.getMountPath(driveSide) then
			path = path.."/password"
			file = fs.exists(path) and io.open(path, "r") or nil
		end
		if file and file:read() == pass then
			rs.setOutput(doorSide, true)
			sleep(delay)
			rs.setOutput(doorSide, false)
		end
		disk.eject(driveSide)
		if file then
			file:close()
			file = nil
		end
	end
end
after several seconds error appears and computer's going off. I remember on another modpack this code worked well. I don't know what is wrong with it…
os.pullEventRaw /= os.pullEventRaw()
In other words you forgot the parenthesis.
OK. This error is not showing, but now is another one:
startup:6: attempt to concatenate nil and string
I don't understand this. Both of vars (event and driveSide) are selfprinting good (as strings), but when i insert disc, error appears.
Bomb Bloke #6
Posted 08 July 2014 - 12:21 AM
You say the error points to line 6, but the only line on which you're concatenating is line 9. In any case, you're attempting to concatenate "path" with the string "/password"; but since "path" isn't already a string, it errors.

Seems you want to use disk.getMountPath(driveSide) there instead.
FireHead996 #7
Posted 08 July 2014 - 12:57 AM
You say the error points to line 6, but the only line on which you're concatenating is line 9. In any case, you're attempting to concatenate "path" with the string "/password"; but since "path" isn't already a string, it errors.

Seems you want to use disk.getMountPath(driveSide) there instead.
Ooo… That was my fault. I didn't used after first condition this:

path = disk.getMountPath(diskSide)
if(path) then
Now it works. :)/> Thanks for help.
Edited on 20 January 2015 - 10:13 PM