This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
help with turtle wirelss prog
Started by candycool1234, 16 October 2012 - 09:48 PMPosted 16 October 2012 - 11:48 PM
i need to make a wirelles rc turtle that goes up down left right place dig plz help im not good with this type of codeing
Posted 16 October 2012 - 11:49 PM
Hmm..
If you don't know Lua..
All I can suggest is you learn the turtle API and some Lua.
If you do then
You should learn the API here
If you don't know Lua..
All I can suggest is you learn the turtle API and some Lua.
If you do then
You should learn the API here
Posted 16 October 2012 - 11:53 PM
ik lua ik turtals i mean the arrow to do commands and wireless XD
Posted 16 October 2012 - 11:55 PM
Let's see the code you've got so far. There are plenty of programs to do this already, if you just want code handed to you. We will help you fix your code if you can't get it to work, but we won't code it for you.
Posted 16 October 2012 - 11:55 PM
we won't code whole programs for people, especially when your english is close to un-understandable :D/>/> Try coding it yourself and we are here to help you when there is a bug :P/>/>
Posted 17 October 2012 - 12:03 AM
term.clear()
turtle.turnLeft()
arrow.left()
if arrow left is pressed activated
turtle.turnLeft
turtle.turnRight()
arrow.right()
if arrow left is pressed then activate
turtle.turnRight()
turtle.forward()
arrow.up()
if arrow up is pressed then activate
turtle.forward()
turtle.back()
arrow.down()
if arrow down is presed then activate
turtle.forward()
turtle.dig()
letter./()
if / is presed activate
turtle.dig()
turtle.place()
letter.'()
if ' is pressed then activate
turtle.place()
idk if tahts right but idk how to send his to teh turtle or if the botton activate si right also i need to learn red net :/
turtle.turnLeft()
arrow.left()
if arrow left is pressed activated
turtle.turnLeft
turtle.turnRight()
arrow.right()
if arrow left is pressed then activate
turtle.turnRight()
turtle.forward()
arrow.up()
if arrow up is pressed then activate
turtle.forward()
turtle.back()
arrow.down()
if arrow down is presed then activate
turtle.forward()
turtle.dig()
letter./()
if / is presed activate
turtle.dig()
turtle.place()
letter.'()
if ' is pressed then activate
turtle.place()
idk if tahts right but idk how to send his to teh turtle or if the botton activate si right also i need to learn red net :/
Posted 17 October 2012 - 12:07 AM
Arrow - No API unless you have one loaded?term.clear()
turtle.turnLeft()
arrow.left()
if arrow left is pressed activated
turtle.turnLeft
turtle.turnRight()
arrow.right()
if arrow left is pressed then activate
turtle.turnRight()
turtle.forward()
arrow.up()
if arrow up is pressed then activate
turtle.forward()
turtle.back()
arrow.down()
if arrow down is presed then activate
turtle.forward()
turtle.dig()
letter./()
if / is presed activate
turtle.dig()
turtle.place()
letter.'()
if ' is pressed then activate
turtle.place()
idk if tahts right but idk how to send his to teh turtle or if the botton activate si right also i need to learn red net :/
Arrow left is pressed?
You need to learn the Events API
The tutorial for Events API
http://www.computercraft.info/forums2/index.php?/topic/1516-ospullevent-what-is-it-and-how-is-it-useful/
Posted 17 October 2012 - 12:09 AM
i told u my main problems are i cant do arrow press and then that activates commands also rednet plz help if there is a video on this i need help :/
Posted 17 October 2012 - 12:19 AM
.. Since you don't want to learn
term.clear()
turtle.turnLeft()
while true do
event, p1 = os.pullEvent
if p1 == keys.left then
turtle.turnLeft()
elseif p1 == keys.right then
turtle.turnRight()
elseif p1 == keys.up then
turtle.forward()
elseif p1 == keys.down then
turtle.forward()
end
if p1 == 53 then -- /
turtle.dig()
end
if p1 == 40 then -- '
turtle.place()
end
end
Posted 17 October 2012 - 12:19 AM
I will walk you through this.
for the computer you press the keys in, maybe have:
always one step ahead of me noodle gash darn it
for the computer you press the keys in, maybe have:
while true do -- starts what is called an endless loop, it goes on for infinity or until it get break()ed or something like that. The simple explaination is just: an infinite loop
local event, param = os.pullEvent("key") -- this will create 2 new local variables: 'event' and 'param'. The local means that they can only be accessed by this program. then, we set these 2 variables to os.pullEvent("key"), which will basically wait for a keypress, and then, when a key is pressed, store that keycode into 'param'. 'event' wont be used because we are filtering away all events except keypresses
rednet.open("back") -- This will just open the rednet modem, change "back" to whatever side you have your modem on
if param == 200 then -- This will check if the keycode is 200. 200 is the keycode for the up arrow.
rednet.send(1, "forward") -- This will send a message saying 'forward' to the computer/turtle with id 1. Change the 1 to whatever id your turtle has. to chech what the id is, type 'id' in the turtle.
end -- this ends the if statement
rednet.close("back") -- This closes rednet, again, change "back" to whatever side your modem is on
end -- This closes the infinite loop
Now ofcourse you will need a program in the turtle too, tell em when you fully understand the code I just wrote and I will help you with that too :D/>/>always one step ahead of me noodle gash darn it
Posted 17 October 2012 - 12:26 AM
Hmm.. His code was confusing from the start, I thought he wanted to be in the turtle doing that 0.0I will walk you through this.
for the computer you press the keys in, maybe have:while true do -- starts what is called an endless loop, it goes on for infinity or until it get break()ed or something like that. The simple explaination is just: an infinite loop local event, param = os.pullEvent("key") -- this will create 2 new local variables: 'event' and 'param'. The local means that they can only be accessed by this program. then, we set these 2 variables to os.pullEvent("key"), which will basically wait for a keypress, and then, when a key is pressed, store that keycode into 'param'. 'event' wont be used because we are filtering away all events except keypresses rednet.open("back") -- This will just open the rednet modem, change "back" to whatever side you have your modem on if param == 200 then -- This will check if the keycode is 200. 200 is the keycode for the up arrow. rednet.send(1, "forward") -- This will send a message saying 'forward' to the computer/turtle with id 1. Change the 1 to whatever id your turtle has. to chech what the id is, type 'id' in the turtle. end -- this ends the if statement rednet.close("back") -- This closes rednet, again, change "back" to whatever side your modem is on end -- This closes the infinite loop
Posted 17 October 2012 - 12:26 AM
doyle that is very helpfull do i need spaces also how do i figure out the id of the key?
Posted 17 October 2012 - 12:29 AM
Here's the Key IDsdoyle that is very helpfull do i need spaces also how do i figure out the id of the key?
http://www.minecraftwiki.net/wiki/Key_Codes
The tabbing isn't required, but in some cases you do need spaces.
Posted 17 October 2012 - 12:29 AM
http://www.minecraft.../wiki/Key_codes :D/>/>
With the help of what I just wrote It hink you can replicate that for all keys you want.
When you are done with that, post the program here and I'll help you along with the turtle program
Noodle, seriously? AGAIN?
With the help of what I just wrote It hink you can replicate that for all keys you want.
When you are done with that, post the program here and I'll help you along with the turtle program
Noodle, seriously? AGAIN?
Posted 17 October 2012 - 12:30 AM
What, beat you to it?http://www.minecraft.../wiki/Key_codes :D/>/>
With the help of what I just wrote It hink you can replicate that for all keys you want.
When you are done with that, post the program here and I'll help you along with the turtle program
Noodle, seriously? AGAIN?
Posted 17 October 2012 - 12:32 AM
*sadface* Yes… sadly I'm always second….
Posted 17 October 2012 - 12:32 AM
lol ill get to work with 1 question when are tabs needed
Posted 17 October 2012 - 12:36 AM
when you are entering a new "folder". Think of it like when you are calling for example a while true loop, everything between that while true and that end belongs to that folder, thus you give them blanksteps or tabs to show that they are in that folder. also, it helps you track how many ends you are going to need when you use this method, dispite the fact how much easier it is to read.
Posted 17 October 2012 - 12:38 AM
ok i also need tabs after each end like this
end
end
end
end
ok i also need tabs after each end like this
end
end
Posted 17 October 2012 - 12:39 AM
yeah, tabs are quite buggy for copy pasting or opening code in a different program so I suggest blanksteps. I use 3 but it's really optional for what you think fits you best
I'll give you a example:
And yes, the forum have a failed engine :D/>/>
I'll give you a example:
while true do
print("This is a random print")
for i=1,10 do
print("This for loop opens a new folder in the while true loop folder")
if 1 == 1 then
print("There is no bug in the universe")
else
print("Please reboot the universe, a bug was found")
end
end
end
And yes, the forum have a failed engine :D/>/>
Posted 17 October 2012 - 12:54 AM
while true do
[indent=1]local event, param = os.pullEvent("203")[/indent]
[indent=1]rednet.open("side")[/indent]
[indent=1]if param == 203[/indent]
[indent=2]rednet.send("1, turnLeft")[/indent]
[indent=1]end[/indent]
[indent=1]rednet.close("side")[/indent]
end
Posted 17 October 2012 - 01:00 AM
there we're a few bugs there. First, os.pullEvent() should still have "key" in it, "key" means we filter out all events that are not a keypress.while true do
[indent=1]local event, param = os.pullEvent("203")[/indent]
[indent=1]rednet.open("side")[/indent]
[indent=1]if param == 203[/indent]
[indent=2]rednet.send("1, turnLeft")[/indent]
[indent=1]end[/indent]
[indent=1]rednet.close("side")[/indent]
end
second, you never chose a side for your modem :D/>/>
third, you forgot a 'then' after 'if param == 203'
fourth and last, you have quotes around the 1 too, rednet.send(1, "turnLeft") would be more correct
Posted 17 October 2012 - 01:03 AM
I've posted a working program in User Friendly Program combining several useful functions. If you only want to test drive it, that's fine, but if your willing to learn how it works and help improve it, then that would be great.
Posted 17 October 2012 - 01:06 AM
hey this is great and all ik now how to do taht could u show me how to recive data
Posted 17 October 2012 - 01:13 AM
oh yeah…
I think the only thing new here is rednet.receive(), which receives a rednet message pretty much.
say if there is something that you don't understand in my code :D/>/>
And oh, in the sender computer, make sure you have typed in the correct id of the turtle. the turtle id can be found by opening the turtle GUI and typing 'id'
while true do
senderID, message = rednet.receive()
rendet.open("back")
if message == "forward" then
turtle.forward()
end
if message == "turnLeft" then
turtle.turnLeft()
end
rendet.close
("back")
end
I think the only thing new here is rednet.receive(), which receives a rednet message pretty much.
say if there is something that you don't understand in my code :D/>/>
And oh, in the sender computer, make sure you have typed in the correct id of the turtle. the turtle id can be found by opening the turtle GUI and typing 'id'
Posted 17 October 2012 - 01:20 AM
thx i think i got it but can u gimmi a link to a remote controled 1 i gtg to bed thx ive learned alot :D/>/>
Posted 17 October 2012 - 01:51 AM
I've posted a working program in User Friendly Program combining several useful functions. If you only want to test drive it, that's fine, but if your willing to learn how it works and help improve it, then that would be great.
Posted 17 October 2012 - 04:12 AM
I read through the whole post, and I am just wondering how old this dude is. His name is "candycool1234" and he has no sense of English, so I expect not very old.
Any guesses?
Any guesses?
Posted 17 October 2012 - 04:56 AM
I read through the whole post, and I am just wondering how old this dude is. His name is "candycool1234" and he has no sense of English, so I expect not very old.
Any guesses?
This has no relevancy whatsoever.
Posted 17 October 2012 - 06:22 AM
oh yeah…while true do senderID, message = rednet.receive() rendet.open("back") if message == "forward" then turtle.forward() end if message == "turnLeft" then turtle.turnLeft() end end
I think the only thing new here is rednet.receive(), which receives a rednet message pretty much.
say if there is something that you don't understand in my code :P/>/>
And oh, in the sender computer, make sure you have typed in the correct id of the turtle. the turtle id can be found by opening the turtle GUI and typing 'id'
Why put rednet.open in the loop? :D/>/>
Posted 17 October 2012 - 07:27 AM
My question is more basic…why not start with an example of a working remote control program? Mine isn't the only one that has been written, it's just the one I'm most interested in stirring interest in. But surely everyone here has a favorite program for remotely controlling their turtles, right?
Posted 17 October 2012 - 10:30 AM
oh yeah…while true do senderID, message = rednet.receive() rendet.open("back") if message == "forward" then turtle.forward() end if message == "turnLeft" then turtle.turnLeft() end end
I think the only thing new here is rednet.receive(), which receives a rednet message pretty much.
say if there is something that you don't understand in my code :P/>/>
And oh, in the sender computer, make sure you have typed in the correct id of the turtle. the turtle id can be found by opening the turtle GUI and typing 'id'
Why put rednet.open in the loop? :D/>/>
because I forgot the close… *edits*
I don't like opening rednet permanent since then if my program gets terminated it's higher chance for rednet staying on, which is fine really but I like my code clean.
Posted 17 October 2012 - 10:32 AM
And guys, I don't care if this guy is 5 years old or if he's 40 years old. This is cc forums and we are nice to others and are not going to not help ppl because of their age.
Posted 17 October 2012 - 06:06 PM
What about non-ppl? I'm just kidding, obviously, since I'm the only one that honored the request for a link to a working program.
Posted 16 January 2013 - 02:35 PM
Hey guys I tryed ChunLing link it confused the hell out of me but now i am determined to figure this out if you wait a bit i need to get a new code up and if i can have a link to Notepad++ that would be great I have improved my spelling I am sorry for my previous stupid spelling and understanding I am now a horner roll student so hopefully that will improve my learning thank you for putting up with me back then and i hope you will contiune to help me further in my efforts after i get my code up so please wait.
Posted 17 January 2013 - 10:07 AM
You can get Notepad++ at http://notepad-plus-plus.org/. If you need help specifically with a program posted in the Programs or Turtle Programs forums, you should post on the threads in those forums and refer to this forum only if nobody is responding to posts on the program's thread (and there is an actual problem with the program that you need help solving, of course).
Congrats on improving your academic standing, not everything you learn in school will really matter but your ability to learn always matters.
Congrats on improving your academic standing, not everything you learn in school will really matter but your ability to learn always matters.