os.loadAPI("btn")
os.loadAPI("ocs/apis/sensor")
m = peripheral.wrap("top")
prox = sensor.wrap("bottom")
m.setTextScale(.5)

while true do

m.setBackgroundColor(colors.black)
m.clear()
m.setTextColor(colors.cyan)
m.setCursorPos(3,1)
m.write("Laser Ammo")
m.setTextColor(colors.lime)
m.setCursorPos(1,18)
m.write("Check before or")
m.setCursorPos(1,19)
m.write("After Shooting,")
m.setCursorPos(1,20)
m.write("Never DURING!")
term.redirect(m)
paintutils.drawLine(2,3,14,3,colors.red)
paintutils.drawLine(2,8,14,8,colors.red)
paintutils.drawLine(2,3,2,8,colors.red)
paintutils.drawLine(14,3,14,8,colors.red)
m.setBackgroundColor(colors.blue)
m.setTextColor(colors.white)

function fillTable()
 btn.setTable("Check", check, 4,12,5,6)
 btn.screen()
end

function getClick()
 event,side,x,y = os.pullEvent("monitor_touch")
 btn.checkxy(x,y)
end

function check()
btn.flash("Check")
m.setBackgroundColor(colors.red)
m.clear()
m.setTextScale(.5)
m.setTextColor(colors.yellow)
m.setCursorPos(3,1)
m.write("LASER AMMO")
m.setCursorPos(1,5)
m.write("Cannon 1(%):")
m.setCursorPos(1,8)
m.write("Cannon 2(%):")
m.setCursorPos(1,11)
m.write("Cannon 3(%):")
m.setCursorPos(1,14)
m.write("Cannon 4(%):")

moreDetails = prox.getTargetDetails("-2,-4,4")
m.setTextColor(colors.white)
m.setCursorPos(1,6)
m.write(moreDetails.InventoryPercentFull)

moreDetails = prox.getTargetDetails("1,-4,1")
m.setCursorPos(1,9)
m.write(moreDetails.InventoryPercentFull)

moreDetails = prox.getTargetDetails("1,-4,7")
m.setCursorPos(1,12)
m.write(moreDetails.InventoryPercentFull)
moreDetails = prox.getTargetDetails("4,-4,4")
m.setCursorPos(1,15)
m.write(moreDetails.InventoryPercentFull)

sleep(10)
end

fillTable()
getClick()
end
