Advertisement
LazyKernel

mineserver

Feb 24th, 2015
542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 0 0
  1. local cobblestone = 0
  2. local iron = 0
  3. local other = 0
  4.  
  5. term.clear()
  6. term.setCursorPos(1, 1)
  7. monitor.clear()
  8. monitor.setCursorPos(1, 1)
  9.  
  10. function newline()
  11.   cx, cy = monitor.getCursorPos()
  12.   monitor.setCursorPos(1, cy + 1)
  13. end
  14.  
  15. function splitS(str, index)
  16.   counter = 0
  17.   returned = false
  18.  
  19.   for i in string.gmatch(str, "%S+") do
  20.     if counter == index
  21.     then
  22.       returned = true
  23.       return i
  24.     else
  25.       counter = counter + 1
  26.     end
  27.   end
  28.  
  29.   if not returned
  30.   then
  31.     return str
  32.   end
  33. end  
  34.  
  35. function drawInfo()
  36.   monitor.write("Cobblestone: "..cobblestone)
  37.   newline()
  38.   monitor.write("Iron: "..iron)
  39.   newline()
  40.   monitor.write("Other: "..other)
  41. end
  42.  
  43. function startMiner()
  44.   modem.transfer(3, 1, "start")
  45. end
  46.  
  47. function stopMiner()
  48.   modem.transfer(3, 1, "stop")
  49. end
  50.    
  51. if tArgs[1] == "stop"
  52. then
  53.   stopMiner()
  54. elseif tArgs[1] == "start"
  55. then
  56.   startMiner()
  57. end
  58.  
  59. modem.open(3)
  60.  
  61. while true do
  62.   event, modemSide, senderChannel, replyChannel,
  63.   message, senderDist = os.pullEvent("modem_message")
  64.  
  65.   monitor.write("Mined "..message.." items")
  66.   newline()
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement