Advertisement
agentsix1

Farmer Server vALPHA

Aug 6th, 2016 (edited)
2,799
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.80 KB | None | 0 0
  1. local currentKey = "none"
  2. local selectedClient = 0
  3. local modemLocation = "back"
  4. function Home_Screen()
  5.     print("------------------------------")
  6.     print("Welcome To Farmers Server v0.1")
  7.     print("------------------------------")
  8.     print("Options:")
  9.     print("0) Activate Farm")
  10.     print("1) Redstone Listener")
  11.     print("2) View Client Status")
  12.     print("3) Action Log")
  13.     print("4) Set Modem Location")
  14.     print("5) Set Client Key")
  15.     print("Enter a number to select a option above!")
  16.     local input = read()
  17.     if input == "0" then
  18.         activateFarm()
  19.     elseif input == "1" then
  20.         redstoneListener()
  21.     elseif input == "2" then
  22.         viewClient()
  23.     elseif input == "3" then
  24.         actionLog()
  25.     elseif input == "4" then
  26.         setModemLocation()
  27.     elseif input == "5" then
  28.         setClientKey()
  29.     end
  30. end
  31.  
  32. function activateFarm()
  33.     print("--------------------------------")
  34.     print("Select a Client to activate v0.1")
  35.     print("--------------------------------")
  36.     print("1) Client 1")
  37.     print("2) Client 2")
  38.     print("3) Client 3")
  39.     print("4) Client 4")
  40.     print("5) Client 5")
  41.     print("6) Client 6")
  42.     print("7) Client 7")
  43.     print("8) Client 8")
  44.     print("9) Client 9")
  45.     print("Enter a number to select a option above!")
  46.     local input = read()
  47.     if input == "1" then
  48.         local modem = peripheral.wrap(modemLocation)
  49.         modem.transmit(1, 10, generateCode(getKey("1")))
  50.         Home_Screen()
  51.     elseif input == "2" then
  52.         local modem = peripheral.wrap(modemLocation)
  53.         modem.transmit(2, 10, generateCode(getKey("2")))
  54.         Home_Screen()
  55.     elseif input == "3" then
  56.         local modem = peripheral.wrap(modemLocation)
  57.         modem.transmit(3, 10, generateCode(getKey("3")))
  58.         Home_Screen()
  59.     elseif input == "4" then
  60.         local modem = peripheral.wrap(modemLocation)
  61.         modem.transmit(4, 10, generateCode(getKey("4")))
  62.         Home_Screen()
  63.     elseif input == "5" then
  64.         local modem = peripheral.wrap(modemLocation)
  65.         modem.transmit(5, 10, generateCode(getKey("5")))
  66.         Home_Screen()
  67.     elseif input == "6" then
  68.         local modem = peripheral.wrap(modemLocation)
  69.         modem.transmit(6, 10, generateCode(getKey("6")))
  70.         Home_Screen()
  71.     elseif input == "7" then
  72.         local modem = peripheral.wrap(modemLocation)
  73.         modem.transmit(7, 10, generateCode(getKey("7")))
  74.         Home_Screen()
  75.     elseif input == "8" then
  76.         local modem = peripheral.wrap(modemLocation)
  77.         modem.transmit(8, 10, generateCode(getKey("8")))
  78.         Home_Screen()
  79.     elseif input == "9" then
  80.         local modem = peripheral.wrap(modemLocation)
  81.         modem.transmit(9, 10, generateCode(getKey("9")))
  82.         Home_Screen()
  83.     end
  84. end
  85.  
  86. function getKey(num)
  87.     local file = io.open("client" .. num, "r")
  88.     local out = file:read()
  89.     file:close()
  90.     return out
  91. end
  92.  
  93. function setClientKey()
  94.     print("-----------------------------------------")
  95.     print("Select a Client to set a new key for v0.1")
  96.     print("-----------------------------------------")
  97.     print("1) Client 1")
  98.     print("2) Client 2")
  99.     print("3) Client 3")
  100.     print("4) Client 4")
  101.     print("5) Client 5")
  102.     print("6) Client 6")
  103.     print("7) Client 7")
  104.     print("8) Client 8")
  105.     print("9) Client 9")
  106.     print("Enter a number to select a option above!")
  107.     local input = read()
  108.     print("Enter a small string that you would like to set Client " .. input .. "'s key to.")
  109.     local input1 = read()
  110.     if input == "1" then
  111.         local file = io.open("client1", "w")
  112.         file:write(input1)
  113.         file:close()
  114.         Home_Screen()
  115.     elseif input == "2" then
  116.         local file = io.open("client2", "w")
  117.         file:write(input1)
  118.         file:close()
  119.         Home_Screen()
  120.     elseif input == "3" then
  121.         local file = io.open("client3", "w")
  122.         file:write(input1)
  123.         file:close()
  124.         Home_Screen()
  125.     elseif input == "4" then
  126.         local file = io.open("client4", "w")
  127.         file:write(input1)
  128.         file:close()
  129.         Home_Screen()
  130.     elseif input == "5" then
  131.         local file = io.open("client5", "w")
  132.         file:write(input1)
  133.         file:close()
  134.         Home_Screen()
  135.     elseif input == "6" then
  136.         local file = io.open("client6", "w")
  137.         file:write(input1)
  138.         file:close()
  139.         Home_Screen()
  140.     elseif input == "7" then
  141.         local file = io.open("client7", "w")
  142.         file:write(input1)
  143.         file:close()
  144.         Home_Screen()
  145.     elseif input == "8" then
  146.         local file = io.open("client8", "w")
  147.         file:write(input1)
  148.         file:close()
  149.         Home_Screen()
  150.     elseif input == "9" then
  151.         local file = io.open("client9", "w")
  152.         file:write(input1)
  153.         file:close()
  154.         Home_Screen()
  155.     end
  156. end
  157.  
  158. function generateCode(client)
  159.     if 4 < 1 then return nil end
  160.     local s = ""
  161.     for i = 1, 4 do
  162.         s = s .. string.char(math.random(48, 57))
  163.     end
  164.     s = s .. "-"
  165.     for i = 1, 4 do
  166.         s = s .. string.char(math.random(48, 57))
  167.     end
  168.     s = s .. "-"
  169.     for i = 1, 4 do
  170.         s = s .. string.char(math.random(48, 57))
  171.     end
  172.     s = s .. "-"
  173.     for i = 1, 4 do
  174.         s = s .. string.char(math.random(48, 57))
  175.     end
  176.     return client .. "-" .. s
  177. end
  178.  
  179. function redstoneListener()
  180.  
  181. end
  182.  
  183. function viewClient()
  184.  
  185. end
  186.  
  187. function actionLog()
  188.  
  189. end
  190.  
  191. Home_Screen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement