Posted 16 February 2017 - 07:38 PM
When I run the program, it runs fine, but after about 10 seconds, the monitor starts going crazy. The colors in the rectangle change color. After that, in the next 20 seconds, the game crashes.
Since my english it very good :D/>, I will post a video instead. That will hopefully explain, what is going on. In the video, the flickering is small compared to the flickering I usually get.
VideoURL: https://youtu.be/XVlwCspR2tk
CODE:
Since my english it very good :D/>, I will post a video instead. That will hopefully explain, what is going on. In the video, the flickering is small compared to the flickering I usually get.
VideoURL: https://youtu.be/XVlwCspR2tk
CODE:
Spoiler
showRF <FramesPerSecond>
args = {...}
monitor = peripheral.wrap("top")
monitor.setTextScale(0.5)
monitor.setBackgroundColor(colors.black)
monitor.clear()
wirelessModem = peripheral.wrap("bottom")
wirelessModem.open(0)
rednet.open("bottom")
energyCell = peripheral.wrap("front")
running = true
fps = args[1]
screenSizeX, screenSizeY = monitor.getSize()
function drawPoint(x, y, color)
-- returnState = monitor.getBackgroundColor()
monitor.setCursorPos(x, y)
monitor.setBackgroundColor(color)
monitor.write(" ")
-- monitor.setBackgroundColor(returnState)
end
function drawRect(minX, maxX, minY, maxY, backgroundColor, borderColor)
returnState = monitor.getBackgroundColor()
for i = minX, maxX do
for j = minY, maxY do
if i == minX or i == maxX or j == minY or j == maxY then
drawPoint(i, j, borderColor)
else
drawPoint(i, j, backgroundColor)
end
end
end
monitor.setBackgroundColor(returnState)
end
function draw()
monitor.setBackgroundColor(colors.black)
monitor.clear()
drawRect(3, screenSizeX - 3, 3, screenSizeY - 3, colors.green, colors.blue)
drawRect(4, screenSizeX - 4, 4, screenSizeY - 4, colors.purple, colors.purple)
drawRect(4, 3 + math.floor((screenSizeX - 9) * energyCell.getEnergyStored() / energyCell.getMaxEnergyStored()), 4, screenSizeY - 4, colors.red, colors.red)
monitor.setCursorPos(1, 1)
monitor.setBackgroundColor(colors.black)
monitor.write("Enegry Stored: " .. energyCell.getEnergyStored())
monitor.setCursorPos(1, 2)
monitor.write("Energy Capacity: " .. energyCell.getMaxEnergyStored())
end
while true do
if peripheral.isPresent("front") then
draw()
rednet.broadcast(textutils.serialize({energyCell.getEnergyStored(), energyCell.getMaxEnergyStored(), true}), "EnergyCellEnergy")
os.startTimer(1 / fps)
os.pullEvent("timer")
else
rednet.broadcast(textutils.serialize({0, 0, false}), "EnergyCellEnergy")
end
end