1ng0

Computer Craft RCT v1.0b - Computer

Nov 15th, 2015
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local rcTable = {[17] = "RCF", [50] = "RCMF", [200] = "RCGF", [28] = "RCPF", [57] = "RCAF", [31] = "RCB", [30] = "RCL", [32] = "RCR", [44] = "RCRF", [19] = "RCU", [20] = "RCMU", [21] = "RCGU", [22] = "RCPU", [45] = "RCAU", [33] = "RCD", [34] = "RCMD", [35] = "RCGD", [36] = "RCPD", [46] = "RCAD", [2] = "RC1", [3] = "RC2", [4] = "RC3", [5] = "RC4", [6] = "RC5", [7] = "RC6", [8] = "RC7", [9] = "RC8"}
  2. --(Add): Redstone pulse, Redstone toggle, Drop item, Suck items
  3.  
  4. function RCTC()
  5.  termReset()
  6.  print("Remote Controlled Turtles Controller initiating...")
  7.  sleep(1)
  8.  termReset()
  9.  print("Remote Controlled Turtles Controller initiated, enjoy!")
  10.  controls()
  11.  while true do
  12.   parallel.waitForAny(send, recv)
  13.  end
  14. end
  15.  
  16. function send()
  17.  local sEvent, par = os.pullEvent("key")
  18.  for k, v in pairs(rcTable) do
  19.   if(sEvent == "key") then
  20.    rednet.broadcast(rcTable[par])
  21.   else
  22.    termReset()
  23.    print("Error: Invalid key!")
  24.    controls()
  25.   end
  26.  end
  27. end
  28.  
  29. function recv()
  30.  local scrap, msg = rednet.receive()
  31.  if msg == "RFNF" then
  32.   termReset()
  33.   print("No Fuel in slot 16!")
  34.   controls()
  35.  elseif msg == "RFF" then
  36.   termReset()
  37.   print("Turtle has plenty of fuel! :D")
  38.   controls()
  39.  elseif msg == "RFNV" then
  40.   termReset()
  41.   print("Item in slot 16 is not valid fuel!")
  42.   controls()
  43.   elseif msg == "RFS" then
  44.   termReset()
  45.   print("Refuel successful!")
  46.   controls()
  47.  end
  48. end
  49.  
  50. function controls()
  51.  sleep(1)
  52.  termReset()
  53.  if pocket then --This part revamped for PDA's by Aus4000
  54.   print[[
  55.          RCT
  56.        Controls:
  57.   +------------------+
  58.   |Action|F|B|L|R|U|D|
  59.   +------+-+-+-+-+-+-|
  60.   |Go/Trn|W|S|A|D|R|F|
  61.   |Mine  |M|#|#|#|T|G|
  62.   |GoMine|^|#|#|#|Y|H|
  63.   |Place |<|#|#|#|U|J|
  64.   |Attack| |#|#|#|X|C|
  65.   +------------------+
  66.   |Refuel:Z (Slot 16)|
  67.   |Select-a-slot:1-8 |
  68.   +------------------+
  69.       By 44shades44]]
  70.  else
  71.   print[[
  72.        Remote Controlled Turtles (RCT)
  73.                    Controls:
  74.     +-------------------------------------+
  75.     |Direction  |  F  | B | L | R | U | D |
  76.     +-----------+-----+---+---+---+---+---+
  77.     |Go/Turn    |  W  | S | A | D | R | F |
  78.     |Mine       |  M  | # | # | # | T | G |
  79.     |Mine & Go  | Up  | # | # | # | Y | H |
  80.     |Place Block|Enter| # | # | # | U | J |
  81.     |Attack     |Space| # | # | # | X | C |
  82.     +-------------------------------------+
  83.     |Refuel: Z  | Select slot 1-8: 1-8    |
  84.     |Turtle refuels from slot 16 (last 1) |
  85.     |Turtle selects slot 1 after refuel   |
  86.     +-------------------------------------+
  87.                  By 44shades44]]
  88.  end
  89. end
  90.  
  91. function termReset()
  92.  term.clear()
  93.  term.setCursorPos(1,1)
  94. end
  95.  
  96. if pocket then --also added by Aus4000 for PDA's
  97.  rednet.open("back")
  98.  RCTC()
  99. else
  100.  termReset()
  101.  print("What side is your modem on?")
  102.  rednet.open(read())
  103.  RCTC()
  104. end
  105. -- Thanks Aus4000
Add Comment
Please, Sign In to add comment