Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local aes = 2
- local produce = 32768
- local modemSide = "front"
- maxenergy = produce*aes
- rednet.open(modemSide)
- function convertNBT(nbt)
- local conv = {}
- if (nbt == nil) then
- return nil
- elseif (nbt["type"] == "NBTTagCompound") or (nbt["type"] == "NBTTagList") then
- for key, value in pairs(nbt["value"]) do
- conv[key] = convertNBT(value)
- end
- else
- conv = nbt["value"]
- end
- return conv
- end
- function getNBT(side)
- local pipe = peripheral.wrap(side)
- pipe.getAvailableItems()
- local event, items = os.pullEvent("available_items_return")
- return convertNBT(pipe.getNBTTagCompound(items[1][1]))
- end
- function messure()
- rs.setOutput("bottom",true)
- sleep(.5)
- rs.setOutput("bottom",false)
- sleep(.5)
- return getNBT("right")
- end
- function calculate()
- count = 0
- while true do
- if count > 0 then
- local nbt = messure()
- i2 = nbt["lastTotalEnergyEmitted"]
- t2 = nbt["lastMeasureTime"]
- local i = (i2 - i1)
- local t = (t2 - t1)
- print("Energie: "..i/t.."eu/t")
- print("MaxEnergie: "..maxenergy)
- print("å9Cberfluss: "..maxenergy-(i/t))
- pkg = {}
- table.insert(pkg,i/t)
- --table.insert(pkg,maxenergy)
- rednet.broadcast(textutils.serialize(pkg))
- count = 0
- else
- local nbt = messure()
- i1 = nbt["lastTotalEnergyEmitted"]
- t1 = nbt["lastMeasureTime"]
- count = 1
- end
- end
- end
- calculate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement