Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local targets = {'-1,-1,-1', '-1,-1,-2', '-1,-1,-3', '-1,-1,0', '-2,-1,-4', '-2,0,-1', '-2,0,-2', '-2,0,-3', '-2,0,0'}
- os.loadAPI('ocs/apis/sensor')
- local prox, monitor = sensor.wrap('top'), peripheral.find('monitor')
- local currentRMFurnaces, trueEmcValue, lastRMFurnaces, currentSecond = 0, 0, 0, 0
- function initiate()
- monitor.setTextScale(1.5)
- while true do
- loop()
- currentSecond = currentSecond + 1
- sleep(1)
- end
- end
- function loop()
- -- Every 2 Seconds to reduce amount of sensor calls and potentially limit lag
- if ( currentSecond % 2 == 0 ) then
- -- Probe Sensors
- currentRMFurnaces = 0
- for index, target in ipairs(targets) do
- local targetDetails = prox.getTargetDetails(target)
- if ( targetDetails and targetDetails.Name == 'Crystal Chest' ) then
- for slot, item in ipairs(targetDetails.Slots) do
- if ( item.Name == 'Red Matter Furnace') then
- currentRMFurnaces = currentRMFurnaces + item.Size
- end
- end
- end
- end
- -- Calculate EMC Per Second
- local emcPerSecond = math.floor((currentRMFurnaces-lastRMFurnaces) * 10059784)/5
- local rmCountString = 'Furnaces: '..(currentRMFurnaces > 64 and math.floor(currentRMFurnaces / 64)..' stacks & ' or '')..(currentRMFurnaces % 64)..' items'
- local storedEMC = currentRMFurnaces * 10059784
- -- Store biggest number of EMC incase of Zero Per Second.
- trueEmcValue = (emcPerSecond ~= 0 and emcPerSecond or trueEmcValue)
- monitor.clear()
- monitor.setCursorPos(2,4)
- monitor.write('EMC Rate: '..trueEmcValue..' per/s')
- monitor.setCursorPos(2,5)
- monitor.write(rmCountString)
- monitor.setCursorPos(2,6)
- monitor.write('Stored EMC: '..storedEMC)
- lastRMFurnaces = currentRMFurnaces
- end
- end
- initiate()
Advertisement
Add Comment
Please, Sign In to add comment