28 posts
Posted 13 July 2012 - 09:28 AM
Hi,i'm trying to compile a program like this: It's a bit boring let the turtle advance 1 block,then 1 more,1 more…so,what about if turtle could recognize Arrow Keys i press and react moving?
It should move forward with Up Arrow
Backward with Down Arrow…
Turn left and right with Left and Right arrows
How to do this?
404 posts
Location
St. Petersburg
Posted 13 July 2012 - 09:49 AM
while true do
local event,param = os.pullEvent("key")
if param == [KEY#] – where [KEY#] is the number of the arrow key you want (up = 200, down = 208, left = 203, right = 205)
then
end
end
28 posts
Posted 13 July 2012 - 10:07 AM
This half works,if i put
while true do
local event,param = os.pullEvent("key")
if param == [203] -- where [KEY#] is the number of the arrow key you want (up = 200, down = 208, left = 203, right = 205)
then
turtle.turnLeft()
end
end
This as first string,it will only turn left but i wrote all other 3 strings (200,208 and 205)
Some fix? What about
elseif
1604 posts
Posted 13 July 2012 - 05:20 PM
You don't have to put the []. It should look like this:
while true do
local evt, key = os.pullEvent("key")
if key == 200 then -- Up
turtle.forward()
elseif key == 208 then -- Down
turtle.back()
elseif key == 203 then -- Left
turtle.turnLeft()
elseif key == 205 then -- Right
turtle.turnRight()
end
end
You may want to add some keys to go up/down, place/dig blocks and some way to exit the program.
28 posts
Posted 13 July 2012 - 07:42 PM
Thank you a LOT!!! This works fine,and now i can move my turtle a lot easier :)/>/>
Another little question: How can i shrink turtle's GUI? It's a bit invasive,i can't see where my turtle goes
351 posts
Posted 13 July 2012 - 08:19 PM
On singleplayer, you can go to your mod config file, and you will see options for turtle display size. Dunno if this works for multiplayer though, I doubt it.