Script Editor
Functions for interacting with scripts and the script editor.
Functions
| Type | Name |
|---|---|
| void | vrAbortScript(string name) Aborts a suspended script. |
| boolean | vrInCoroutine(string script) Executes the specified piece of Lua in a coroutine. |
| boolean | vrIsEditableScriptNode(vrnode node) Returns true if the supplied node contains a script property supported by the script editor. |
| table | vrListSleepingScripts(boolean details =false) Lists the scripts currently suspended, awaiting resume. |
| void | vrRevertToCleanState() Restores the captured state of the Lua global environment. |
| void | vrScriptEditorAppendText(string text) Inserts text into the currently visible script editor tab and advances the insert cursor position. |
| void | vrScriptEditorClearOutput() Clears the script editor output. |
| void | vrScriptEditorCopySelection() Copies the selected text in the currently visible script editor tab to the clipboard. |
| void | vrScriptEditorCutSelection() Copies the selected text in the currently visible script editor tab to the clipboard and then erases it. |
| void | vrScriptEditorDeleteBackwards() Deletes a single character from behind the insertion point in the currently visible script editor tab and steps the cursor backwards (backspace behaviour) |
| void | vrScriptEditorDeleteForwards() Deletes a single character at the insertion point in the currently visible script editor tab and leaves the insertion point where it is (delete behaviour) |
| void | vrScriptEditorDeleteSelection() Deletes the selected text from the currently visible script editor tab. |
| number | vrScriptEditorFind(string text, number pos) Finds some text in the currently visible script editor tab. |
| number | vrScriptEditorGetCurrentLine() Returns the current line number (zero based) in the currently visible script editor tab. |
| number | vrScriptEditorGetInsertPos() Gets the text insert cursor position in the currently visible script editor tab. |
| number | vrScriptEditorGetMarkPos() Gets the text mark cursor position in the currently visible script editor tab. |
| void | vrScriptEditorInsertText(string text) Inserts text into the currently visible script editor tab. |
| void | vrScriptEditorPasteCopyBuffer() Reads the clipboard, translates the contents and inserts them at the insertion point in the currently visible script editor tab. |
| void | vrScriptEditorSelectAll() Selects all the text in the currently visible script editor tab. |
| void | vrScriptEditorSelectWord() Selects the word surrounding the current insertion point in the currently visible script editor tab. |
| void | vrScriptEditorSetCurrentLine(number lineNo) Set the cursor at the start of the specified line in the currently visible script editor tab. |
| void | vrScriptEditorSetInsertAtMousePos() Places the text insert cursor in the currently visible script editor tab underneath the mouse cursor. |
| void | vrScriptEditorSetInsertPos(number pos) Sets the text insert cursor position in the currently visible script editor tab. |
| void | vrScriptEditorSetMarkPos(number pos) Sets the text mark cursor position in the currently visible script editor tab. This is for highlighting text. |
| void | vrSetAppQuitHook(string luaFunc) Specify a lua function to be called when user tries to quit the application. |
| void | vrSetScriptIdentifier(string name) Sets an identifier for the Lua execution. |
| void | vrSetScriptTimeout(number time) Overrides the default Lua timeout for scripts, until the next script event is triggered. |
| void | vrYield(number time =0.0) Yields the Lua execution back to the application for the (approximate) specified time. |
Functions Documentation
vrAbortScript
void vrAbortScript(
string name
)
Aborts a suspended script.
Parameters:
- name The name of the script (reported by vrListSleepingScripts)
vrInCoroutine
boolean vrInCoroutine(
string script
)
Executes the specified piece of Lua in a coroutine.
Parameters:
- script Lua code to execute
Return: true if the coroutine is started successfully
vrIsEditableScriptNode
boolean vrIsEditableScriptNode(
vrnode node
)
Returns true if the supplied node contains a script property supported by the script editor.
Parameters:
- node node to check
vrListSleepingScripts
table vrListSleepingScripts(
boolean details =false
)
Lists the scripts currently suspended, awaiting resume.
Parameters:
- details Whether to display additional details about each script
Return: Array of script identifiers
vrRevertToCleanState
void vrRevertToCleanState()
Restores the captured state of the Lua global environment.
vrScriptEditorAppendText
void vrScriptEditorAppendText(
string text
)
Inserts text into the currently visible script editor tab and advances the insert cursor position.
Parameters:
- text text to append
vrScriptEditorClearOutput
void vrScriptEditorClearOutput()
Clears the script editor output.
vrScriptEditorCopySelection
void vrScriptEditorCopySelection()
Copies the selected text in the currently visible script editor tab to the clipboard.
vrScriptEditorCutSelection
void vrScriptEditorCutSelection()
Copies the selected text in the currently visible script editor tab to the clipboard and then erases it.
vrScriptEditorDeleteBackwards
void vrScriptEditorDeleteBackwards()
Deletes a single character from behind the insertion point in the currently visible script editor tab and steps the cursor backwards (backspace behaviour)
vrScriptEditorDeleteForwards
void vrScriptEditorDeleteForwards()
Deletes a single character at the insertion point in the currently visible script editor tab and leaves the insertion point where it is (delete behaviour)
vrScriptEditorDeleteSelection
void vrScriptEditorDeleteSelection()
Deletes the selected text from the currently visible script editor tab.
vrScriptEditorFind
number vrScriptEditorFind(
string text,
number pos
)
Finds some text in the currently visible script editor tab.
Parameters:
- text text to find
- pos character position to start searching from
Return: The position of the first match
vrScriptEditorGetCurrentLine
number vrScriptEditorGetCurrentLine()
Returns the current line number (zero based) in the currently visible script editor tab.
vrScriptEditorGetInsertPos
number vrScriptEditorGetInsertPos()
Gets the text insert cursor position in the currently visible script editor tab.
vrScriptEditorGetMarkPos
number vrScriptEditorGetMarkPos()
Gets the text mark cursor position in the currently visible script editor tab.
vrScriptEditorInsertText
void vrScriptEditorInsertText(
string text
)
Inserts text into the currently visible script editor tab.
Parameters:
- text text to insert
vrScriptEditorPasteCopyBuffer
void vrScriptEditorPasteCopyBuffer()
Reads the clipboard, translates the contents and inserts them at the insertion point in the currently visible script editor tab.
vrScriptEditorSelectAll
void vrScriptEditorSelectAll()
Selects all the text in the currently visible script editor tab.
vrScriptEditorSelectWord
void vrScriptEditorSelectWord()
Selects the word surrounding the current insertion point in the currently visible script editor tab.
vrScriptEditorSetCurrentLine
void vrScriptEditorSetCurrentLine(
number lineNo
)
Set the cursor at the start of the specified line in the currently visible script editor tab.
Parameters:
- lineNo Line number
vrScriptEditorSetInsertAtMousePos
void vrScriptEditorSetInsertAtMousePos()
Places the text insert cursor in the currently visible script editor tab underneath the mouse cursor.
vrScriptEditorSetInsertPos
void vrScriptEditorSetInsertPos(
number pos
)
Sets the text insert cursor position in the currently visible script editor tab.
Parameters:
- pos Character position in the text
vrScriptEditorSetMarkPos
void vrScriptEditorSetMarkPos(
number pos
)
Sets the text mark cursor position in the currently visible script editor tab. This is for highlighting text.
Parameters:
- pos Character position in the text
vrSetAppQuitHook
void vrSetAppQuitHook(
string luaFunc
)
Specify a lua function to be called when user tries to quit the application.
Parameters:
- luaFunc Name of the Lua function. This function should return false if it wants to block the exit.
vrSetScriptIdentifier
void vrSetScriptIdentifier(
string name
)
Sets an identifier for the Lua execution.
Parameters:
- name Name to identify the current Lua execution
vrSetScriptTimeout
void vrSetScriptTimeout(
number time
)
Overrides the default Lua timeout for scripts, until the next script event is triggered.
Parameters:
- time Number of seconds to wait before timing out. A value of 0 means it never times out.
vrYield
void vrYield(
number time =0.0
)
Yields the Lua execution back to the application for the (approximate) specified time.
Parameters:
- time Number of seconds before resuming execution of this script, or 0 for one frame