Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- echest = "west"
- net = peripheral.wrap("back")
- ae = "appeng_me_tilecolorlesscable_1"
- glass= "openperipheral_glassesbridge_0"
- net.callRemote(glass,"clear")
- sheight = 250
- swidth = 450
- AEmonmax = math.floor((swidth-20)/30)
- monitems = {}
- monicons = {}
- montext = {}
- formattext = {}
- b = ""
- message = function(message,colour)
- for word in string.gmatch(message) do
- a = string.len(word)
- blen = string.len(b)
- if a + blen < 15 then
- b = b.." "..word
- else
- table.insert(formattext, b)
- b = word
- end
- end
- end
- function round(number, sigDigits)
- local decimalPlace = string.find(number, "%.")
- if not decimalPlace or (sigDigits < decimalPlace) then
- numberTable = {}
- count = 1
- for digit in string.gmatch(number, "%d") do
- table.insert(numberTable, digit)
- end
- local endNumber = ""
- for i,digit in ipairs(numberTable) do
- if i < sigDigits then
- endNumber = endNumber .. digit
- end
- if i == sigDigits then
- if tonumber(numberTable[i + 1]) >= 5 then
- endNumber = endNumber .. digit + 1
- else
- endNumber = endNumber .. digit
- end
- end
- if i > sigDigits and (not decimalPlace or (i < decimalPlace)) then
- endNumber = endNumber .. "0"
- end
- end
- return tonumber(endNumber)
- else
- local decimalDigits = sigDigits - decimalPlace + 1
- return tonumber(string.format("%" .. decimalPlace - 1 .. "." .. decimalDigits .. "f", number))
- end
- end
- addmon = function()
- curitem = {}
- event,itmid = os.pullEvent("chat_command")
- itmid = tonumber(itmid)
- event,itmdmg = os.pullEvent("chat_command")
- itmdmg = tonumber(itmdmg)
- curitem = {id=itmid;dmg=itmdmg;}
- table.insert(monitems,curitem)
- end
- AEmon = function()
- if #monitems > 0 then
- AEbox = net.callRemote(glass,"addBox",10,10,#monitems*30,40,0x000000,0.7)
- for i = 1,#monitems do
- if i <= #montext then
- curdeltext = montext[i]
- curdeltext.delete()
- end
- curitem = monitems[i]
- curid = curitem.id
- curdmg = curitem.dmg
- monicons[i] = net.callRemote(glass,"addIcon",(30*i)-13,17,curid,curdmg)
- iteminsys = net.callRemote(ae,"countOfItemType",curid,curdmg)
- if iteminsys > 9999999999 then
- iteminsys = iteminsys/1000000000
- iteminsys = round(iteminsys, 4)
- iteminsys = iteminsys.."B"
- elseif iteminsys > 9999999 then
- iteminsys = iteminsys/1000000
- iteminsys = round(iteminsys, 4)
- iteminsys = iteminsys.."M"
- elseif iteminsys > 9999 then
- iteminsys = iteminsys/1000
- iteminsys = round(iteminsys, 4)
- iteminsys = iteminsys.."K"
- end
- montext[i] = net.callRemote(glass,"addText",(30*i)-20,40,iteminsys)
- end
- end
- end
- removemon = function()
- event, num = os.pullEvent()
- table.remove(monitems, num)
- delicon = monicons[num]
- delicon.delete()
- deltext = montext[num]
- deltext.delete()
- AEbox.delete()
- AEmon()
- end
- refresh = function()
- AEmon()
- end
- request = function()
- event, itmqty = os.pullEvent("chat_command")
- itmqty = tonumber(itmqty)
- event, itmid = os.pullEvent("chat_command")
- itmid = tonumber(itmid)
- event, itmdmg = os.pullEvent("chat_command")
- itmdmg = tonumber(itmdmg)
- reqitem = {id = itmid;dmg = itmdmg;qty = itmqty;}
- unavailable = itmqty - net.callRemote(ae,"countOfItemType",itmid,itmdmg)
- if unavailable > 0 then
- craft = reqitem
- craft[qty] = unavailable
- net.callRemote(ae,requestCrafting,craft)
- end
- net.callRemote(ae,"extractItem",reqitem,echest)
- end
- while true do
- os.startTimer(1)
- event,action = os.pullEvent()
- if event == "timer" then
- refresh()
- elseif action == "req" then
- request()
- elseif action == "addmon" then
- addmon()
- elseif action == "removemon" then
- removemon()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement