Advertisement
MatthewJ217

Remote Control (CC Computer)

Oct 24th, 2022 (edited)
918
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. -- Send keyboard inputs as rednet signals to a set ID
  2. peripheral.find("modem", rednet.open);
  3.  
  4. local id = 0;
  5. local event, key;
  6.  
  7. function setID()
  8.     print("Setting new ID\nPress Right Ctrl to set");
  9.     print("Last ID: "..tostring(id));
  10.     key = 0;
  11.     id = 0;
  12.     while true do
  13.         event, key = os.pullEvent("key");
  14.         if key == 345 then
  15.             break
  16.         elseif key > 47 and key < 58 then
  17.             id = id * 10 + (key - 48);
  18.             print(tostring(id));
  19.         end
  20.     end
  21.     print("ID set");
  22. end
  23.  
  24. print("Change ID with Right Ctrl\nMove with wasd\nPlace with rfc\nDig with tgv\nInspect blocks with yhb\nGrab items with ujn\nDrop items with ikm\nRefuel with z\nChange slot with 1 and 2\nEquip new tool with x\nAttack with ol,");
  25. setID();
  26.  
  27. while true do
  28.     event, key = os.pullEvent("key");
  29.     --print(tostring(key));
  30.     if key == 345 then
  31.         setID();
  32.     else
  33.         rednet.send(id, key);
  34.         local id, message = rednet.receive();
  35.         if key == 49 then
  36.             print("Selected "..message);
  37.         elseif message ~= "" then
  38.             print(message);
  39.         end
  40.     end
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement