local stand="front"
local standRed="front"
local monitor="top"
local mfe="mfe_3"

local slots={"head","chest","legs","boots"}

local armors={
["empty"]={name="Empty",power=false},
--Nanosuit
[30178]={name="NanoSuit Helmet",power=true,slot="head"},
[30177]={name="NanoSuit Bodyarmor",power=true,slot="chest"},
[30176]={name="NanoSuit Leggings",power=true,slot="legs"},
[30175]={name="NanoSuit Boots",power=true,slot="boots"},
--Jetpack
[30209]={name="Jetpack",power=true,slot="chest"},
}


local function wrapAll()
stand=peripheral.wrap(stand)
if not stand then error("Wrong stand side ") end
monitor=peripheral.wrap(monitor)
if not monitor then error("Wrong monitor side ") end
mfe=peripheral.wrap(mfe)
if not mfe then error("Wrong mfe side ") end
end

local function charge(A)
mfe.pullItemIntoSlot("up",A,1,1)
local tar=mfe.getStackInSlot(1)
if tar then
	repeat
	tar=mfe.getStackInSlot(1)
	sleep(1)
	until tar.dmg<=1
end
mfe.pushItemIntoSlot("up",1,1,A)
end

local function ready(A)
monitor.setBackgroundColor(A and colors.lime or colors.red)
monitor.clear()
end

wrapAll()

if standRed then redstone.setOutput(standRed,true) end

while true do
for i=1,4 do
local item=stand.getStackInSlot(i)
	if item then
		local armor=armors[item.id]
			if armor and armor.power and item.dmg>1 then 
				ready(false)
				charge(i)		
			end
	end
end
ready(true)

sleep(5)
end
