Posted 17 September 2012 - 06:59 PM
So I'm trying to make a script like eloraam did in Direwolf20's SMP Lets Play series. I think most of my script works but it says
The old code + error is:
path:77: attempt to call boolean
The newest code/error is to do with rednet. (Keep on mind that this is on a turtle!)
Error: path:11: attempt to call nil
Also. How would I go about creating a GPS tower for when my turtle is further away from my main system.
The old code + error is:
Spoiler
Turtle:18:Expected Number
os.pullEvent = os.pullEventRaw
local slot
local times
turtle.select(slot)
slot = 1
function check()
if turtle.getItemCount(slot) == 0 then
print("Changing Stack.")
slot = slot + 1
turtle.select(slot)
if turtle.getItemCount(slot) == 0 then
print("No more items. Please keep all items together.")
end
end
end
function up()
turtle.up()
end
function down()
turtle.down()
end
function go()
turtle.forward()
end
function left()
turtle.turnLeft()
end
function right()
right = turtle.turnRight()
end
term.clear()
term.setCursorPos(1,1)
print("Please place fuel in the highlighted area.")
print(" ")
print("Please place building materials in non-highlighted areas.")
print(" ")
print("Please remember that each 'set' of blocks is 7.")
sleep(5)
term.clear()
term.setCursorPos(1,1)
print("How far should the path go?")
print("")
times = tonumber(io.read())
sleep(2)
print("")
print("Going " ..times.. " blocks.")
for i = 1, times, 1 do --times()
go()
left()
go()
go()
turtle.placeDown()
check()
up()
turtle.placeDown()
check()
right()
right()
go()
down()
turtle.placeDown()
check()
for j = 1, 3 do
go()
turtle.placeDown()
check()
end
up()
turtle.placeDown()
check()
left()
left()
go()
go()
right()
down()
end
Spoiler
The 2nd code + error is:path:77: attempt to call boolean
os.pullEvent = os.pullEventRaw
turtle.refuel(64)
local times
local slot = 1
turtle.select(slot)
slot = 1
function check()
if turtle.getItemCount(slot) == 0 then
print("Changing Stack.")
slot = slot + 1
turtle.select(slot)
if turtle.getItemCount(slot) == 0 then
print("No more items. Please keep all items together.")
end
end
end
function up()
turtle.up()
sleep(1)
end
function down()
turtle.down()
sleep(1)
end
function go()
turtle.forward()
sleep(1)
end
function left()
turtle.turnLeft()
sleep(1)
end
function right()
right = turtle.turnRight()
sleep(1)
end
term.clear()
term.setCursorPos(1,1)
print("Please place fuel in the highlighted area.")
print(" ")
print("Please place building materials in non-highlighted areas.")
print(" ")
print("Please remember that each 'set' of blocks is 7.")
sleep(5)
term.clear()
term.setCursorPos(1,1)
print("How far should the path go?")
print("")
times = tonumber(io.read())
sleep(2)
print("")
print("Going " ..times.. " blocks.")
for i = 1, times, 1 do
go()
left()
go()
go()
up()
turtle.placeDown()
check()
right()
right()
go()
down()
turtle.placeDown()
check()
for j = 1, 2 do
go()
turtle.placeDown()
check()
end
go()
up()
turtle.placeDown()
check()
left()
left()
go()
go()
right()
down()
end
The newest code/error is to do with rednet. (Keep on mind that this is on a turtle!)
Error: path:11: attempt to call nil
os.pullEvent = os.pullEventRaw
local timeout = 1000000
local times
local slot = 1
turtle.select(slot)
slot = 1
local id = 0
rednet.open("right")
rednet.recieve(timeout) -- Line 11
function check()
if turtle.getItemCount(slot) == 0 then
print("Changing Stack.")
slot = slot + 1
turtle.select(slot)
if turtle.getItemCount(slot) == 0 then
print("No more items. Please keep all items together. Carrying on in 120 seconds.")
sleep(120)
end
end
end
function up()
turtle.up()
sleep(.5)
end
function down()
turtle.down()
sleep(.5)
end
function go()
turtle.forward()
sleep(.5)
end
function left()
turtle.turnLeft()
sleep(.5)
end
function right()
turtle.turnRight()
sleep(.5)
end
term.clear()
term.setCursorPos(1,1)
print("Please place fuel in the highlighted area.")
print(" ")
print("Please place building materials in non-highlighted areas.")
print(" ")
print("Please remember that each 'set' of blocks is 7.")
sleep(5)
turtle.refuel(64)
term.clear()
term.setCursorPos(1,1)
print("How far should the path go?")
print("")
if times == nil then
times = tonumber(io.read())
end
if times == 999 then
error()
end
if times == 0 then
up()
down()
left()
right()
go()
left()
left()
go()
right()
right()
else
sleep(2)
print("")
print("Going " ..times.. " blocks.")
for i = 1, times, 1 do
go()
left()
go()
go()
turtle.placeDown()
turtle.placeDown()
check()
up()
turtle.placeDown()
check()
right()
right()
go()
down()
turtle.placeDown()
check()
for j = 1, 3 do
go()
turtle.placeDown()
check()
end
up()
turtle.placeDown()
check()
left()
left()
go()
go()
right()
down()
end
end
shell.run("path")
Also. How would I go about creating a GPS tower for when my turtle is further away from my main system.