요약
메서드
MultiEditTextAsync(edits: {any}):Tuple |
ReviewableTextEditsAsync(changes: {any}):Tuple |
이벤트
SelectionChanged(positionLine: number,positionCharacter: number,anchorLine: number,anchorCharacter: number):RBXScriptSignal |
ViewportChanged(startLine: number,endLine: number):RBXScriptSignal |
상속된 멤버
API 참조
메서드
CloseAsync
반환
코드 샘플
ScriptDocument:CloseAsync
--!nocheck
-- 다음 코드를 명령 바에서 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local documents = ScriptEditorService:GetScriptDocuments()
local scriptDocument
-- 첫 번째 열린 스크립트 문서를 찾습니다
for _, document in documents do
-- 명령 바는 닫을 수 없으므로 선택하지 마세요
if not document:IsCommandBar() then
scriptDocument = document
break
end
end
if scriptDocument then
local success, err = scriptDocument:CloseAsync()
if success then
print(`닫힘 {scriptDocument.Name}`)
else
warn(`닫기 실패 {scriptDocument.Name} 원인: {err}`)
end
else
print("열린 스크립트가 없습니다")
endEditTextAsync
ForceSetSelectionAsync
반환
코드 샘플
ScriptDocument:ForceSetSelectionAsync()
--!nocheck
-- 스크립트가 열려 있는 동안 Command Bar에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
-- 커서의 현재 줄에 있는 텍스트 가져오기
local cursorLine = scriptDocument:GetSelection()
local lineText = scriptDocument:GetLine(cursorLine)
-- 전체 줄의 텍스트 강제 선택
local success, err = scriptDocument:ForceSetSelectionAsync(cursorLine, 1, cursorLine, #lineText + 1)
if success then
print("선택이 설정되었습니다!")
else
print(`선택 설정 실패: {err}`)
end
else
print("열려 있는 스크립트가 없습니다")
endGetLine
매개 변수
| 기본값: "nil" |
반환
코드 샘플
ScriptDocument.SelectionChanged 및 ScriptDocument:GetLine()
--!nocheck
-- 스크립트가 열려 있는 동안 Command Bar에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
scriptDocument.SelectionChanged:Connect(function(positionLine, positionCharacter, anchorLine, anchorCharacter)
print(`선택됨: 줄 {positionLine}, 문자 {positionCharacter}`)
print(`앵커: 줄 {anchorLine}, 문자 {anchorCharacter}`)
local lineText = scriptDocument:GetLine(positionLine)
print(`선택된 줄 텍스트: {lineText}`)
end)
else
print("열려 있는 스크립트가 없습니다")
endGetLineCount
반환
코드 샘플
ScriptDocument:GetLineCount()
--!nocheck
-- 스크립트가 열려 있는 동안 Command Bar에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local lineCount = scriptDocument:GetLineCount()
print(`스크립트에는 {lineCount} 줄이 있습니다!`)
else
print("열려 있는 스크립트가 없습니다")
endGetScript
코드 샘플
ScriptDocument:GetScript()
--!nocheck
-- 스크립트가 열려 있는 동안 Command Bar에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local openScript = scriptDocument:GetScript()
print(`현재 열려 있는 스크립트: {openScript:GetFullName()}`)
else
print("열려 있는 스크립트가 없습니다")
endGetSelectedText
반환
코드 샘플
ScriptDocument:HasSelectedText() 및 :GetSelectedText()
--!nocheck
-- 스크립트가 열려 있는 동안 Command Bar에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
scriptDocument.SelectionChanged:Connect(function()
if scriptDocument:HasSelectedText() then
local selectedText = scriptDocument:GetSelectedText()
print(`현재 선택된 텍스트: {selectedText}`)
else
print("현재 선택된 텍스트가 없습니다")
end
end)
else
print("열려 있는 스크립트가 없습니다")
endGetSelectionEnd
반환
코드 샘플
ScriptDocument:GetSelectionStart() 및 :GetSelectionEnd()
--!nocheck
-- 스크립트가 열려 있는 동안 Command Bar에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local startLine, startCharacter = scriptDocument:GetSelectionStart()
local endLine, endCharacter = scriptDocument:GetSelectionEnd()
print(`Selection start: Line {startLine}, Char {startCharacter}`)
print(`Selection end: Line {endLine}, Char {endCharacter}`)
else
print("열려 있는 스크립트가 없습니다")
endGetSelectionStart
반환
코드 샘플
ScriptDocument:GetSelectionStart() 및 :GetSelectionEnd()
--!nocheck
-- 스크립트가 열려 있는 동안 Command Bar에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local startLine, startCharacter = scriptDocument:GetSelectionStart()
local endLine, endCharacter = scriptDocument:GetSelectionEnd()
print(`Selection start: Line {startLine}, Char {startCharacter}`)
print(`Selection end: Line {endLine}, Char {endCharacter}`)
else
print("열려 있는 스크립트가 없습니다")
endGetText
반환
코드 샘플
ScriptDocument:GetText()
--!nocheck
-- 스크립트가 열려 있는 동안 Command Bar에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local text = scriptDocument:GetText()
print(`스크립트 내용: {text}`)
else
print("열려 있는 스크립트가 없습니다")
endGetViewport
반환
코드 샘플
ScriptDocument:GetViewport
--!nocheck
-- 스크립트가 열려 있는 동안 명령 바에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local firstLine, lastLine = scriptDocument:GetViewport()
print(`현재 보고 있는 줄 {firstLine}에서 {lastLine}까지`)
else
print("열려 있는 스크립트가 없습니다")
endHasSelectedText
반환
코드 샘플
ScriptDocument:HasSelectedText() 및 :GetSelectedText()
--!nocheck
-- 스크립트가 열려 있는 동안 Command Bar에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
scriptDocument.SelectionChanged:Connect(function()
if scriptDocument:HasSelectedText() then
local selectedText = scriptDocument:GetSelectedText()
print(`현재 선택된 텍스트: {selectedText}`)
else
print("현재 선택된 텍스트가 없습니다")
end
end)
else
print("열려 있는 스크립트가 없습니다")
endIsCommandBar
반환
코드 샘플
ScriptDocument:IsCommandBar()
--!nocheck
-- 다음 코드를 Command Bar에서 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if document:IsCommandBar() then
print("명령 바 문서:", document)
end
endRequestSetSelectionAsync
반환
코드 샘플
ScriptDocument:RequestSetSelectionAsync()
--!nocheck
-- 스크립트가 열려 있는 동안 Command Bar에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
-- 커서의 현재 줄에 있는 텍스트 가져오기
local cursorLine = scriptDocument:GetSelection()
local lineText = scriptDocument:GetLine(cursorLine)
-- 전체 줄의 텍스트 선택 강제
local success, err = scriptDocument:RequestSetSelectionAsync(cursorLine, 1, cursorLine, #lineText + 1)
if success then
print("선택이 설정되었습니다!")
else
print(`선택 설정 실패: {err}`)
end
else
print("열려 있는 스크립트가 없습니다")
end이벤트
SelectionChanged
ScriptDocument.SelectionChanged(
코드 샘플
ScriptDocument.SelectionChanged 및 ScriptDocument:GetLine()
--!nocheck
-- 스크립트가 열려 있는 동안 Command Bar에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
scriptDocument.SelectionChanged:Connect(function(positionLine, positionCharacter, anchorLine, anchorCharacter)
print(`선택됨: 줄 {positionLine}, 문자 {positionCharacter}`)
print(`앵커: 줄 {anchorLine}, 문자 {anchorCharacter}`)
local lineText = scriptDocument:GetLine(positionLine)
print(`선택된 줄 텍스트: {lineText}`)
end)
else
print("열려 있는 스크립트가 없습니다")
endViewportChanged
코드 샘플
스크립트 문서의 뷰포트 변경 연결
--!nocheck
--[[
실행 방법:
1. 출력 뷰가 열려 있는지 확인하세요.
2. 아래 코드를 명령 바에서 실행하세요.
3. 열린 스크립트 창에서 위아래로 스크롤하세요.
뷰포트 변경 이벤트의 출력 문이 나타납니다.
]]
local Workspace = game:GetService("Workspace")
local ScriptEditorService = game:GetService("ScriptEditorService")
-- 여러 줄에 걸쳐 있는 텍스트 생성
local dummyText = string.rep("-- 더미 텍스트\n", 60)
-- 더미 텍스트를 포함하는 스크립트를 생성하고 열기
local otherScript = Instance.new("Script")
otherScript.Source = dummyText
otherScript.Parent = Workspace
local success, err = ScriptEditorService:OpenScriptDocumentAsync(otherScript)
if not success then
warn(`스크립트를 열지 못했습니다: {err}`)
return
end
-- 열린 스크립트에 대한 참조 가져오기
local scriptDocument = ScriptEditorService:FindScriptDocument(otherScript)
local function onViewportChanged(startLine: number, endLine: number)
print(`스크립트 뷰포트 변경 - 시작 라인: {startLine}, 종료 라인: {endLine}`)
end
-- 업데이트된 뷰포트의 시작 및 종료 라인을 출력하는 위 함수에 뷰포트 변경 이벤트 연결
scriptDocument.ViewportChanged:Connect(onViewportChanged)