From ComputerCraft Wiki
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Function window.setVisible |
A function available to window-based terminal objects created via the window API, which toggles the visibility flag of the window in concern.
You may still alter the content of an invisible window, though the changes will only be displayed when the window is next rendered. If a window's parent is invisible, then that window is also treated as invisible.
Note that toggling visibility of a window to false will NOT "undraw" it; its content will still remain within any parent terminal objects until they are cleared via other means, as anything rendered in a given window is rendered via said parents. However, if toggling from false to true, the window will be automatically redrawn (though whether it'll actually show up on the screen again at that point depends on the visibility of its parents at the time). |
Syntax |
window.setVisible(boolean visible) |
Returns |
None |
Part of |
ComputerCraft |
API |
term |
Examples
Example |
Defines two windows at the top left of the display, then alternates their visibility until terminated (Ctrl + T). |
Code |
term.clear()
local window1 = window.create(term.current(), 1, 1, 2, 1)
local window2 = window.create(term.current(), 1, 1, 2, 1)
window1.setVisible(false)
window2.setVisible(false)
window1.write("):")
window2.write(":)")
while true do
window2.setVisible(false)
window1.setVisible(true)
sleep(0.5)
window1.setVisible(false)
window2.setVisible(true)
sleep(0.5)
end
|