Posted 02 November 2013 - 05:58 AM
I've been working on a program that builds schematic-like stuff. Here's the code.
It always throws an error when I type in the foolowing command:
build house.cs -118 65 23
It says:
It WAS named build_cs but now it's named build
Please help me!
Spoiler
local args = {...}
if #args ~= 4 then
print("Usage: build <file> <x> <y> <z>")
exit()
end
local file = args[1]
local x = args[2]
local y = args[3]
local z = args[4]
sfile = fs.open(file, "r")
Instructions = split(sfile.readAll(), ",")
if Instructions == nil then
print("Instructions file is corrupt or empty")
exit()
end
--shell.run("goto", x, y, z)
for i = 1, #Instructions do
local slot = tonumber(split(Instructions[i], "#")[1])
local coords = split(split(Instructions[i], "#")[2], ";")[1]
local bx = currentX + coords[1]
local by = currentY + coords[2]
local bz = currentZ + coords[3] + 1
shell.run("goto", bx, by, bz)
turtle.select(slot)
turtle.placeDown()
end
--shell.run("goto", x, y, z)
function split(pString, pPattern)
if sep == nil then
sep = "%s"
end
local t = {}
local i = 1
for str in string.gmatch(pString, "([^"..pPattern.."]+)") do
t[i] = str
i = i + 1
end
return t
end
build house.cs -118 65 23
It says:
build_cs:6: attempt to index ? (a nil value)
But at line 6 there is only the end
What is also wierd, there is no build_cs file on my turtle :/It WAS named build_cs but now it's named build
Please help me!