Panakotta00 / FicsIt-Networks

Control, Monitor, Manage and Automate your Satisfactory.
https://ficsit.app/mod/FicsItNetworks
GNU General Public License v3.0
157 stars 51 forks source link

Crash to Desktop when running the Plot Example code to two monitors without delay in loop #150

Closed Braindrift closed 3 years ago

Braindrift commented 3 years ago

SMMDebug_2021-8-17_0-52-33.zip

Random crash when running the Random Plot Example on two screens. Had just removed the event.pull(0.05) from the while loop and closed down the computer interface. Took a second then it crashed.

anotherFile = "another.lua"
fs = filesystem
fs.doFile(anotherFile)

local gpu = computer.getPCIDevices(findClass("GPUT1"))[1]
local internalScreen = computer.getPCIDevices(findClass("FINComputerScreen"))[1]
local largeScreen = component.proxy("259D11FB49941D435A803CB9A61FC299")

data = {0}

function initScreen(screen)
    gpu:bindScreen(screen)
    w,h = gpu:getSize()
    gpu:setBackground(0,0,0,0)
    gpu:fill(0,0,w,h," ")
    gpu:flush()
end

function getData(i)
    d = data[i]
    if not d then
        d = math.random(h)
        data[i] = d
    end
    return d
end

p = 0

initScreen(internalScreen)
initScreen(largeScreen)

function printScreen(screen)
    gpu:bindScreen(screen)
    gpu:setBackground(0,0,0,0)
    gpu:fill(0, 0, w, h,"")
    gpu:setBackground(1,1,1,1)
    for i = 0, w - 1, 1 do
        x = (p + i) / 10.0
        x1 = math.floor(x)
        x2 = x1 + 10
        y1 = getData(math.floor(x1))
        y2 = getData(math.floor(x2))
        d = y1 + ((x - x1) * ((y2 - y1) / (x2 - x1)))
        d = math.floor(d)
        gpu:setText(i, d, " ")
    end
    gpu:flush()
end

while true do
    printScreen(internalScreen)
    printScreen(largeScreen)
    p = p + 1
end
Panakotta00 commented 3 years ago

If the issues still persists, Feeld free to reopen the issue