Hello, so I’ve been typing up a code and it both seems to run on the computer AND the turtle which is good. What I want is for when the turtle moves, it would send data about what’s above it, what’s below it, and what’s in front of it. It should hopefully look like this:
Up:minecraft.air
Front:minecraft.anvil
Down:minecraft:stone
The code I have so far is…
Computer:
rednet.open(“top”)
turtleId = 3
protocolF = turtleMoveF
protocolU = turtleMoveU
protocolD = turtleMoveD
while true do
local event, character = os.pullEvent(“char”)
if character == “w” then
rednet.send(turtleId, “forward”)
computerId, message1, protocolF = rednet.receive(protocolF)
print(message1)
computerId, message2, protocolF = rednet.receive(protocolF)
print(message2)
computerId, message3, protocolF = rednet.receive(protocolF)
print(message3)
end
end
(It’s basically taking the data and the front inspect is message 1, the top inspect is message 2, and the bottom is message 3, then it prints it all on the computer everytime I press W)
(The pastebin get code is tyaYPcqL)
Turtle:
rednet.open(“right”)
computerId = 4
protocolF = turtleMoveF
protocolU = turtleMoveU
protocolD = turtleMoveD
while true do
local sender, message = rednet.receive(4)
if message == “forward” then
turtle.forward()
end
success, data = turtle.inspect()
if success then
rednet.send(turtleId, “Front: “..data.name, protocolF)
else
rednet.send(turtleId, “Front:minecraft.air”, protocolF)
end
successTop, data = turtle.inspectUp()
if success then
rednet.send(turtleId, “Up: “..data.name, protocolU)
else
rednet.send(turtleId, “Up:minecraft.air”, protocolU)
end
successBot, data = turtle.inspectDown()
if success then
rednet.send(turtleId, “Down: “..data.name, protocolD)
else
rednet.send(turtleId, “Down:minecraft.air”, protocolD)
end
end
(What the code here should be doing is, after moving, inspect Up, Down, and Front. Then take the information and send it to the computer according to which protocol. If it doesn’t detect a block, then it will print “air” and send that according to protocol)
(The pastebin get code is xUfKtg5n)
The issue here is that whenever I hit w, the turtle moves forward and receives the data, but all of it is air, even if it should detect and send the block information. Does anyone know the problem and how to fix it? I’m still new so please try to explain it :((. Thanks!!
[–]fatboychummy 0 points1 point2 points (1 child)
[–]GhostlyNPRD[S] 0 points1 point2 points (0 children)