the problem is, that I can't figure out a way to wrap all the peripherals and their coordinates.
this is how it works: \
there is a Main computer (server)
there is a slave (turtle)
there is a remote (Pocket computer)
this is a little bit of the code for the Server (I always need to manually edit the script):
local localChannel=1
local rest={x=156,y=7,z=263}
local drop={x=160,y=6,z=264}
local chests={
{chest=peripheral.wrap("iron_0"),pos={x=156,y=5,z=260}},
{chest=peripheral.wrap("iron_1"),pos={x=157,y=5,z=260}},
{chest=peripheral.wrap("iron_2"),pos={x=158,y=5,z=260}},
{chest=peripheral.wrap("iron_3"),pos={x=159,y=5,z=260}},
{chest=peripheral.wrap("iron_4"),pos={x=160,y=5,z=260}},
{chest=peripheral.wrap("iron_5"),pos={x=161,y=5,z=260}},
{chest=peripheral.wrap("iron_6"),pos={x=162,y=5,z=260}},
{chest=peripheral.wrap("iron_7"),pos={x=163,y=5,z=260}},
{chest=peripheral.wrap("iron_8"),pos={x=164,y=5,z=260}},
{chest=peripheral.wrap("iron_9"),pos={x=165,y=5,z=260}},
}
local modem=peripheral.wrap("back")
local wireless=peripheral.wrap("bottom")
you can see the complete code for the server here: http://pastebin.com/zhSV6GeZ
I need to optimize the code so it will ask for a resting point and a drop point for the turtle, the modem sides and ofcourse the chests, with their coordinates.
The code for the turtle is here: http://pastebin.com/saVGtpYB
The code for the pocket computer is: http://pastebin.com/RsXahp4s
PS:
I also get errors on the turtle when sending him instructions: Startup:131: Expected number
this leads to the following snippet of the Turtle script:
unction self.goto(x,y,z,fails)
if turtle.getFuelLevel() == 0 then
[color=#ff0000] [/color] wireless.transmit(replyChannel,localChannel,"status|Out of fuel")[color=#ff0000] -- this is the error line 131[/color]
print("Awaiting fuel in slot 16")
turtle.select(16)
while turtle.getFuelLevel() == 0 do
turtle.refuel()
end
end
local fails=fails
if fails==nil then
fails=0
end
local yDistance=(self.pos.y-y)*-1
local yTravel=true
if yDistance>0 then
yTravel=self.move("up",yDistance)
elseif yDistance<0 then
yTravel=self.move("down",yDistance*-1)
end
local xDistance=(self.pos.x-x)*-1
local xTravel=true
if xDistance>0 then
self.setFacing("east")
elseif xDistance<0 then
self.setFacing("west")
xDistance=xDistance*-1
end
xTravel=self.move("forward",xDistance)
local zDistance=(self.pos.z-z)*-1
local zTravel=true
if zDistance>0 then
self.setFacing("south")
elseif zDistance<0 then
self.setFacing("north")
zDistance=zDistance*-1
end
zTravel=self.move("forward",zDistance)
if xTravel==false or zTravel==false or yTravel==false then
if fails==6 or fails == 8 or fails == 10 then
self.move("up",1)
self.move("forward",2)
self.move("down",1)
elseif fails == 5 or fails == 7 or fails == 9 then
local originalFacing = self.facing
if originalFacing == "north" then
self.setFacing("west")
self.move("forward",1)
self.setFacing(originalFacing)
self.move("forward",2)
self.setFacing("east")
self.move("forward",1)
self.setFacing(originalFacing)
elseif originalFacing == "south" then
self.setFacing("east")
self.move("forward",1)
self.setFacing(originalFacing)
self.move("forward",2)
self.setFacing("west")
self.move("forward",1)
self.setFacing(originalFacing)
elseif originalFacing == "west" then
self.setFacing("north")
self.move("forward",1)
self.setFacing(originalFacing)
self.move("forward",2)
self.setFacing("south")
self.move("forward",1)
self.setFacing(originalFacing)
else
self.setFacing("south")
self.move("forward",1)
self.setFacing(originalFacing)
self.move("forward",2)
self.setFacing("north")
self.move("forward",1)
self.setFacing(originalFacing)
end
end
fails=fails+1
if fails>=11 then
return false
end
sleep(1)
return self.goto(x,y,z,fails)
end
return true
end
can someone help me fix my scripts please? I am getting a headache from it at this point since I can't figure it out anymore :(/>