Posted 19 December 2015 - 01:53 PM
PLEASE lock this topic.
I made a turtle startup program that does other stuff, but on line 61, with code that sends GPS coordinates, it says the error message: "Attempt to concatenate nil and string"
Here's the entire code:
I made a turtle startup program that does other stuff, but on line 61, with code that sends GPS coordinates, it says the error message: "Attempt to concatenate nil and string"
Here's the entire code:
term.clear()
term.setCursorPos(1,1)
print("Booting Keanu&Kiwi TurtleOS")
if turtle.getItemCount() > 0 then
turtle.drop()
end
turtle.equipLeft()
if turtle.getItemCount() > 0 then
print("Left equipment found")
turtle.equipLeft()
end
turtle.equipRight()
if turtle.getItemCount() > 0 then
print("Right equipment found")
turtle.equipRight()
end
function turtleShell()
shell.run("shell")
end
local turtlefuel = turtle.getFuelLevel() / turtle.getFuelLimit() * 100
print("Welcome to Keanu&KiwiOS 2.0")
print("Your fuel level is: "..turtlefuel.."%")
local tModem = peripheral.find("modem")
function turtleSSH()
tModem.open(4872)
while true do
e,s,c,r,m = os.pullEvent("modem_message")
if c == 4872 and r == 5572 then
pcall(loadstring(m))
end
end
end
function turtleLocate()
while true do
sleep(1)
local x,y,z = gps.locate()
if x and y and z then
tModem.transmit(1235,1,{x = x,y = y,z = z})
else
tModem.transmit(1235,1,{x = "?",y = "?",z = "?"})
end
end
end
function turtleFuel()
while true do
local fuelLevelPercentage = math.floor(turtle.getFuelLevel() / turtle.getFuelLimit() * 100)
sleep(0.1)
os.setComputerLabel("Keanu's Mining Turtle ["..tostring(fuelLevelPercentage).."%]")
end
end
function turtleSend()
while true do
sleep(1)
if turtle.detect() then
tModem.transmit(4872,5572,"Obstructed")
else
tModem.transmit(4872,5572,"Clear")
end
local x,y,z = gps.locate()
tModem.transmit(4876,5576,"X: "..x.." | Y: "..y.." | Z: "..z.." ")
end
end
_G.os.version = function() return "Keanu&KiwiOS 2.0" end
parallel.waitForAll(turtleSSH,turtleShell,turtleLocate,turtleFuel,turtleSend)
Edited on 19 December 2015 - 05:43 PM