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 endafter 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...
[Tekkit Classic/v1.33][SSP/SMP]Error - nil: vm error: java.lang.NullPointerException
Started by FireHead996, Jul 07 2014 11:23 AM
6 replies to this topic
#1
Posted 07 July 2014 - 11:23 AM
Hi. When i run this code:
#2
Posted 07 July 2014 - 07:09 PM
FireHead996, 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 endafter 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...
#3
Posted 07 July 2014 - 07:18 PM
Geforce Fan, on 07 July 2014 - 07:09 PM, said:
FireHead996, 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 endafter 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...
#4
Posted 07 July 2014 - 07:46 PM
Not a bug, moved to Ask A Pro.
#5
Posted 07 July 2014 - 07:57 PM
Agoldfish, on 07 July 2014 - 07:18 PM, said:
Geforce Fan, on 07 July 2014 - 07:09 PM, said:
FireHead996, 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 endafter 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...
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
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.
Seems you want to use disk.getMountPath(driveSide) there instead.
#7
Posted 07 July 2014 - 11:57 PM
Bomb 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.
Seems you want to use disk.getMountPath(driveSide) there instead.
path = disk.getMountPath(diskSide) if(path) thenNow it works.
Edited by FireHead996, 20 January 2015 - 11:13 PM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











