Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mon = peripheral.wrap("bottom")
- local turrets = {
- peripheral.wrap("OMTBase_4");
- peripheral.wrap("OMTBase_5");
- peripheral.wrap("OMTBase_6");
- peripheral.wrap("OMTBase_7");
- }
- local attackPlayers = false
- local attackMobs = true
- local attackNeutrals = false
- --function declaration
- function clearMonitor()
- mon.setTextColor(colors.white)
- mon.clear()
- mon.setCursorPos(1,1)
- end
- function nextLine()
- x,y = mon.getCursorPos()
- mon.setCursorPos(1,y+1)
- mon.setTextColor(colors.white)
- end
- function toggleAttackPlayers()
- local attack = not turrets[1].attacksPlayers()
- for i=1, #turrets do
- turrets[i].setAttacksPlayers(attack)
- end
- end
- function toggleAttackMobs()
- local attack = not turrets[1].attacksMobs()
- for i=1, #turrets do
- turrets[i].setAttacksMobs(attack)
- end
- end
- function toggleAttackNeutrals()
- local attack = not turrets[1].attacksNeutrals()
- for i=1, #turrets do
- turrets[i].setAttacksNeutrals(attack)
- end
- end
- function printTurretInfo()
- for i=1, #turrets do
- mon.write("Turret: "..i.." "..(math.floor(turrets[i].getEnergyStored()/turrets[i].getMaxEnergyStored()*10*100)/10).."% Energy Stored")
- nextLine()
- end
- nextLine()
- end
- function n()
- if turrets[1].attacksNeutrals() == true then
- return colors.green
- else
- return colors.red
- end
- end
- function p()
- if turrets[1].attacksPlayers() == true then
- return colors.green
- else
- return colors.red
- end
- end
- function m()
- if turrets[1].attacksMobs() == true then
- return colors.green
- else
- return colors.red
- end
- end
- --button Color Write
- function bCW(s,c)
- mon.setBackgroundColor(c)
- mon.write(s)
- mon.setBackgroundColor(colors.black)
- end
- function printControls()
- --start printing at line 9
- mon.setCursorPos(1,9)
- mon.write("+--Neut--+-Players-+---Mob--+")
- nextLine()
- for i=1,2,1 do
- mon.write("|")
- bCW(" ",n())
- mon.write("|")
- bCW(" ",p())
- mon.write("|")
- bCW(" ",m())
- mon.write("|")
- nextLine()
- end
- mon.write("+--------+---------+--------+")
- --meaning that the buttons are at: (2,10) -> (9,11) | (11,10) -> (19,11) | (21,10) - > (29,11) (x,y)
- end
- function routine()
- clearMonitor()
- printTurretInfo()
- printControls()
- end
- while true do
- local timer = os.startTimer(1)
- local event,a1,a2,a3 = os.pullEvent()
- if event == "timer" then
- routine()
- elseif event == "monitor_touch" then
- routine()
- local x = a2
- local y = a3
- if y == 10 or y == 11 then
- if x >= 2 and x <= 11 then
- --Neutrals Button
- toggleAttackNeutrals()
- elseif x >= 11 and x <= 19 then
- --Players Button
- toggleAttackPlayers()
- elseif x >= 21 and x <= 29 then
- --Mobs Button
- toggleAttackMobs()
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment