Jump to content




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



  • You cannot reply to this topic
6 replies to this topic

#1 FireHead996

  • Members
  • 14 posts
  • LocationPoland

Posted 07 July 2014 - 11:23 AM

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...

#2 Geforce Fan

  • Members
  • 846 posts
  • LocationMissouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension

Posted 07 July 2014 - 07:09 PM

View PostFireHead996, on 07 July 2014 - 11:23 AM, said:

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()

#3 Agoldfish

  • Members
  • 451 posts
  • LocationSome Fish Bowl in Ohio.

Posted 07 July 2014 - 07:18 PM

View PostGeforce Fan, on 07 July 2014 - 07:09 PM, said:

View PostFireHead996, on 07 July 2014 - 11:23 AM, said:

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.

#4 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 07 July 2014 - 07:46 PM

Not a bug, moved to Ask A Pro.

#5 FireHead996

  • Members
  • 14 posts
  • LocationPoland

Posted 07 July 2014 - 07:57 PM

View PostAgoldfish, on 07 July 2014 - 07:18 PM, said:

View PostGeforce Fan, on 07 July 2014 - 07:09 PM, said:

View PostFireHead996, on 07 July 2014 - 11:23 AM, said:

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.

#6 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 07 July 2014 - 11:21 PM

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.

#7 FireHead996

  • Members
  • 14 posts
  • LocationPoland

Posted 07 July 2014 - 11:57 PM

View PostBomb Bloke, on 07 July 2014 - 11:21 PM, said:

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 by FireHead996, 20 January 2015 - 11:13 PM.






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users