merte_edenflower

Untitled

Dec 26th, 2013
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.58 KB | None | 0 0
  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
  21. local gold = 0
  22. local iron = 0
  23. local gunpowder = 0
  24. local bones_max = 1024
  25. local gold_max = 1024
  26. local iron_max = 1024
  27. local gunpowder_max = 1024
  28. --))
  29. -- get data from tank
  30. function essenceupdate()
  31.   rednet.broadcast("Send_Essence_Tank_Status");
  32.   local senderId, message, distance = rednet.receive(10)
  33.   local tbl = textutils.unserialize(message)
  34.   if tbl["ID"] == "Essence_Tank_Status" then
  35.     essence_tank_amount = tbl["amount"]
  36.     essence_tank_capacity = tbl["capacity"]
  37.     print(essence_tank_amount)
  38.   else
  39.     essenceupdate()
  40.   end
  41. end
  42. -- get updated values from my ME system
  43. function updateME()
  44.   local MEstuff = me.getAvailableItems()
  45.   for k, v in pairs(MEstuff) do
  46.     if me.getUnlocalizedName(v[1]) == "Gold Ingot" then
  47.       gold = v[2]
  48.     elseif me.getUnlocalizedName(v[1]) == "Iron Ingot" then
  49.       iron = v[2]
  50.     elseif me.getUnlocalizedName(v[1]) == "Bone" then
  51.       bone = v[2]
  52.     elseif me.getUnlocalizedName(v[1]) == "Gunpowder" then
  53.       gunpowder = v[2]
  54.     end
  55.   end
  56. end
  57.  
  58. -- function to print the stop/run function on the screen
  59. function printstatus(bool)
  60.   if bool == true then
  61.     monitor.setTextColor(colors.green)
  62.     print(" RUN")
  63.     monitor.setTextColor(colors.white)
  64.   else
  65.     monitor.setTextColor(colors.red)
  66.     print("STOP")
  67.     monitor.setTextColor(colors.white)
  68.   end
  69. end
  70. --print stored values on screen
  71. function printessencevalues(x,y)
  72.   monitor.setTextColor(colors.black)
  73.   print("test")
  74.   monitor.setCursorPos(x,y)
  75.   if essence_tank_amount > 999 then
  76.     if essence_tank_amount > (essence_tank_capacity / 2) then
  77.       monitor.setTextColor(colors.green)
  78.       print(tostring(essence_tank_amount))
  79.     else
  80.       monitor.setTextColor(colors.orange)
  81.       print(tostring(essence_tank_amount))
  82.     end
  83.   else
  84.     monitor.setTextColor(colors.red)
  85.     print(tostring(essence_tank_amount))
  86.   end
  87.   monitor.setTextColor(colors.white)
  88.   monitor.setCursorPos(x+10,y)
  89.   print(tostring(essence_tank_capacity))
  90. end
  91. function drawframe()
  92.   term.redirect(monitor)--redirect printing to monitor
  93.   term.setCursorBlink(false)
  94.   monitor.clear()
  95.   monitor.setTextColor(colors.white)
  96.   monitor.setBackgroundColor(colors.black)
  97.   paintutils.drawLine(1,1,50,1,colors.yellow)--Border
  98.   paintutils.drawLine(1,26,50,26,colors.yellow)--Border
  99.   paintutils.drawLine(1,1,1,26,colors.yellow)--Border
  100.   paintutils.drawLine(50,1,50,26,colors.yellow)--Border
  101.   paintutils.drawLine(25,1,25,26,colors.yellow)--table
  102.   paintutils.drawLine(30,1,30,26,colors.yellow)--table
  103.   paintutils.drawLine(40,1,40,26,colors.yellow)--table
  104.   -- set texts
  105.   monitor.setCursorPos(2,2)
  106.   print("Essence")
  107.  
  108.   monitor.setCursorPos(26,2)
  109.   printstatus(Mob_essence_on)
  110.   printessencevalues(31,2)
  111.   monitor.setCursorPos(2,3)
  112.   print("Gold")
  113.   monitor.setCursorPos(26,3)
  114.   printstatus(Mob_zpm_on)
  115.   monitor.setCursorPos(31,3)
  116.   print(gold)
  117.   monitor.setCursorPos(41,3)
  118.   print(gold_max)
  119.   monitor.setCursorPos(2,4)
  120.   print("Bones")
  121.   monitor.setCursorPos(26,4)
  122.   printstatus(Mob_skeleton_on)
  123.   monitor.setCursorPos(31,4)
  124.   print(bones)
  125.   monitor.setCursorPos(41,4)
  126.   print(bones_max)
  127.   monitor.setCursorPos(2,5)
  128.   print("Gunpowder")
  129.   monitor.setCursorPos(26,5)
  130.   printstatus(Mob_creep_on)
  131.   monitor.setCursorPos(31,5)
  132.   print(gunpowder)
  133.   monitor.setCursorPos(41,5)
  134.   print(gunpowder_max)
  135.   monitor.setCursorPos(2,6)
  136.   print("iron")
  137.   monitor.setCursorPos(26,6)
  138.   printstatus(Mob_iron_on)
  139.   monitor.setCursorPos(31,6)
  140.   print(iron)
  141.   monitor.setCursorPos(41,6)
  142.   print(iron_max)
  143.   term.restore()--restore printing to computer
  144. end
  145.  
  146. -- inf loop
  147. while true do
  148.   essenceupdate()
  149.   updateME()
  150.   drawframe()
  151.   sleep(5)
  152. end
Advertisement
Add Comment
Please, Sign In to add comment