Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back")
- local fuelID = 0
- local tempID = 0
- local shieldID = 0
- local energyID = 0
- local maxShield = 7
- local maxEnergy = 5
- --- do not edit after this line ---
- local _exit = false
- --if fuelID <= 0 or tempID <= 0 or shieldID <=0 or energyID <=0 then
- -- print("Bitte konfiguriere die Computer ID's")
- -- _exit = true
- --end
- local fuel = 0
- local temp = 0
- local shield = 0
- local energy = 0
- local monitorLeft = peripheral.wrap("left")
- local monitorRight = peripheral.wrap("right")
- local monitorTop = peripheral.wrap("top")
- function receive()
- while not _exit do
- ID, msg = rednet.receive()
- if ID == tempID then
- temp = msg
- elseif ID == fuelID then
- fuel = msg
- elseif ID == shieldID then
- shield = msg
- elseif ID == energyID then
- energy = msg
- end
- sleep(.1)
- end
- end
- function _print()
- while not _exit do
- monitorTop.clear()
- monitorTop.setCursorPos(1,1)
- monitorTop.write("Fuel : " .. tostring(math.floor((100/15)*fuel)) .. "%")
- monitorTop.setCursorPos(1,2)
- monitorTop.write("Temperatur: " .. tostring(math.floor((100/15)*temp)) .. "%")
- monitorTop.setCursorPos(1,3)
- monitorTop.write("Shield : " .. tostring(math.floor((100/15)*shield)) .. "%")
- monitorTop.setCursorPos(1,4)
- monitorTop.write("Energy : " .. tostring(math.floor((100/15)*energy)) .. "%")
- monitorTop.setCursorPos(1,5)
- monitorTop.write("-----------------------------")
- sleep(.1)
- end
- end
- function _color()
- while not _exit do
- monitorLeft.clear()
- monitorRight.clear()
- monitorLeft.setCursorPos(1,2)
- monitorRight.setCursorPos(1,2)
- if shield <= maxShield then
- monitorLeft.setBackgroundColor(colors.red)
- else
- monitorLeft.setBackgroundColor(colors.lime)
- end
- if energy <= maxEnergy then
- monitorRight.setBackgroundColor(colors.red)
- else
- monitorRight.setBackgroundColor(colors.lime)
- end
- monitorLeft.write("Shield")
- monitorRight.write("Energy")
- monitorLeft.setCursorPos(1,3)
- monitorRight.setCursorPos(1,3)
- monitorLeft.write(tostring(math.floor((100/15)*shield)).."%")
- monitorRight.write(tostring(math.floor((100/15)*energy)).."%")
- sleep(.1)
- end
- end
- function _exitScript()
- local event, key = os.pullEvent( "key" ) -- limit os.pullEvent to the 'key' event
- if key == keys.e then -- if the key pressed was 'e'
- print("Script Stopped")
- _exit = true
- end
- return true
- end
- print( "Press E to exit Script." )
- while not _exit do
- parallel.waitForAny(receive, _print, _color, _exitScript)
- sleep(.1)
- end
- rednet.close("back")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement