Advertisement
cozzimoto

Mob Farmer B:3

Jul 1st, 2013
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.54 KB | None | 0 0
  1. -- MOB Farmer Program
  2. -- Author: theonlycozzy
  3. -- Build 3 July 3, 2013
  4.  
  5. local chat = peripheral.wrap("top")
  6. local m = peripheral.wrap("left")
  7. local active = false
  8. local curOutput = 0
  9. local mods = {"theonlycozzy","ijpooi","jitsublade","beslam","t_ork","detoxii"}
  10. local mobs = {
  11.         skeleton = {active=false,x=4,y=3,output=colors.lime},
  12.         zombie = {active=false,x=4,y=4,output=colors.pink},
  13.         spider = {active=false,x=4,y=5,output=colors.orange},
  14.         blaze = {active=false,x=4,y=6,output=colors.lightGray},
  15.         creeper = {active=false,x=4,y=7,output=colors.yellow},
  16.         mooshroom = {active=false,x=4,y=8,output=colors.white},
  17.         witch = {active=false,x=4,y=9,output=colors.lightBlue},
  18.         magmaCube = {active=false,x=4,y=10,output=colors.magenta},
  19.         enderman = {active=false,x=4,y=11,output=colors.gray},
  20.         skeletonWither = {active=false,x=19,y=3,output=colors.cyan},
  21.         chicken = {active=false,x=19,y=4,output=colors.purple}}
  22.  
  23. if cozCore == nil then
  24.   os.loadAPI("cozCore")
  25. end
  26.  
  27. local X,Y = m.getSize()
  28. m.setCursorPos(6,Y-1)
  29. m.write("Use '-soc mob toggle [NAME]'")
  30. m.setCursorPos(6,Y)
  31. m.write("Use '-soc mob alloff' to shutdown system")
  32.  
  33. while true do
  34.   for name,data in pairs(mobs) do
  35.     if data.active then
  36.       m.setCursorPos(data.x,data.y)
  37.       m.setBackgroundColor(colors.lime)
  38.       m.write("->"..name.." ")
  39.       m.setBackgroundColor(colors.black)
  40.     else
  41.       m.setCursorPos(data.x,data.y)
  42.       m.setBackgroundColor(colors.red)
  43.       m.write("  "..name.." ")
  44.       m.setBackgroundColor(colors.black)
  45.     end
  46.   end
  47.  
  48.   e,p1,p2 = os.pullEvent()
  49.  
  50.   if e == "redstone" then
  51.     local input = rs.getBundledInput("right")
  52.     if input == 1 then -- all off
  53.       os.sleep(0.9)
  54.       chat.say("[Spirit of Coz] Emergency Shutoff Aknowledged",128)
  55.       for name,data in pairs(mobs) do
  56.         data.active = false
  57.       end
  58.     elseif input == 2 then -- all on
  59.       os.sleep(0.9)
  60.       chat.say("[Spirit of Coz] Warning! Activated All Mobs",128)
  61.       for name,data in pairs(mobs) do
  62.         data.active = true
  63.       end
  64.     end  
  65.   end
  66.  
  67.   if e == "chat" then
  68.     local args = cozCore.splitString(string.lower(p2))
  69.  
  70.     for k,v in pairs(mods) do
  71.       if v == string.lower(p1) then
  72.         if args[1] == "-soc" then
  73.           if args[2] == "mob" then
  74.             if args[3] == "toggle" then
  75.               for name,data in pairs(mobs) do
  76.                 if string.lower(name) == args[4] then
  77.                   if data.active then
  78.                     data.active = not data.active
  79.                     os.sleep(0.3)
  80.                     chat.say("[Spirit of Coz] De-actived Mob "..name,128)
  81.                   else
  82.                     data.active = not data.active
  83.                     os.sleep(0.3)
  84.                     chat.say("[Spirit of Coz] Actived Mob "..name,128)
  85.                   end
  86.                 end
  87.               end
  88.             elseif args[3] == "alloff" then
  89.               for name,data in pairs(mobs) do
  90.                 data.active = false
  91.               end
  92.               os.sleep(0.3)
  93.               chat.say("[Spirit of Coz] Mob Farm shutdown Complete",128)
  94.               curOutput = 0
  95.             end
  96.           end
  97.         end
  98.       end
  99.     end
  100.   end
  101.  
  102.   curOutput = 0
  103.   for name,data in pairs(mobs) do
  104.     if data.active then
  105.       curOutput = curOutput + data.output
  106.     end
  107.   end
  108.  
  109.   if curOutput > 1 then
  110.     active = true
  111.   else
  112.     active = false
  113.   end
  114.   rs.setOutput("bottom",active)
  115.   rs.setBundledOutput("back",curOutput)
  116. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement