Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Init program
- os.loadAPI("ocs/apis/graph")
- os.loadAPI("ocs/apis/sensor")
- rednetSide = "right"
- sensorSide = "back"
- idScreenPC = 20
- dataSend = {}
- mfsuList = {}
- function getMFSU()
- mfsuList = {}
- targetNameSelect = {}
- targetNames = sensor.call(sensorSide, "getTargets")
- if targetNames then
- -- Adding all targets in the temp list
- for k, value in pairs(targetNames) do
- table.insert(targetNameSelect, k)
- end
- table.sort(targetNameSelect)
- -- Adding a target in the mfsu list when the name is "MFSU"
- infoTable = {}
- for i = 1, #targetNameSelect do
- infoTable = sensor.call(sensorSide, "getTargetDetails", targetNameSelect[i])
- if infoTable ~= nil then
- for k, v in pairs(infoTable) do
- if k == "Name" and v == "MFSU" then
- table.insert(mfsuList, infoTable)
- end
- end
- end
- end
- end
- end
- rednet.open(rednetSide)
- -- Main loop
- while true do
- term.clear()
- id, msg, d = rednet.receive(0.5)
- if id ~= nil and id == idScreenPC then
- if msg ~= nil then
- action = textutils.unserialize(msg)
- if action["button"] ~= nil then
- if action.button == "on_lava" then
- rs.setBundledOutput("left", 1)
- print("1")
- elseif action.button == "off_lava" then
- rs.setBundledOutput("left", 0)
- print("0")
- end
- end
- rednet.send(id, "ok")
- end
- end
- -- Getting information sensor
- getMFSU()
- for i = 0, (#mfsuList - 1) do
- dataSend[i] = {}
- j = i + 1
- dataSend[i]["p"] = tonumber(mfsuList[j]["StoredPercentage"])
- dataSend[i]["e"] = tonumber(mfsuList[j]["EnergyEmitted"])
- end
- -- Message sending
- msgSend = textutils.serialize(dataSend)
- rednet.send(idScreenPC, msgSend)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement