Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modem_Side = "front"
- local deployer_Side = "right"
- local pipe_Side = "bottom"
- local messure_speed = 10
- print("Computer ID: " .. os.getComputerID())
- rednet.open(modem_Side)
- 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")
- for k,v in pairs(items) do
- id = pipe.getItemID(v[1])
- if id == 30182 then
- local nbt = convertNBT(pipe.getNBTTagCompound(v[1]))
- if (nbt ~= nil) then
- return nbt
- end
- end
- end
- sleep(messure_speed)
- return getNBT(side)
- end
- function messure()
- rs.setOutput(deployer_Side,true)
- sleep(.5)
- rs.setOutput(deployer_Side,false)
- sleep(.5)
- return getNBT(pipe_Side)
- 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")
- pkg = {}
- table.insert(pkg,i/t)
- rednet.broadcast(textutils.serialize(pkg))
- count = 0
- else
- sleep(messure_speed)
- 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