merte_edenflower

Untitled

Dec 26th, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- binding peripherals/initializing
  2. --((
  3. local monitor = peripheral.wrap("top")
  4. local modem = peripheral.wrap("back")
  5. local me = peripheral.wrap("right")
  6. rednet.open("back")
  7. -- global variables
  8. local essence_tank_capacity = 1000-- storage capacity of the mob essence tank
  9. local essence_tank_amount = 0 -- total amount of mob essence in the tank
  10. local Mob_essence_on = false -- is the mob essence spawner on
  11. local Mob_zpm_on = false -- is the zombypigman spawner on
  12. local Mob_skeleton_on = false -- is the skeleton spawner on
  13. local Mob_creep_on = false -- is the creeper spawner on
  14. local Mob_ender_on = false -- is the enderman spawner on
  15. local Mob_zombie_on = false -- is the zombie spawner on
  16. local Mob_iron_on = false -- is the iron golem spawner on
  17. local Mob_chicken_on = false -- is the chicken spawner on
  18. local Mob_cow_on = false -- is the cow spawner on
  19. local Mob_sheep_on = false -- is the sheep spawner on
  20. local bones = 0-- amount of bones in my ME system
  21. local gold = 0--amount of gold in my ME system
  22. local iron = 0--amount of iron in my ME system
  23. local gunpowder = 0
  24. local bonesID =352
  25. local goldID = 266
  26. local ironID = 265
  27. local gunpowderID = 289
  28. local bones_max = 1024
  29. local gold_max = 1024
  30. local iron_max = 1024
  31. local gunpowder_max = 1024
  32. --))
  33. -- get data from tank
  34. function essenceupdate()
  35.   rednet.broadcast("Send_Essence_Tank_Status");
  36.   local senderId, message, distance = rednet.receive(10)
  37.   local tbl = textutils.unserialize(message)
  38.   if tbl["ID"] == "Essence_Tank_Status" then
  39.     essence_tank_amount = tbl["amount"]
  40.     essence_tank_capacity = tbl["capacity"]
  41.     print(essence_tank_amount)
  42.   else
  43.     essenceupdate()
  44.   end
  45. end
  46. -- get updated values from my ME system
  47. function updateME()
  48.   local MEstuff = me.getAvailableItems()
  49.   for k, v in pairs(MEstuff) do
  50.     if me.getItemID(v[1]) == goldID then
  51.       gold = v[2]
  52.     end
  53.     if me.getItemID(v[1]) == ironID then
  54.       iron = v[2]
  55.     end
  56.     if me.getItemID(v[1]) == bonesID then
  57.       bone = v[2]
  58.     end
  59.     if me.getItemID(v[1]) == gunpowderID then
  60.       gunpowder = v[2]
  61.     end
  62.   end
  63. end
  64.  
  65. -- function to print the stop/run function on the screen
  66. function printstatus(bool)
  67.   if bool == true then
  68.     monitor.setTextColor(colors.green)
  69.     print(" RUN")
  70.     monitor.setTextColor(colors.white)
  71.   else
  72.     monitor.setTextColor(colors.red)
  73.     print("STOP")
  74.     monitor.setTextColor(colors.white)
  75.   end
  76. end
  77. --print stored values on screen
  78. function printessencevalues(x,y)
  79.   monitor.setTextColor(colors.black)
  80.   print("test")
  81.   monitor.setCursorPos(x,y)
  82.   if essence_tank_amount > 999 then
  83.     if essence_tank_amount > (essence_tank_capacity / 2) then
  84.       monitor.setTextColor(colors.green)
  85.       print(tostring(essence_tank_amount))
  86.     else
  87.       monitor.setTextColor(colors.orange)
  88.       print(tostring(essence_tank_amount))
  89.     end
  90.   else
  91.     monitor.setTextColor(colors.red)
  92.     print(tostring(essence_tank_amount))
  93.   end
  94.   monitor.setTextColor(colors.white)
  95.   monitor.setCursorPos(x+10,y)
  96.   print(tostring(essence_tank_capacity))
  97. end
  98. function drawframe()
  99.   term.redirect(monitor)--redirect printing to monitor
  100.   term.setCursorBlink(false)
  101.   monitor.clear()
  102.   monitor.setTextColor(colors.white)
  103.   monitor.setBackgroundColor(colors.black)
  104.   paintutils.drawLine(1,1,50,1,colors.yellow)--Border
  105.   paintutils.drawLine(1,26,50,26,colors.yellow)--Border
  106.   paintutils.drawLine(1,1,1,26,colors.yellow)--Border
  107.   paintutils.drawLine(50,1,50,26,colors.yellow)--Border
  108.   paintutils.drawLine(25,1,25,26,colors.yellow)--table
  109.   paintutils.drawLine(30,1,30,26,colors.yellow)--table
  110.   paintutils.drawLine(40,1,40,26,colors.yellow)--table
  111.   -- set texts
  112.   monitor.setCursorPos(2,2)
  113.   write("Essence")
  114.  
  115.   monitor.setCursorPos(26,2)
  116.   printstatus(Mob_essence_on)
  117.   printessencevalues(31,2)
  118.   monitor.setCursorPos(2,3)
  119.   write("Gold")
  120.   monitor.setCursorPos(26,3)
  121.   printstatus(Mob_zpm_on)
  122.   monitor.setCursorPos(31,3)
  123.   write(gold)
  124.   monitor.setCursorPos(41,3)
  125.   write(gold_max)
  126.   monitor.setCursorPos(2,4)
  127.   write("Bones")
  128.   monitor.setCursorPos(26,4)
  129.   printstatus(Mob_skeleton_on)
  130.   monitor.setCursorPos(31,4)
  131.   write(bone)
  132.   monitor.setCursorPos(41,4)
  133.   write(bones_max)
  134.   monitor.setCursorPos(2,5)
  135.   write("Gunpowder")
  136.   monitor.setCursorPos(26,5)
  137.   printstatus(Mob_creep_on)
  138.   monitor.setCursorPos(31,5)
  139.   write(gunpowder)
  140.   monitor.setCursorPos(41,5)
  141.   write(gunpowder_max)
  142.   monitor.setCursorPos(2,6)
  143.   write("iron")
  144.   monitor.setCursorPos(26,6)
  145.   printstatus(Mob_iron_on)
  146.   monitor.setCursorPos(31,6)
  147.   write(iron)
  148.   monitor.setCursorPos(41,6)
  149.   write(iron_max)
  150.   term.restore()--restore printing to computer
  151. end
  152.  
  153.  
  154. --spawner control function part 1
  155. function control()
  156.   if essence_tank_amount < essence_tank_capacity then
  157.     Mob_essence_on = true
  158.   else
  159.     Mob_essence_on = false
  160.   end
  161.   if gold < gold_max then
  162.     Mob_zpm_on = true
  163.   else
  164.     Mob_zpm_on = false
  165.   end
  166.   if bones < bones_max then
  167.     Mob_skeleton_on = true
  168.   else
  169.     Mob_skeleton_on = false
  170.   end
  171.   if iron < iron_max then
  172.     Mob_iron_on = true
  173.   else
  174.     Mob_iron_on = false
  175.   end
  176.   if gunpowder < gunpowder_max then
  177.     Mob_creep_on = true
  178.   else
  179.     Mob_creep_on = false
  180.   end
  181.   control2()
  182. end
  183. --spawner control function part 2
  184. function control2()
  185.   local redp = 0
  186.   if Mob_essence_on then
  187.     colors.combine(redp, colors.orange)
  188.   end
  189.   if Mob_zpm_on then
  190.     colors.combine(redp, colors.magenta)
  191.   end
  192.   if Mob_skeleton_on then
  193.     colors.combine(redp, colors.lightblue)
  194.   end
  195.   if Mob_iron_on then
  196.     colors.combine(redp, colors.yellow)
  197.   end
  198.   if Mob_creep_on then
  199.     colors.combine(redp, colors.lime)
  200.   end
  201.   redstone.setBundledOutput("left", redp)
  202. end
  203.  
  204. -- inf loop
  205. while true do
  206.   essenceupdate()
  207.   updateME()
  208.   drawframe()
  209.   control()
  210.   sleep(5)
  211. end
Advertisement
Add Comment
Please, Sign In to add comment