Posted 11 April 2014 - 06:51 AM
I'm hitting up Ask A Pro instead of the bug thread because I'm not sure if this is actually a bug, or something I'm doing wrong and I'm not sure how to proceed.
Assuming the following:
Output positioned at (termY/2)-1 (when in a CraftOS tab) sometimes seems to 'disappear'. I've had to hard code termY values in one of my programs because things randomly won't show up when using (termY/2)-1 in a tab.
The routine I'm using to draw everything is drawElement() (x,y = cursor pos, h = height, w = width)
Does anyone see something in my drawElement routine that would cause it to fail or weird-out with (termY/2)-1 vs. a hard value of '8' or '9' when running in a CraftOS tab?
Question part 'the second':
I'm also noticing that my readInput() function is behaving strangely in CraftOS tabs
In this case, feeding it (termY/2)-1 (while in a tab) causes the text it writes to the screen to be 1 line above the blinking cursor position.
So are my routines to blame for these problems or is there something in all of this I should take to the bug thread? And if so, how do I describe it so it makes sense?
If necessary I can provide a working program that demonstrates the problem, but it's a two piece setup that requires a turtle and an advanced wireless portable.
Apologies for the vague nature of my request - I'm rather stumped.
Assuming the following:
ComputerCraft 1.63pr1 (possibly earlier 1.6x versions)
Using an advanced wireless portable computer
termX,termY = term.getSize()
Output positioned at (termY/2)-1 (when in a CraftOS tab) sometimes seems to 'disappear'. I've had to hard code termY values in one of my programs because things randomly won't show up when using (termY/2)-1 in a tab.
The routine I'm using to draw everything is drawElement() (x,y = cursor pos, h = height, w = width)
Spoiler
local function drawElement(x,y,w,h,txColor,bgColor,text)
local deText,i = tostring(text)
term.setCursorPos(x,y)
term.setBackgroundColor(bgColor)
if w > #deText or h > 1 then -- We're 'drawing' something more than text
for i = 1,h,1 do --
term.write(string.rep(" ",w)) -- Draw the 'element' (box/rectangle/line-seg)
term.setCursorPos(x,y+i) --
end
end
if deText ~= "" and deText ~= "nil" then
term.setTextColor(txColor)
if w < #deText then w = #deText end -- Ensure minimum length
local xW = (x + w/2) - #deText/2 -- Center the text horizontally
local xH = y + h/2 -- Center the text vertically
term.setCursorPos(xW,xH)
term.write(deText)
end
end
end
Does anyone see something in my drawElement routine that would cause it to fail or weird-out with (termY/2)-1 vs. a hard value of '8' or '9' when running in a CraftOS tab?
Question part 'the second':
I'm also noticing that my readInput() function is behaving strangely in CraftOS tabs
Spoiler
local function readInput(cX,cY,cO) -- cursor X,Y and color
local word = ""
local curX, curY = cX, cY
term.setTextColor(cO)
term.setCursorBlink(true)
term.setCursorPos(curX, curY)
while true do
local kEvent = { os.pullEvent() }
if kEvent[1] == "key" then
if kEvent[2] == keys.backspace then
if curX > cX then
curX = curX - 1
word = word:sub(1,#word-1)
end
drawElement(curX,curY,1,1,cO,black," ")
elseif kEvent[2] == keys.enter then
term.setCursorBlink(false)
return word
end
elseif kEvent[1] == "char" then
drawElement(curX,curY,1,1,cO,black,kEvent[2])
word = word .. kEvent[2]
curX = curX + 1
end
term.setCursorPos(curX, curY)
end
end
In this case, feeding it (termY/2)-1 (while in a tab) causes the text it writes to the screen to be 1 line above the blinking cursor position.
So are my routines to blame for these problems or is there something in all of this I should take to the bug thread? And if so, how do I describe it so it makes sense?
If necessary I can provide a working program that demonstrates the problem, but it's a two piece setup that requires a turtle and an advanced wireless portable.
Apologies for the vague nature of my request - I'm rather stumped.
Edited on 11 April 2014 - 07:25 AM