요약
메서드
DeregisterAutocompleteCallback(name: string):() |
DeregisterScriptAnalysisCallback(name: string):() |
GetEditorSource(script: LuaSourceContainer):string |
OpenScriptDocumentAsync(script: LuaSourceContainer,options: Dictionary):Tuple |
RegisterAutocompleteCallback(name: string,priority: number,callbackFunction: function):() |
RegisterScriptAnalysisCallback(name: string,priority: number,callbackFunction: function):() |
UpdateSourceAsync(script: LuaSourceContainer,callback: function):() |
이벤트
TextDocumentDidChange(document: ScriptDocument,changesArray: Variant):RBXScriptSignal |
TextDocumentDidClose(oldDocument: ScriptDocument):RBXScriptSignal |
TextDocumentDidOpen(newDocument: ScriptDocument):RBXScriptSignal |
상속된 멤버
API 참조
메서드
DeregisterAutocompleteCallback
DeregisterScriptAnalysisCallback
FindScriptDocument
매개 변수
코드 샘플
스크립트문서: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("열려 있는 스크립트가 없습니다")
endScriptDocument.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)GetEditorSource
매개 변수
반환
GetScriptDocuments
반환
코드 샘플
모든 스크립트의 이름 출력
--!nocheck
-- 다음 코드를 명령줄에서 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local scriptDocuments = ScriptEditorService:GetScriptDocuments()
for _, scriptDocument in scriptDocuments do
-- 각 스크립트의 이름을 출력합니다
if not scriptDocument:IsCommandBar() then
print(scriptDocument.Name)
end
endOpenScriptDocumentAsync
매개 변수
| 기본값: "nil" |
반환
코드 샘플
OpenScriptDocumentAsync()
--!nocheck
-- 다음 코드를 명령 바에서 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local Workspace = game:GetService("Workspace")
local newScript = Instance.new("Script")
newScript.Parent = Workspace
local success, err = ScriptEditorService:OpenScriptDocumentAsync(newScript)
if success then
print("스크립트 문서가 열렸습니다")
else
print(`스크립트 문서를 여는 데 실패했습니다: {err}`)
endRegisterAutocompleteCallback
반환
()
코드 샘플
RegisterAutocompleteCallback() 및 DeregisterAutocompleteCallback()
--!nocheck
-- 다음 코드를 명령어 바에서 실행하십시오
local ScriptEditorService = game:GetService("ScriptEditorService")
type Request = {
position: {
line: number,
character: number,
},
textDocument: {
document: ScriptDocument?,
script: LuaSourceContainer?,
},
}
type Response = {
items: {
{
label: string,
kind: Enum.CompletionItemKind?,
tags: { Enum.CompletionItemTag }?,
detail: string?,
documentation: {
value: string,
}?,
overloads: number?,
learnMoreLink: string?,
codeSample: string?,
preselect: boolean?,
textEdit: {
newText: string,
replace: {
start: { line: number, character: number },
["end"]: { line: number, character: number },
},
}?,
}
},
}
local autocompleteCallback = function(request: Request, response: Response): Response
local item = {
label = "foo",
preselect = true,
}
table.insert(response.items, item)
return response
end
ScriptEditorService:RegisterAutocompleteCallback("foo", 1, autocompleteCallback)
-- 콜백을 등록 해제하려면 명령어 바에서 다음 코드를 실행하십시오
ScriptEditorService:DeregisterAutocompleteCallback("foo")RegisterScriptAnalysisCallback
반환
()
코드 샘플
RegisterScriptAnalysisCallback()
type Request = {
["script"]: LuaSourceContainer,
}
type Response = {
diagnostics: {
{
range: {
start: {
line: number,
character: number,
},
["end"]: {
line: number,
character: number,
},
},
code: string?,
message: string,
severity: Enum.Severity?,
codeDescription: { href: string }?,
}
},
}
local ScriptEditorService = game:GetService("ScriptEditorService")
ScriptEditorService:RegisterScriptAnalysisCallback("foo", 1, function(Req: Request): Response
local response = {
diagnostics = {},
}
local lineNo = 1
-- 줄별로 반복
for text, newline in Req.script.Source:gmatch("([^\r\n]*)([\r\n]*)") do
local startIndex, endIndex = string.find(text, "Foo")
if startIndex and endIndex then
table.insert(response.diagnostics, {
range = {
["start"] = {
line = lineNo,
character = startIndex,
},
["end"] = {
line = lineNo,
character = endIndex,
},
},
code = "FooFinder",
message = "여기에서 Foo를 찾았습니다!",
severity = Enum.Severity.Warning,
})
end
lineNo = lineNo + #newline:gsub("\n+", "\0%0\0"):gsub(".%z.", "."):gsub("%z", "")
end
return response
end)UpdateSourceAsync
매개 변수
반환
()
이벤트
TextDocumentDidChange
ScriptEditorService.TextDocumentDidChange(
매개 변수
changesArray:Variant |
코드 샘플
ScriptEditorService.TextDocumentDidChange
--!nocheck
-- 다음 코드를 명령줄에서 실행합니다.
local ScriptEditorService = game:GetService("ScriptEditorService")
ScriptEditorService.TextDocumentDidChange:Connect(function(scriptDocument, changes)
print("변경됨", scriptDocument, changes)
end)TextDocumentDidClose
매개 변수
코드 샘플
스크립트편집기서비스.문서닫힘
--!nocheck
-- 다음 코드를 명령 줄에서 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
ScriptEditorService.TextDocumentDidClose:Connect(function(scriptDocument)
print("닫힘", scriptDocument)
end)TextDocumentDidOpen
매개 변수
코드 샘플
ScriptEditorService.TextDocumentDidOpen
--!nocheck
-- 다음 코드를 Command Bar에서 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
ScriptEditorService.TextDocumentDidOpen:Connect(function(scriptDocument)
print("열림", scriptDocument)
end)