Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local lComp=5 -- Lava sensor computer ID
- local lMax= 576000 -- Lava tank max capacity
- local crComp=6 -- Creosote sensor computer ID
- local crMax=576000 -- Creosote tank max capacity
- local oComp=8 -- Oil sensor computer ID
- local oMax=576000 -- Oil tank max capacity
- local fComp=7 -- Fuel sensor computer ID
- local fMax=576000 -- Fuel tank max capacity
- local monpos="left" -- Monitor position
- local modempos="back" -- Modem position
- local reqStr="DREQ" -- Data request keystring
- local dbgr=false -- Debug Mode
- local version="1.7" -- Version number, string in case of finer point releases
- print ("Remote Fluid Graph v"..version.."\nBy Shurhaian\n")
- mon=peripheral.wrap(monpos) -- Assign the monitor
- print ("Modem position: "..modempos.."\nMonitor position: "..monpos.."\n")
- rednet.open(modempos) -- Open Rednet
- if dbgr then
- print ("Rednet channel open")
- end
- local function callData(sensID) -- Generic sensor poller function
- myNet.send( reqStr, sensID ) -- Send the request string to the specified computer
- local msg,id=myNet.receive(1) -- Wait up to 1 full second for a reply
- if msg then return msg -- If a sensible value was received, return it
- else return 0 end -- Otherwise, just return 0
- end
- local function callLava()
- return callData(lComp)
- end
- local function callCreo()
- return callData(crComp)
- end
- local function callOil()
- return callData(oComp)
- end
- local function callFuel()
- return callData(fComp)
- end
- local nameTable={"Lava", "Creosote", "Oil", "Fuel"} -- Table of fluid names
- local callTable={callLava, callCreo, callOil, callFuel} -- Table of update functions
- local colorTable={{colors.orange},{colors.green},{colors.white},{colors.yellow}} -- Table of gradient "tables"
- local minTable={0, 0, 0, 0} -- Table of minimum values - always 0 (for now)
- local maxTable={lMax, crMax, oMax, fMax} -- Table of maximum values
- print ("Sensor computers:")
- print ("Lava : "..lComp)
- print ("Creosote oil : "..crComp)
- print ("Petroleum oil: "..oComp)
- print ("Refined fuel : "..fComp)
- local compID=os.getComputerID() -- Store local ID for next POST report
- print ("Running on computer: #"..compID.."\n")
- if dbgr then
- print ("Test polls: ")
- local testVal=callData(lComp) -- Fetch lava amount
- print ("Lava : "..testVal) -- Report lava
- testVal=callData(crComp) -- Fetch creosote amount
- print ("Creosote oil : "..testVal) -- Report creosote
- testVal=callData(oComp) -- Fetch oil amount
- print ("Petroleum oil: "..testVal) -- Report oil
- testVal=callData(fComp) -- Fetch fuel amount
- print ("Refined fuel : "..testVal) -- Report fuel
- else
- os.loadAPI("ocs/apis/graph")
- print ("Graph API loaded\n")
- graphInstance = graph.new(mon, callTable, nameTable, colorTable, minTable, maxTable, true) -- Graph declaration
- print ("Graph declared\n")
- print ("Now polling...")
- end
- while not dbgr do
- graphInstance:draw()
- sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement