Posted 24 September 2014 - 05:52 PM
Hey everyone, I am very new to the use of modems but i can do some lua programming in computercraft. i need help making my code work with a modem (tell a computer to do something and it sends the command to a turtle)
basically my code is sort of a delivery system with a turtle. it doesnt do much, it just travels a distance, drops blocks, and returns.
so here it is:
while true do
– Clear screen
term.clear()
term.setCursorPos(1,1)
print ("Pick an action:")
print ("1) Travel Distance.")
print ("2) Drop items.")
print ("3) Return turtle to starting point.")
– Option 1: Turtle move distance 5 blocks.
choice = tonumber(read())
if choice == 1 then
tfront = 0
while tfront < 5 do
turtle.forward()
tfront = tfront + 1
end
end
– Option 2: Drop items
if choice == 2 then
for sslot = 1,9 do
turtle.select(sslot)
for islot = 1,turtle.getItemCount(sslot) do
turtle.drop()
end
end
end
– Option 3: Return to start
if choice == 3 then
tback = 0
while tback < 5 do
turtle.back()
tback = tback + 1
end
end
end
i would be really greatful if someone could show me how to make with work from a computer giving comands to a wireless turtle. many of the tutorials i've googled havent helped much.
Ty!!
basically my code is sort of a delivery system with a turtle. it doesnt do much, it just travels a distance, drops blocks, and returns.
so here it is:
while true do
– Clear screen
term.clear()
term.setCursorPos(1,1)
print ("Pick an action:")
print ("1) Travel Distance.")
print ("2) Drop items.")
print ("3) Return turtle to starting point.")
– Option 1: Turtle move distance 5 blocks.
choice = tonumber(read())
if choice == 1 then
tfront = 0
while tfront < 5 do
turtle.forward()
tfront = tfront + 1
end
end
– Option 2: Drop items
if choice == 2 then
for sslot = 1,9 do
turtle.select(sslot)
for islot = 1,turtle.getItemCount(sslot) do
turtle.drop()
end
end
end
– Option 3: Return to start
if choice == 3 then
tback = 0
while tback < 5 do
turtle.back()
tback = tback + 1
end
end
end
i would be really greatful if someone could show me how to make with work from a computer giving comands to a wireless turtle. many of the tutorials i've googled havent helped much.
Ty!!