Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local itemdb = {}
- local time = 0
- local startemc = nil
- local storage = peripheral.wrap( "back" )
- local mon = peripheral.find( "monitor" )
- mon.w, mon.h = mon.getSize()
- local request = http.get( "https://gmod.club/scripts/cc/item_emc.json" )
- local json = request.readAll()
- itemdb = textutils.unserialiseJSON( json )
- request.close()
- local input_item = "minecraft:blaze_rod"
- local function clear()
- term.clear()
- mon.clear()
- term.setCursorPos( 5, 3 )
- term.setBackgroundColor( colors.red )
- mon.setTextColor( colors.black )
- mon.setTextScale( 2 )
- end
- function formatTime( sec )
- return string.format( "%.2d:%.2d:%.2d", sec / ( 60 * 60 ), sec / 60 % 60, sec % 60 )
- end
- function comma( n )
- return tostring( math.floor( n ) ):reverse():gsub( "(%d%d%d)","%1," ):gsub( ",(%-?)$","%1" ):reverse()
- end
- clear()
- term.redirect( mon )
- while true do
- clear()
- local emc = 0
- local amount = 0
- for slot, item in pairs( storage.list() ) do
- if item.name ~= input_item then
- amount = amount + item.count
- local stored = itemdb[item.name .. "|" .. item.damage]
- if stored then
- emc = emc + ( item.count * stored )
- end
- end
- end
- mon.setTextColor( colors.black )
- mon.setCursorPos( 8, 1 )
- mon.write( "EMC Monitor" )
- mon.setCursorPos( 5, 3 )
- mon.write( "EMC: " .. comma( emc ) )
- if startemc == nil then startemc = emc end
- local gained = emc - startemc
- local emcrate = math.floor( gained / time ) * 60
- if gained < 0 then os.reboot() end
- mon.setCursorPos( 5, 4 )
- mon.write( "EMC/m: " .. comma( emcrate ) )
- mon.setCursorPos( 5, 5 )
- mon.write( "Time: " .. formatTime( time ) )
- mon.setCursorPos( 5, 6 )
- mon.write( "Amount: " .. comma( amount ) )
- time = time + 1
- sleep( 1 )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement