Difference between revisions of "Term.native"
From ComputerCraft Wiki
Bomb Bloke (Talk | contribs) (As of ComputerCraft 1.6, term.native now points to a function, not a table.) |
|||
Line 2: | Line 2: | ||
{{Function | {{Function | ||
|name=term.native | |name=term.native | ||
− | |returns=The term table | + | |returns=The original [[Term (API)|"term" table]]. |
|api=term | |api=term | ||
|addon=ComputerCraft | |addon=ComputerCraft | ||
− | |desc= | + | |desc=Prior to ComputerCraft 1.6, "term.native" is a table pointer leading to the original "term" table (that is to say, the basic "term" API used to render to a given computer's own display). In cases where scripts have [[term.redirect|term.redirect()ed]] to an alternate display (eg a [[monitor]]), generally [[term.restore|term.restore()]] can be used to switch back, but depending on the amount of redirects performed that may not lead to the ''original'' terminal with a single call - use of '''term.redirect(term.native)''' will generally hop back in one go.<br><br> |
+ | |||
+ | As of ComputerCraft 1.6, term.native is no longer a table but a ''function pointer'', which must be ''called'' in order to receive the desired table back - for eg, '''term.redirect(term.native())''' should be expected to return the the default display. Bear in mind that in most cases, you'll want to restore to whatever display you ''originally redirected from'' - [[term.current|term.current()]] can be used to help track that.<br><br> | ||
+ | |||
+ | Note that this change breaks backwards compatibility with scripts that assume term.native's prior identity.<br><br> | ||
+ | |||
+ | See also: [[term.current|term.current()]], [[term.redirect|term.redirect()]], [[term.restore|term.restore()]] | ||
|examples= | |examples= | ||
{{Example | {{Example | ||
− | |desc= | + | |desc=For pre-ComputerCraft 1.6, writes to the default display even if the terminal is currently redirected elsewhere. |
− | + | |code=term.native.write("I should appear on the computer's native display.") | |
− | |code=term.native.write(" | + | }} |
+ | {{Example | ||
+ | |desc=For ComputerCraft 1.6 or later, writes to the default display even if the terminal is currently redirected elsewhere. | ||
+ | |code=term.native().write("I should appear on the computer's native display.") | ||
}} | }} | ||
|notes= | |notes= |
Revision as of 06:07, 4 April 2014
Function term.native | |
Prior to ComputerCraft 1.6, "term.native" is a table pointer leading to the original "term" table (that is to say, the basic "term" API used to render to a given computer's own display). In cases where scripts have term.redirect()ed to an alternate display (eg a monitor), generally term.restore() can be used to switch back, but depending on the amount of redirects performed that may not lead to the original terminal with a single call - use of term.redirect(term.native) will generally hop back in one go. As of ComputerCraft 1.6, term.native is no longer a table but a function pointer, which must be called in order to receive the desired table back - for eg, term.redirect(term.native()) should be expected to return the the default display. Bear in mind that in most cases, you'll want to restore to whatever display you originally redirected from - term.current() can be used to help track that. Note that this change breaks backwards compatibility with scripts that assume term.native's prior identity. | |
Syntax | term.native() |
Returns | The original "term" table. |
Part of | ComputerCraft |
API | term |
Examples
Example | |
For pre-ComputerCraft 1.6, writes to the default display even if the terminal is currently redirected elsewhere. | |
Code |
term.native.write("I should appear on the computer's native display.") |