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

[Lua] [Error] attempt to call nil

Started by CJR, 07 March 2013 - 03:18 PM
CJR #1
Posted 07 March 2013 - 04:18 PM
I've recently started futzing about with ComputerCraft, since my server is doing a for fun feed the beast server for admins and trusted players. I decided it would be pretty cool to have a tower surrounded by a canyon, and deploy turtles to greet anyone entering and prompt them for the entry password after they press the doorbell. For the program of the greeting turtle, I can get as far as responding to the redstone signal before getting an error. The code is written here.


rednet.open("right")
signal = redstone.getInput("top")
if signal == true then
turtle.forward()
end
while not turtle.detectDown() do
turtle.foward()
end
turtle.left()
turtle.clear()
turtle.setCursorPos(1,1)
turtle.write("Welcome to the lab! Password: ")
local input = read ("*")
turtle.clear()
turtle.setCursorPos(1,1)
turtle.write("Wait here while I check!")
sleep(5)
turtle.right()
turtle.backward()
while not turtle.detectDown() do
turtle.backward()
end
rednet.broadcast(input)
Lyqyd #2
Posted 08 March 2013 - 08:39 AM
Split into new topic.

I think you've confused your APIs here. You have a bunch of turtle calls with functions found in the term API. Try switching all of the term calls over to actually call from term.
TheOddByte #3
Posted 08 March 2013 - 11:26 AM
What error are you getting?
And it's not

turtle.backward()
It's

turtle.back()

--Other Moving Stuff
turtle.down()
turtle.up()
turtle.turnLeft()
turtle.turnRight()

--[[
This Was Also
Wrong..
]]--
turtle.clear() --Should be term.clear()
turtle.setCursorPos(1,1) --Should be term.setCursorPos(1,1)



rednet.open("right")
signal = redstone.getInput("top")
if signal then
turtle.forward()
end

while not turtle.detectDown() do
turtle.forward()
end

turtle.turnLeft()
term.clear()
term.setCursorPos(1,1)
write("Welcome to the lab! Password: ")
local input = read ("*")
term.clear()
term.setCursorPos(1,1)
write("Wait here while I check!")
sleep(5)
turtle.turnRight()
turtle.back()
while not turtle.detectDown() do
turtle.back()
end
rednet.broadcast(input)