This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
candycool1234's profile picture

Wireless turtle help me please

Started by candycool1234, 16 January 2013 - 02:18 PM
candycool1234 #1
Posted 16 January 2013 - 03:18 PM
Please go here to see code as I cannot figure out how to copy over Thank you
btw this is just the send code

http://pastebin.com/MLaPHVyQ
theoriginalbit #2
Posted 16 January 2013 - 03:36 PM
pastebin is a good place to put it anyways

Where you have this all over the place

local event, con = os.pullEvent("key203")
it wont work… should be

local event, con = os.pullEvent("key")
your line here checks the key code…

if con == 203 then
  -- do the stuff you need to here
end
candycool1234 #3
Posted 16 January 2013 - 03:45 PM
omg thankyou i will try it
candycool1234 #4
Posted 16 January 2013 - 03:58 PM
http://pastebin.com/piixXmtj
theoriginalbit #5
Posted 16 January 2013 - 04:00 PM
ok so now I'm assuming the next issue you posted that link for is that only one key works?
candycool1234 #6
Posted 16 January 2013 - 04:07 PM
im getting a bios: [string "control"]:16: '<eof>' expected
theoriginalbit #7
Posted 16 January 2013 - 04:10 PM
looks at code *wild else appears on line 16*

remove the else and it should be good
candycool1234 #8
Posted 16 January 2013 - 04:11 PM
i fixed that with removing the else and i think if i get 1 key works ill just make the con to cad ras ert and other random variables

im gonna start on the recive code
theoriginalbit #9
Posted 16 January 2013 - 04:15 PM
the reason the other keys dont work is because the program is tied up in the first loop…
change the check to this


local event, con = os.pullEvent("key")
if con == 203 then
  -- do something
elseif con == 205 then
  -- do something else
elseif -- etc etc etc

end

candycool1234 #10
Posted 16 January 2013 - 04:29 PM
that wouldnt work you would need

while true do

[indent=1]local event,con os.pullEvent(key)[/indent]
[indent=1]if con == ___ then[/indent]
[indent=1]ect[/indent]
[indent=1]ect[/indent]
[indent=1]end[/indent]

[indent=1]local event, cod os.pullevent(key)[/indent]
theoriginalbit #11
Posted 16 January 2013 - 04:31 PM
no i can tell you that it will work…


while true do

is an infinite loop, so it pulls an event each loop and stores the key that was pressed to cause the event…

then all you need to do is check the key against what you want with if elseif when you need to check multiple keys…


EDIT: Oh i just realised what you meant… the code i suggested is for inside the loop… not replacing the loop
Edited on 16 January 2013 - 03:32 PM
candycool1234 #12
Posted 16 January 2013 - 04:55 PM
http://pastebin.com/QEC5kryT
candycool1234 #13
Posted 16 January 2013 - 04:57 PM
lol ill fix the first one and post my final thx
candycool1234 #14
Posted 16 January 2013 - 04:59 PM
  1. while true do
  2. local event, con = os.pullEvent("key")
  3. rednet.open("left")
  4. elseif if con == 205 then
  5. rednet.send(1, "turnRight")
  6. elseif rednet.close("left")
  7. end
  8. end
is that what u meant?

      theoriginalbit #15
      Posted 16 January 2013 - 05:06 PM
      here is your turtle code fixed
      http://pastebin.com/QQpjxNDU

      here is your console code fixed
      http://pastebin.com/yMC1aBMa
      candycool1234 #16
      Posted 16 January 2013 - 05:35 PM
      can i keep that as my own or should i just take yours? as yours… thx tho
      theoriginalbit #17
      Posted 16 January 2013 - 05:39 PM
      can i keep that as my own or should i just take yours? as yours… thx tho
      Not sure I understand what you mean… if you mean do I 'own' the rights to that code… no i don't… I'm here helping you, so its all yours…