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

[ERROR]Attempt to call nil

Started by Rangicus, 15 September 2012 - 10:57 AM
Rangicus #1
Posted 15 September 2012 - 12:57 PM
I made this program: (lights)
Spoiler
print("On/Off")
x = io.read()
if x == "On" then
rs.setOutput("back",true)
end
if x == "Off" then
rs.setOutput("back",false)
end
xcor.clear(1, 1)
This is xcor:
Spoiler
function getTree()
while turtle.detect() do
turtle.dig()
print("Digging the block")
turtle.digUp()
print("Digging the block")
turtle.up()
print("Moving up")
end
while not turtle.detect() and not turtle.detectDown() do
turtle.down()
print("Moving down")
end
term.clear()
term.setCursorPos(1,1)
print("Tree Cut!")
end
function cobbleGen()
while true do
if turtle.detect() then
  turtle.dig()
end
itemcount = turtle.getItemCount(16)
if itemcount == 64 then
  for i=1,16 do
   turtle.select(i)
   turtle.dropUp()
  end
  turtle.select(1)
end
end
end
function buildStair()
while turtle.detect() do
  turtle.up()
end
turtle.down()
turtle.down()
turtle.back()
turtle.place()
while not turtle.detectDown() do
  turtle.back()
  turtle.down()
  turtle.place()
end
print("Done!")
end
function buildPortal()
print("Please insert 10 obsidian in slot 1")
print("[ENTER] to continue")
os.pullEvent()
term.clear()
term.setCursorPos(1,1)
turtle.select(1)
turtle.up()
turtle.placeDown()
turtle.turnRight()
turtle.forward()
turtle.placeDown()
turtle.forward()
turtle.up()
turtle.placeDown()
turtle.up()
turtle.placeDown()
turtle.up()
turtle.placeDown()
turtle.up()
turtle.turnLeft()
turtle.turnLeft()
turtle.forward()
turtle.placeDown()
turtle.forward()
turtle.placeDown()
turtle.forward()
turtle.down()
turtle.down()
turtle.down()
turtle.placeDown()
turtle.up()
turtle.placeDown()
turtle.up()
turtle.placeDown()
print("Portal Built!")
end
function clear(arg1, arg2)
term.clear()
term.setCursorPos(arg1, arg2)
end
This is the error I get:
Spoiler
lights:9: attempt to call nil
I try to call the function clear in xcor, but it gives me the error
yes i know there is already a clear, but I type xcor.clear(1, 1) so it should not be using term.clear()
help?
Magus #2
Posted 15 September 2012 - 01:18 PM
Try loading xcor befor calling any functions in it

os.loadAPI("/(path/to/xcor")