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…
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
[Tekkit Classic/v1.33][SSP/SMP]Error - nil: vm error: java.lang.NullPointerException
Started by FireHead996, 07 July 2014 - 10:23 AMPosted 07 July 2014 - 12:23 PM
Hi. When i run this code:
Posted 07 July 2014 - 08:09 PM
os.pullEventRaw /= os.pullEventRaw()Hi. When i run this code: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…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
Posted 07 July 2014 - 08:18 PM
In other words you forgot the parenthesis.os.pullEventRaw /= os.pullEventRaw()Hi. When i run this code: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…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
Posted 07 July 2014 - 08:46 PM
Not a bug, moved to Ask A Pro.
Posted 07 July 2014 - 08:57 PM
OK. This error is not showing, but now is another one:In other words you forgot the parenthesis.os.pullEventRaw /= os.pullEventRaw()Hi. When i run this code: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…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
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.
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.
Seems you want to use disk.getMountPath(driveSide) there instead.
Posted 08 July 2014 - 12:57 AM
Ooo… That was my fault. I didn't used after first condition this: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.
path = disk.getMountPath(diskSide)
if(path) then
Now it works. :)/> Thanks for help.Edited on 20 January 2015 - 10:13 PM