CC: Tweaked

CC: Tweaked

59M Downloads

[BUG] Incorrect Display on Screen after Number Rounding

kamitojaeger opened this issue ยท 0 comments

commented

Minecraft Version

1.18.x

Version

1.101.2

Details

I have encountered a bug while using the CC Computer mod. I have written a program that monitors the total quantity of items in a chest and continuously prints it on a monitor screen at a fixed position. The code implementation is as follows:

lua
Copy code
local chest = peripheral.wrap("back")
local monitor = peripheral.wrap("monitor")
local sum = 0

while true do
for slot, item in pairs(chest.list()) do
sum = sum + item.count
end

monitor.setCursorPos(1, 5)
monitor.write()
monitor.write("Gun_1:")
monitor.write(sum)
sum = 0
sleep(0.1)
end
In the code above, I used monitor.write() to clear the content at position (1,5) on the screen and then printed the subsequent "Gun_1:" and "sum" values. At this point, if I don't round the variable sum and display it as a decimal, the monitor display works correctly.

However, as soon as I round the sum variable to an integer using any method, and then display the rounded value on the monitor, the display becomes incorrect.

For example, when the displayed value transitions from a four-digit number to a three-digit number or from a three-digit number to a two-digit number, the following issue occurs:

Original: 128

After removing 64 items, the displayed content should become 64. However, in reality, the displayed content becomes 648.

The last digit of the previous three-digit number does not disappear from the screen. If I break and replace the monitor block, forming a complete monitor screen again, the display content becomes normal, showing 64. It seems that there is a problem with the screen refresh.