sandalle / minecraft_bigreactor_control

Minecraft BigReactor Computercraft Control Program
MIT License
76 stars 41 forks source link

Does not fit in a 3x2 screen #68

Closed emp3d closed 8 years ago

emp3d commented 8 years ago

http://imgur.com/LBpJgJt

This should say enough.

sandalle commented 8 years ago

What version of of the script? What version of ComputerCraft? Minecraft? It's working here on NST: Maxx with ComputerCraft 1.63 and Minecraft 1.6.4.

emp3d commented 8 years ago

On minecraft 1.7.10 and computercraft 1.74. It is not this program its fault. Every program that uses monitors are too big for the supposed screen size.

Slacker101 commented 8 years ago

Any idea why this is happening or how we can fix it? I'm having this really annoying problem as well. Basically makes monitors worthless.

Never mind, I figured out a workaround.

sandalle commented 8 years ago

Sounds like at some point monitor.setTextScale(number scale) was called (see http://www.computercraft.info/wiki/Term_%28API%29).

For each monitor, I set monitor.setTextScale(1.0) to work around other programs changing scaling features.

@Slacker101 , mind posting your work-around for others, such as @emp3d ? :) If it's something that I can fix in the code, at least for ComputerCraft (CC) 1.74, then I can make a new release for that. I don't have CC 1.74 on any of the modpacks that I'm currently using.

emp3d commented 8 years ago

My work-around is more screens.

Slacker101 commented 8 years ago

Does more screens actively fix it? I haven't tried that honestly.I just have one reactor currently so I only wanted two screens.

The right arrow button for selecting monitors also seems to be broken in 1.7.4, I haven't had a chance to look into it and fix it yet though.

@sandalle it actually is a bug with the monitor going half inactive from what I've read on their form. For some reason they lose what size they actually are. The owner of computercraft has been supposed to fix it since last July but hasn't yet. The fix is actually using setTextScale() to a value and then back. I added it here in the findmonitors method where it sets the text scale to 1 as default. Setting it to 2 and then 1 causes the monitors to reset and realize their size. It flickers a bit while the script iterates through the method on startup and when it updates periodically but honestly I haven't looked for a better way because it doesn't bother me. Makes it seem like an old vacuum tube set heating up.

-- Then initialize the monitors
local function findMonitors()
    -- Empty out old list of monitors
    monitorList = {}

    printLog("Finding monitors...")
    monitorList, monitorNames = getDevices("monitor")

    if #monitorList == 0 then
        printLog("No monitors found, continuing headless")
    else
        for monitorIndex = 1, #monitorList do
            local monitor, monitorX, monitorY = nil, nil, nil
            monitor = monitorList[monitorIndex]

            if not monitor then
                printLog("monitorList["..monitorIndex.."] in findMonitors() is NOT a valid monitor.")

                table.remove(monitorList, monitorIndex) -- Remove invalid monitor from list
                if monitorIndex ~= #monitorList then    -- If we're not at the end, clean up
                    monitorIndex = monitorIndex - 1 -- We just removed an element
                end -- if monitorIndex == #monitorList then
                break -- Invalid monitorIndex
            else -- valid monitor
                monitor.setTextScale(2)
                monitor.setTextScale(1.0) -- Make sure scale is correct
                monitorX, monitorY = monitor.getSize()

                if (monitorX == nil) or (monitorY == nil) then -- somehow a valid monitor, but non-existent sizes? Maybe fixes Issue #3
                    printLog("monitorList["..monitorIndex.."] in findMonitors() is NOT a valid sized monitor.")

                    table.remove(monitorList, monitorIndex) -- Remove invalid monitor from list
                    if monitorIndex ~= #monitorList then    -- If we're not at the end, clean up
                        monitorIndex = monitorIndex - 1 -- We just removed an element
                    end -- if monitorIndex == #monitorList then
                    break -- Invalid monitorIndex

                -- Check for minimum size to allow for monitor.setTextScale(0.5) to work for 3x2 debugging monitor, changes getSize()
                elseif monitorX < 29 or monitorY < 12 then
                    term.redirect(monitor)
                    monitor.clear()
                    printLog("Removing monitor "..monitorIndex.." for being too small.")
                    monitor.setCursorPos(1,2)
                    write("Monitor is the wrong size!\n")
                    write("Needs to be at least 3x2.")
                    termRestore()

                    table.remove(monitorList, monitorIndex) -- Remove invalid monitor from list
                    if monitorIndex == #monitorList then    -- If we're at the end already, break from loop
                        break
                    else
                        monitorIndex = monitorIndex - 1 -- We just removed an element
                    end -- if monitorIndex == #monitorList then

                end -- if monitorX < 29 or monitorY < 12 then
            end -- if not monitor then

            printLog("Monitor["..monitorIndex.."] named \""..monitorNames[monitorIndex].."\" is a valid monitor of size x:"..monitorX.." by y:"..monitorY..".")
        end -- for monitorIndex = 1, #monitorList do
    end -- if #monitorList == 0 then

    printLog("Found "..#monitorList.." monitor(s) in findMonitors().")
end -- local function findMonitors()
sandalle commented 8 years ago

Thank you, @Slacker101 , I'll test that locally and then put out an update. Sorry for the delays, been busy with the holiday and switching employers.

sandalle commented 8 years ago

This fix will be in the next release, 0.3.18, sorry for the delay and thank you for the proposed fix. :)