요약
메서드
MultiEditTextAsync(edits: {any}):Tuple |
이벤트
SelectionChanged(positionLine: number,positionCharacter: number,anchorLine: number,anchorCharacter: number):RBXScriptSignal |
ViewportChanged(startLine: number,endLine: number):RBXScriptSignal |
상속된 멤버
API 참조
메서드
CloseAsync
반환
코드 샘플
스크립트문서: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
반환
코드 샘플
스크립트문서:ForceSetSelectionAsync()
--!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 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" |
반환
코드 샘플
스크립트문서.SelectionChanged 및 스크립트문서: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
반환
코드 샘플
스크립트 문서: 줄 수 가져오기
--!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 lineCount = scriptDocument:GetLineCount()
print(`스크립트에는 {lineCount} 줄이 있습니다!`)
else
print("열려 있는 스크립트가 없습니다")
endGetScript
코드 샘플
스크립트 문서 가져오기
--!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 openScript = scriptDocument:GetScript()
print(`현재 열려 있는 스크립트: {openScript:GetFullName()}`)
else
print("열려 있는 스크립트가 없습니다")
endGetSelectedText
반환
코드 샘플
스크립트 문서: 선택된 텍스트가 있습니까() 및 :선택된 텍스트 가져오기()
--!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
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
반환
코드 샘플
스크립트문서:텍스트가져오기()
--!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 text = scriptDocument:GetText()
print(`스크립트 내용: {text}`)
else
print("열려 있는 스크립트가 없습니다")
endGetViewport
반환
코드 샘플
스크립트문서:뷰포트가져오기
--!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
반환
코드 샘플
스크립트 문서: 선택된 텍스트가 있습니까() 및 :선택된 텍스트 가져오기()
--!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
scriptDocument.SelectionChanged:Connect(function()
if scriptDocument:HasSelectedText() then
local selectedText = scriptDocument:GetSelectedText()
print(`현재 선택된 텍스트: {selectedText}`)
else
print("현재 선택된 텍스트가 없습니다")
end
end)
else
print("열려 있는 스크립트가 없습니다")
endIsCommandBar
반환
코드 샘플
스크립트 문서:IsCommandBar()
--!nocheck
-- 다음 코드를 명령어 바에서 실행합니다.
local ScriptEditorService = game:GetService("ScriptEditorService")
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if document:IsCommandBar() then
print("명령어 바 문서:", document)
end
endRequestSetSelectionAsync
반환
코드 샘플
스크립트문서:RequestSetSelectionAsync()
--!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 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(
코드 샘플
스크립트문서.SelectionChanged 및 스크립트문서: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
코드 샘플
ScriptDocument.ViewportChanged에 연결 중
--!nocheck
--[[
실행 방법:
1. 출력 뷰가 열려 있는지 확인하세요.
2. 아래 코드를 명령 바에서 실행하세요.
3. 열린 스크립트 창에서 위아래로 스크롤하세요.
ViewportChanged 이벤트에서 인쇄된 문장은 출력에 나타납니다.
]]
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
-- 업데이트된 뷰포트의 시작 및 종료 줄을 인쇄하는 위의 함수에 ViewportChanged 이벤트를 연결합니다
scriptDocument.ViewportChanged:Connect(onViewportChanged)