Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- binding peripherals/initializing
- --((
- local monitor = peripheral.wrap("top")
- local modem = peripheral.wrap("back")
- local me = peripheral.wrap("right")
- rednet.open("back")
- -- global variables
- local essence_tank_capacity = 1000-- storage capacity of the mob essence tank
- local essence_tank_amount = 0 -- total amount of mob essence in the tank
- local Mob_essence_on = false -- is the mob essence spawner on
- local Mob_zpm_on = false -- is the zombypigman spawner on
- local Mob_skeleton_on = false -- is the skeleton spawner on
- local Mob_creep_on = false -- is the creeper spawner on
- local Mob_ender_on = false -- is the enderman spawner on
- local Mob_zombie_on = false -- is the zombie spawner on
- local Mob_iron_on = false -- is the iron golem spawner on
- local Mob_chicken_on = false -- is the chicken spawner on
- local Mob_cow_on = false -- is the cow spawner on
- local Mob_sheep_on = false -- is the sheep spawner on
- local bones = 0-- amount of bones in my ME system
- local gold = 0--amount of gold in my ME system
- local iron = 0--amount of iron in my ME system
- local gunpowder = 0
- local bonesID =352
- local goldID = 266
- local ironID = 265
- local gunpowderID = 289
- local bones_max = 1024
- local gold_max = 1024
- local iron_max = 1024
- local gunpowder_max = 1024
- --))
- -- get data from tank
- function essenceupdate()
- rednet.broadcast("Send_Essence_Tank_Status");
- local senderId, message, distance = rednet.receive(10)
- local tbl = textutils.unserialize(message)
- if tbl["ID"] == "Essence_Tank_Status" then
- essence_tank_amount = tbl["amount"]
- essence_tank_capacity = tbl["capacity"]
- print(essence_tank_amount)
- else
- essenceupdate()
- end
- end
- -- get updated values from my ME system
- function updateME()
- local MEstuff = me.getAvailableItems()
- for k, v in pairs(MEstuff) do
- if me.getItemID(v[1]) == goldID then
- gold = v[2]
- end
- if me.getItemID(v[1]) == ironID then
- iron = v[2]
- end
- if me.getItemID(v[1]) == bonesID then
- bone = v[2]
- end
- if me.getItemID(v[1]) == gunpowderID then
- gunpowder = v[2]
- end
- end
- end
- -- function to print the stop/run function on the screen
- function printstatus(bool)
- if bool == true then
- monitor.setTextColor(colors.green)
- print(" RUN")
- monitor.setTextColor(colors.white)
- else
- monitor.setTextColor(colors.red)
- print("STOP")
- monitor.setTextColor(colors.white)
- end
- end
- --print stored values on screen
- function printessencevalues(x,y)
- monitor.setTextColor(colors.black)
- print("test")
- monitor.setCursorPos(x,y)
- if essence_tank_amount > 999 then
- if essence_tank_amount > (essence_tank_capacity / 2) then
- monitor.setTextColor(colors.green)
- print(tostring(essence_tank_amount))
- else
- monitor.setTextColor(colors.orange)
- print(tostring(essence_tank_amount))
- end
- else
- monitor.setTextColor(colors.red)
- print(tostring(essence_tank_amount))
- end
- monitor.setTextColor(colors.white)
- monitor.setCursorPos(x+10,y)
- print(tostring(essence_tank_capacity))
- end
- function drawframe()
- term.redirect(monitor)--redirect printing to monitor
- term.setCursorBlink(false)
- monitor.clear()
- monitor.setTextColor(colors.white)
- monitor.setBackgroundColor(colors.black)
- paintutils.drawLine(1,1,50,1,colors.yellow)--Border
- paintutils.drawLine(1,26,50,26,colors.yellow)--Border
- paintutils.drawLine(1,1,1,26,colors.yellow)--Border
- paintutils.drawLine(50,1,50,26,colors.yellow)--Border
- paintutils.drawLine(25,1,25,26,colors.yellow)--table
- paintutils.drawLine(30,1,30,26,colors.yellow)--table
- paintutils.drawLine(40,1,40,26,colors.yellow)--table
- -- set texts
- monitor.setCursorPos(2,2)
- write("Essence")
- monitor.setCursorPos(26,2)
- printstatus(Mob_essence_on)
- printessencevalues(31,2)
- monitor.setCursorPos(2,3)
- write("Gold")
- monitor.setCursorPos(26,3)
- printstatus(Mob_zpm_on)
- monitor.setCursorPos(31,3)
- write(gold)
- monitor.setCursorPos(41,3)
- write(gold_max)
- monitor.setCursorPos(2,4)
- write("Bones")
- monitor.setCursorPos(26,4)
- printstatus(Mob_skeleton_on)
- monitor.setCursorPos(31,4)
- write(bone)
- monitor.setCursorPos(41,4)
- write(bones_max)
- monitor.setCursorPos(2,5)
- write("Gunpowder")
- monitor.setCursorPos(26,5)
- printstatus(Mob_creep_on)
- monitor.setCursorPos(31,5)
- write(gunpowder)
- monitor.setCursorPos(41,5)
- write(gunpowder_max)
- monitor.setCursorPos(2,6)
- write("iron")
- monitor.setCursorPos(26,6)
- printstatus(Mob_iron_on)
- monitor.setCursorPos(31,6)
- write(iron)
- monitor.setCursorPos(41,6)
- write(iron_max)
- term.restore()--restore printing to computer
- end
- --spawner control function part 1
- function control()
- if essence_tank_amount < essence_tank_capacity then
- Mob_essence_on = true
- else
- Mob_essence_on = false
- end
- if gold < gold_max then
- Mob_zpm_on = true
- else
- Mob_zpm_on = false
- end
- if bones < bones_max then
- Mob_skeleton_on = true
- else
- Mob_skeleton_on = false
- end
- if iron < iron_max then
- Mob_iron_on = true
- else
- Mob_iron_on = false
- end
- if gunpowder < gunpowder_max then
- Mob_creep_on = true
- else
- Mob_creep_on = false
- end
- control2()
- end
- --spawner control function part 2
- function control2()
- local redp = 0
- if Mob_essence_on then
- colors.combine(redp, colors.orange)
- end
- if Mob_zpm_on then
- colors.combine(redp, colors.magenta)
- end
- if Mob_skeleton_on then
- colors.combine(redp, colors.lightblue)
- end
- if Mob_iron_on then
- colors.combine(redp, colors.yellow)
- end
- if Mob_creep_on then
- colors.combine(redp, colors.lime)
- end
- redstone.setBundledOutput("left", redp)
- end
- -- inf loop
- while true do
- essenceupdate()
- updateME()
- drawframe()
- control()
- sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment