Hello everyone.
I just made this small script in computercraft:
running = true
Door = "nil"
while running == true do
Door = read()
if Door == "exit()" then
running = false
elseif Door == "1" then
serialData (1, 0, 0, 0)
end
function serialData (A, B, C, D)
redstone.setOutput ("bottom", true)
if A == 1 then
redstone.setOutput ("bottom", true)
else
redstone.setOutput ("bottom", false)
end
sleep (0.2)
if B == 1 then
redstone.setOutput ("bottom", true)
else
redstone.setOutput ("bottom", false)
end
sleep (0.2)
if C == 1 then
redstone.setOutput ("bottom", true)
else
redstone.setOutput ("bottom", false)
end
sleep (0.2)
if D == 1 then
redstone.setOutput ("bottom", true)
else
redstone.setOutput ("bottom", false)
end
sleep (0.2)
end
end
Every time I run it, I get the 'attempted to call nil' message after pressing '1' and therefore written '1' to Door.
Does anyone know what I've done wrong?
Hello everyone.
I just made this small script in computercraft:
running = true
Door = "nil"
while running == true do
Door = read()
if Door == "exit()" then
running = false
elseif Door == "1" then
serialData (1, 0, 0, 0)
end
function serialData (A, B, C, D)
redstone.setOutput ("bottom", true)
if A == 1 then
redstone.setOutput ("bottom", true)
else
redstone.setOutput ("bottom", false)
end
sleep (0.2)
if B == 1 then
redstone.setOutput ("bottom", true)
else
redstone.setOutput ("bottom", false)
end
sleep (0.2)
if C == 1 then
redstone.setOutput ("bottom", true)
else
redstone.setOutput ("bottom", false)
end
sleep (0.2)
if D == 1 then
redstone.setOutput ("bottom", true)
else
redstone.setOutput ("bottom", false)
end
sleep (0.2)
end
end
Every time I run it, I get the 'attempted to call nil' message after pressing '1' and therefore written '1' to Door.
Does anyone know what I've done wrong?
If you put anything before if you will get nil so you can't use elseif because it isn't running a argument it's trying to find the command elseif. Also you don't want to start with door = nil without it door won't be a variable until you type somthing in.
I recommend this
File name: startup
write("Password:")
password = read()
if password == "password" then
shell.run("unlock")
else
write("Incorrect Password!") sleep(2) os.shutdown()
end
File name: unlock
shell.run("clear")
redstone.setOutput("bottom", true)
print(" [1] exit")
option = read()
if option == "1" then
os.shutdown()
else write("Invalid option try again...") sleep(2) shell.run("unlock")
end
If you want somthing more you can download my Safety Deposit Box program and edit it. It's on the Computer Craft library topic on the 4th page
hi guys, I'm trying to make a regular password protected door with a redstone wire behind the computer and under a double reinforced stone door. this is how my code looks and it's probably sloppy but I'm very bad at cc. and I'm using it as a startup program.
however I get up startup:3: attempt to call nil, doesn't that mean that my third line dont exist ?
os.pullEvent = os.pullEventRaw
term.clear()
term.setcursorpos(1,1)
print ("Please enter password: ")
input = read("*")
if input == "TIC" then
print ("Welcome")
hi guys, I'm trying to make a regular password protected door with a redstone wire behind the computer and under a double reinforced stone door. this is how my code looks and it's probably sloppy but I'm very bad at cc. and I'm using it as a startup program.
however I get up startup:3: attempt to call nil, doesn't that mean that my third line dont exist ?
os.pullEvent = os.pullEventRaw
term.clear()
term.setcursorpos(1,1)
print ("Please enter password: ")
input = read("*")
if input == "TIC" then
print ("Welcome")
first u forgot a t on the rs.setoutput("back", false)
also you need to capitalize all the O's in the words Output
you also need to capitalize the C in cursor
while (true) do
sleep(0.25)
if (redstone.getInput("front") == true) then
print("Laser Firing..")
xTarget, yTarget, zTarget, ID, Meta, Resist = CL.getFirstHit()
if ( xTarget ~= -1) and (Resist ~= -1) then
xLaser, yLaser, zLaser = L.pos()
x = - xLaser + xTarget
y = - yLaser + yTarget
z = zLaser - zTarget
L.emitBeam(x,y,z)
sleep(3)
end
end
end
I just made this small script in computercraft:
Every time I run it, I get the 'attempted to call nil' message after pressing '1' and therefore written '1' to Door.
Does anyone know what I've done wrong?
I recommend this
File name: startup
File name: unlock
If you want somthing more you can download my Safety Deposit Box program and edit it. It's on the Computer Craft library topic on the 4th page
line 3: term.setcursorpos(1,1)
line 9: rs.setoutput("back", true)
line 11: rs.setoutpu("back", false)
should be:
term.setCursorPos(1,1)
rs.setOutput("back", true)
rs.setOutpu("back", false)
because its case sensitive
first u forgot a t on the rs.setoutput("back", false)
also you need to capitalize all the O's in the words Output
you also need to capitalize the C in cursor
if you need more help just write me!
CL = peripheral.wrap("left")
L = peripheral.wrap("right")
M = peripheral.wrap("top")
CL.freq(1420)
CL.camFreq(15)
L.freq(64000)
M.freq(15)
while (true) do
sleep(0.25)
if (redstone.getInput("front") == true) then
print("Laser Firing..")
xTarget, yTarget, zTarget, ID, Meta, Resist = CL.getFirstHit()
if ( xTarget ~= -1) and (Resist ~= -1) then
xLaser, yLaser, zLaser = L.pos()
x = - xLaser + xTarget
y = - yLaser + yTarget
z = zLaser - zTarget
L.emitBeam(x,y,z)
sleep(3)
end
end
end
thank you to answer me quickly