Window API

Functionwindow.create
Create a new Window Object.
Syntax window.create(
  • term : table
  • x : number
  • y : number
  • width : number
  • height : number
  • visible? : boolean
)
Returns table window
Part of CC:Tweaked (source)
API window
ExampleCreate a Window
Create a Window
Code
<nowiki>
local win = window.create(term.current(),1,1,10,10)
win.write("Hello World")
  </nowiki>
Functionwindow.getPosition
Returns the Position of a Window.
Syntax window.getPosition()
Returns number x number y
Part of CC:Tweaked (source)
API window
ExampleGet the Position of a Window
Get the Position of a Window and print it.
Code
<nowiki>
local win = window.create(term.current(),1,1,10,10)
print(win.getPosition())
  </nowiki>
Output
1 1
Functionwindow.redraw
Redraw a Window.
Syntax window.redraw()
Part of CC:Tweaked (source)
API window
ExampleRedraw a Window
Redraw a Window
Code
<nowiki>
local win = window.create(term.current(),1,1,10,10)
win.redraw()
  </nowiki>
Functionwindow.reposition
Moves and optional resizes a window.
Syntax window.reposition(
  • x : number
  • y : number
  • width? : number
  • height? : number
)
Returns nil
Part of CC:Tweaked (source)
API window
ExampleMove a Window
Move a Window
Code
<nowiki>
local win = window.create(term.current(),1,1,10,10)
win.reposition(5,5)
  </nowiki>
Functionwindow.restoreCursor
Returns the Cursor back to a Window.
Syntax window.restoreCursor()
Returns nil
Part of CC:Tweaked (source)
API window
ExampleRestore the Cursor
Restore the Cursor
Code
<nowiki>
local win = window.create(term.current(),1,1,10,10)
win.restoreCursor()
  </nowiki>
Functionwindow.setVisible
Change the visibility of a window.
Syntax window.setVisible(
  • visible : boolean
)
Returns nil
Part of CC:Tweaked (source)
API window
ExampleHide a Window
Hide a Window
Code
<nowiki>
local win = window.create(term.current(),1,1,10,10)
win.write("This Text will disappear in 5 seconds")
sleep(5)
win.setVisible(false)
  </nowiki>
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.