ScriptDocumentクラス

クラスInstance.newでは作れない日本語解説は準備中

ひとことで言うと

ScriptDocumentは、ロブロックス(Roblox)のクラスです。くわしい日本語解説は準備中のため、下に公式の説明(英語)を載せています。

公式の説明(英語):Represents the ephemeral state of an open document in the Studio Script Editor, providing APIs for reading and editing code.

クラスの関係

受け継いでいるクラス:Object → Instance → ScriptDocument

メソッド(21)

名前と書き方説明
AddReadOnlyReasonsAsync
ScriptDocument:AddReadOnlyReasonsAsync(reasons: Array): ()
Adds reasons for the Script Editor UI to be read-only. Yields the current thread until the editor acknowledges the change.
CloseAsync
ScriptDocument:CloseAsync(): Tuple
Requests that the editor associated with this document close. Yields the current thread until the editor responds to the request.
EditTextAsync
ScriptDocument:EditTextAsync(newText: string, startLine: int, startCharacter: int, endLine: int, endCharacter: int): Tuple
Replaces the text in the specified range from (startLine, startColumn) to (endLine, endColumn) with newText.
ForceSetSelectionAsync
ScriptDocument:ForceSetSelectionAsync(cursorLine: int, cursorCharacter: int, anchorLine: int?, anchorCharacter: int?): Tuple
Asks the editor to set its cursor selection to the argument values.
GetLine
ScriptDocument:GetLine(lineIndex: int?): string
Returns the text of the specified line. When no argument is provided, returns the line of the current cursor position.
GetLineCount
ScriptDocument:GetLineCount(): int
Returns the number of lines in the document.
GetReadOnlyReasons
ScriptDocument:GetReadOnlyReasons(): List<string>
Returns the reasons the Script Editor UI is currently read-only.
GetScript
ScriptDocument:GetScript(): LuaSourceContainer
Returns the underlying LuaSourceContainer instance, if one exists, otherwise nil.
GetSelectedText
ScriptDocument:GetSelectedText(): string
Gets the text selected in the editor, or an empty string if there is no selection.
GetSelection
ScriptDocument:GetSelection(): Tuple
Returns the last known selection of the Script Editor in the format: CursorLine, CursorChar, AnchorLine, AnchorChar. If the Script Editor has no selection, CursorLine == AnchorLine and CursorChar == AnchorChar.
GetSelectionEnd
ScriptDocument:GetSelectionEnd(): Tuple
Gets the larger of the cursor position and anchor. If the editor has no selection, they are the same value.
GetSelectionStart
ScriptDocument:GetSelectionStart(): Tuple
Gets the smaller of the cursor position and anchor. If the editor has no selection, they are the same value.
GetText
ScriptDocument:GetText(startLine: int?, startCharacter: int?, endLine: int?, endCharacter: int?): string
Returns text from the open editor.
GetViewport
ScriptDocument:GetViewport(): Tuple
Returns the currently displayed line numbers in the editor change.
HasSelectedText
ScriptDocument:HasSelectedText(): boolean
Returns whether or not the editor has any text selected.
IsCommandBar
ScriptDocument:IsCommandBar(): boolean
Returns true if the ScriptDocument represents the Command bar.
IsReadOnly
ScriptDocument:IsReadOnly(): boolean
Returns true if the Script Editor UI is currently read-only.
MultiEditTextAsync
ScriptDocument:MultiEditTextAsync(edits: Array): Tuple
Applies a batch of text edits to the document as a single atomic operation. Yields the current thread until the editor responds.
RemoveReadOnlyReasonsAsync
ScriptDocument:RemoveReadOnlyReasonsAsync(reasons: Array): ()
Removes reasons for the Script Editor UI to be read-only. Yields the current thread until the editor acknowledges the change.
RequestSetSelectionAsync
ScriptDocument:RequestSetSelectionAsync(cursorLine: int, cursorCharacter: int, anchorLine: int?, anchorCharacter: int?): Tuple
Asks the editor to set its cursor selection to the argument values.
ReviewableTextEditsAsync
ScriptDocument:ReviewableTextEditsAsync(changes: Array): Tuple
Applies a batch of line-based text edits that appear in the editor as reviewable inline diffs, allowing users to accept or reject each change.

イベント(2)

名前と書き方説明
SelectionChanged
ScriptDocument.SelectionChanged(positionLine: int64, positionCharacter: int64, anchorLine: int64, anchorCharacter: int64)
Fires when the ScriptDocument changes, including immediately after a text change.
ViewportChanged
ScriptDocument.ViewportChanged(startLine: int64, endLine: int64)
Fires when the displayed line numbers in the editor change.

受け継いでいるメンバー

Instance から受け継いでいるもの(46)

Archivable・Capabilities・IsInSandbox・Name・Parent・PredictionMode・Sandboxed・AddTag・ClearAllChildren・Clone・Destroy・FindFirstAncestor・FindFirstAncestorOfClass・FindFirstAncestorWhichIsA・FindFirstChild・FindFirstChildOfClass・FindFirstChildWhichIsA・FindFirstDescendant・GetActor・GetAttribute・GetAttributeChangedSignal・GetAttributes・GetChildren・GetDebugId・GetDescendants・GetFullName・GetStyled・GetStyledPropertyChangedSignal・GetTags・HasTag・IsAncestorOf・IsDescendantOf・IsPropertyModified・QueryDescendants・RemoveTag・ResetPropertyToDefault・SetAttribute・WaitForChild・AncestryChanged・AttributeChanged・ChildAdded・ChildRemoved・DescendantAdded・DescendantRemoving・Destroying・StyledPropertiesChanged

Object から受け継いでいるもの(4)

ClassName・GetPropertyChangedSignal・IsA・Changed

英語の説明とメンバーの一覧は、Roblox Creator Documentation(ScriptDocument)をもとにしています(CC BY 4.0)。日本語の解説は、このサイトで独自に書いたものです。

執筆:鈴木孝昌官公庁のWeb・システム開発を担当する現役プロジェクトマネージャー。沖縄マイクラ部 クロスウェーブで、ロブロックス(Roblox)・マインクラフト(マイクラ)・Scratchなどのプログラミングを指導。マイクラカップ沖縄代表チームを指導(第6回・第7回、第7回TBS賞)。
沖縄マイクラ部で、子どもたちにロブロックス(Roblox)やマインクラフト(マイクラ)のプログラミングを教えています。プロフィールと編集方針
Instagramで教室の様子を見る
noteで記事を読む