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?
Turtle Recognizing Arrow Keys i press
Started by Macapple, Jul 13 2012 08:28 AM
5 replies to this topic
#1
Posted 13 July 2012 - 08:28 AM
#2
Posted 13 July 2012 - 08: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
[CODE]
end
end
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
[CODE]
end
end
#3
Posted 13 July 2012 - 09:07 AM
This half works,if i put
This as first string,it will only turn left but i wrote all other 3 strings (200,208 and 205)
Some fix? What about
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
#4
Posted 13 July 2012 - 04: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.
#5
Posted 13 July 2012 - 06: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
Another little question: How can i shrink turtle's GUI? It's a bit invasive,i can't see where my turtle goes
#6
Posted 13 July 2012 - 07: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.
3 user(s) are reading this topic
0 members, 3 guests, 0 anonymous users











