Skip to main content

Script Editor

Functions for interacting with scripts and the script editor.

Functions

TypeName
voidvrAbortScript(string name)
Aborts a suspended script.
booleanvrInCoroutine(string script)
Executes the specified piece of Lua in a coroutine.
booleanvrIsEditableScriptNode(vrnode node)
Returns true if the supplied node contains a script property supported by the script editor.
tablevrListSleepingScripts(boolean details =false)
Lists the scripts currently suspended, awaiting resume.
voidvrRevertToCleanState()
Restores the captured state of the Lua global environment.
voidvrScriptEditorAppendText(string text)
Inserts text into the currently visible script editor tab and advances the insert cursor position.
voidvrScriptEditorClearOutput()
Clears the script editor output.
voidvrScriptEditorCopySelection()
Copies the selected text in the currently visible script editor tab to the clipboard.
voidvrScriptEditorCutSelection()
Copies the selected text in the currently visible script editor tab to the clipboard and then erases it.
voidvrScriptEditorDeleteBackwards()
Deletes a single character from behind the insertion point in the currently visible script editor tab and steps the cursor backwards (backspace behaviour)
voidvrScriptEditorDeleteForwards()
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)
voidvrScriptEditorDeleteSelection()
Deletes the selected text from the currently visible script editor tab.
numbervrScriptEditorFind(string text, number pos)
Finds some text in the currently visible script editor tab.
numbervrScriptEditorGetCurrentLine()
Returns the current line number (zero based) in the currently visible script editor tab.
numbervrScriptEditorGetInsertPos()
Gets the text insert cursor position in the currently visible script editor tab.
numbervrScriptEditorGetMarkPos()
Gets the text mark cursor position in the currently visible script editor tab.
voidvrScriptEditorInsertText(string text)
Inserts text into the currently visible script editor tab.
voidvrScriptEditorPasteCopyBuffer()
Reads the clipboard, translates the contents and inserts them at the insertion point in the currently visible script editor tab.
voidvrScriptEditorSelectAll()
Selects all the text in the currently visible script editor tab.
voidvrScriptEditorSelectWord()
Selects the word surrounding the current insertion point in the currently visible script editor tab.
voidvrScriptEditorSetCurrentLine(number lineNo)
Set the cursor at the start of the specified line in the currently visible script editor tab.
voidvrScriptEditorSetInsertAtMousePos()
Places the text insert cursor in the currently visible script editor tab underneath the mouse cursor.
voidvrScriptEditorSetInsertPos(number pos)
Sets the text insert cursor position in the currently visible script editor tab.
voidvrScriptEditorSetMarkPos(number pos)
Sets the text mark cursor position in the currently visible script editor tab. This is for highlighting text.
voidvrSetAppQuitHook(string luaFunc)
Specify a lua function to be called when user tries to quit the application.
voidvrSetScriptIdentifier(string name)
Sets an identifier for the Lua execution.
voidvrSetScriptTimeout(number time)
Overrides the default Lua timeout for scripts, until the next script event is triggered.
voidvrYield(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